blob: 8d8bbee26e1239a30accb217ff6339a20dd6e47d [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/network_service.mojom.h"
namespace net {
class URLRequestContextGetter;
namespace network {
namespace mojom {
class NetworkContext;
} // namespace network
namespace safe_browsing {
// This class owns the NetworkContext that is used for requests by Safe
// Browsing.
// All methods are called on the UI thread.
// Note: temporarily this is wrapping SafeBrowsingURLRequestContextGetter,
// however once all requests are converted to using the network service mojo
// APIs we can delete SafeBrowsingURLRequestContextGetter and this object will
// create the NetworkContext directly.
class SafeBrowsingNetworkContext {
// |request_context_getter| is used only if network service is disabled.
// Otherwise |user_dtaa_dir| and |network_context_params_factory| are used
// to construct a URLRequestContext through the network service.
using NetworkContextParamsFactory =
scoped_refptr<net::URLRequestContextGetter> request_context_getter,
const base::FilePath& user_data_dir,
NetworkContextParamsFactory network_context_params_factory);
// Returns a SharedURLLoaderFactory.
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory();
// Returns a NetworkContext.
network::mojom::NetworkContext* GetNetworkContext();
// Flushes NetworkContext and URLLoaderFactory pipes.
void FlushForTesting();
// Called at shutdown to ensure that the URLRequestContextGetter reference is
// destroyed..
void ServiceShuttingDown();
class SharedURLLoaderFactory;
scoped_refptr<SharedURLLoaderFactory> url_loader_factory_;
} // namespace safe_browsing