0

Make services/network a component.

This is needed to fix the cert verifier tests that were temporarily disabled in r532778.

Also remove the public headers in services/network/public/cpp that are implemented in services/network. As Ken pointed out, public/cpp is just client library and isn't a public interface.

Bug: 753658
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: Ie4f721a781cb8c1c345749ea9e1f30cbf67e5fd7
Reviewed-on: https://chromium-review.googlesource.com/894298
Reviewed-by: Ken Rockot <rockot@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533385}
This commit is contained in:
John Abd-El-Malek
2018-01-31 20:30:47 +00:00
committed by Commit Bot
parent f2f3b1c3b5
commit 8e82a32d4c
46 changed files with 173 additions and 174 deletions

@@ -55,7 +55,9 @@ include_rules = [
"+services/identity/public", "+services/identity/public",
"+services/metrics/metrics_mojo_service.h", "+services/metrics/metrics_mojo_service.h",
"+services/metrics/public", "+services/metrics/public",
"+services/network/network_service.h",
"+services/network/public", "+services/network/public",
"+services/network/url_request_context_builder_mojo.h",
"+services/preferences/public/cpp", "+services/preferences/public/cpp",
"+services/preferences/public/interfaces", "+services/preferences/public/interfaces",
"+services/proxy_resolver", # Android runs the packaged proxy resolver "+services/proxy_resolver", # Android runs the packaged proxy resolver

@@ -95,11 +95,11 @@
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h" #include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/ignore_errors_cert_verifier.h" #include "services/network/public/cpp/ignore_errors_cert_verifier.h"
#include "services/network/public/cpp/network_service.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/url_request_context_builder_mojo.h" #include "services/network/url_request_context_builder_mojo.h"
#include "url/url_constants.h" #include "url/url_constants.h"
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)

@@ -25,8 +25,8 @@
#include "content/public/common/service_names.mojom.h" #include "content/public/common/service_names.mojom.h"
#include "mojo/public/cpp/bindings/associated_interface_ptr.h" #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
#include "net/net_features.h" #include "net/net_features.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/network_service.h"
namespace { namespace {

@@ -109,11 +109,11 @@
#include "net/url_request/url_request_intercepting_job_factory.h" #include "net/url_request/url_request_intercepting_job_factory.h"
#include "net/url_request/url_request_interceptor.h" #include "net/url_request/url_request_interceptor.h"
#include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_job_factory_impl.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/ignore_errors_cert_verifier.h" #include "services/network/public/cpp/ignore_errors_cert_verifier.h"
#include "services/network/public/cpp/network_service.h"
#include "services/network/public/cpp/proxy_config_traits.h" #include "services/network/public/cpp/proxy_config_traits.h"
#include "services/network/public/cpp/url_request_context_builder_mojo.h" #include "services/network/url_request_context_builder_mojo.h"
#include "third_party/WebKit/public/public_features.h" #include "third_party/WebKit/public/public_features.h"
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)

@@ -44,7 +44,7 @@ static_library("utility") {
"//media", "//media",
"//net:net_with_v8", "//net:net_with_v8",
"//printing/features", "//printing/features",
"//services/network/public/cpp", "//services/network:network_service",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
"//skia", "//skia",
"//sql", "//sql",

@@ -30,6 +30,7 @@ include_rules = [
"+extensions/utility", "+extensions/utility",
"+media", "+media",
"+services/network/public", "+services/network/public",
"+services/network/url_request_context_builder_mojo.h",
"+services/proxy_resolver", "+services/proxy_resolver",
"+services/service_manager/embedder", "+services/service_manager/embedder",
"+services/service_manager/public/cpp", "+services/service_manager/public/cpp",

@@ -38,7 +38,7 @@
#include "chrome/utility/importer/profile_import_impl.h" #include "chrome/utility/importer/profile_import_impl.h"
#include "chrome/utility/importer/profile_import_service.h" #include "chrome/utility/importer/profile_import_service.h"
#include "net/proxy_resolution/proxy_resolver_v8.h" #include "net/proxy_resolution/proxy_resolver_v8.h"
#include "services/network/public/cpp/url_request_context_builder_mojo.h" #include "services/network/url_request_context_builder_mojo.h"
#include "services/proxy_resolver/proxy_resolver_service.h" // nogncheck #include "services/proxy_resolver/proxy_resolver_service.h" // nogncheck
#include "services/proxy_resolver/public/interfaces/proxy_resolver.mojom.h" // nogncheck #include "services/proxy_resolver/public/interfaces/proxy_resolver.mojom.h" // nogncheck
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)

@@ -10,7 +10,7 @@
#include "content/public/browser/content_browser_client.h" #include "content/public/browser/content_browser_client.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "content/public/common/service_names.mojom.h" #include "content/public/common/service_names.mojom.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
@@ -19,7 +19,7 @@ namespace content {
namespace { namespace {
network::mojom::NetworkServicePtr* g_network_service_ptr = nullptr; network::mojom::NetworkServicePtr* g_network_service_ptr = nullptr;
network::NetworkServiceImpl* g_network_service; network::NetworkService* g_network_service;
void CreateNetworkServiceOnIO(network::mojom::NetworkServiceRequest request) { void CreateNetworkServiceOnIO(network::mojom::NetworkServiceRequest request) {
if (g_network_service) { if (g_network_service) {
@@ -29,7 +29,7 @@ void CreateNetworkServiceOnIO(network::mojom::NetworkServiceRequest request) {
return; return;
} }
g_network_service = new network::NetworkServiceImpl( g_network_service = new network::NetworkService(
nullptr, std::move(request), GetContentClient()->browser()->GetNetLog()); nullptr, std::move(request), GetContentClient()->browser()->GetNetLog());
} }
@@ -66,7 +66,7 @@ network::NetworkService* GetNetworkServiceImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!base::FeatureList::IsEnabled(network::features::kNetworkService)); DCHECK(!base::FeatureList::IsEnabled(network::features::kNetworkService));
if (!g_network_service) { if (!g_network_service) {
g_network_service = new network::NetworkServiceImpl( g_network_service = new network::NetworkService(
nullptr, nullptr, GetContentClient()->browser()->GetNetLog()); nullptr, nullptr, GetContentClient()->browser()->GetNetLog());
} }

@@ -56,7 +56,7 @@
#include "services/device/public/interfaces/constants.mojom.h" #include "services/device/public/interfaces/constants.mojom.h"
#include "services/metrics/metrics_mojo_service.h" #include "services/metrics/metrics_mojo_service.h"
#include "services/metrics/public/interfaces/constants.mojom.h" #include "services/metrics/public/interfaces/constants.mojom.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/interfaces/network_service_test.mojom.h" #include "services/network/public/interfaces/network_service_test.mojom.h"
#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h" #include "services/resource_coordinator/public/cpp/resource_coordinator_features.h"
@@ -321,7 +321,7 @@ std::unique_ptr<service_manager::Service> CreateNetworkService() {
auto registry = std::make_unique<service_manager::BinderRegistry>(); auto registry = std::make_unique<service_manager::BinderRegistry>();
registry->AddInterface(base::BindRepeating( registry->AddInterface(base::BindRepeating(
[](network::mojom::NetworkServiceTestRequest request) {})); [](network::mojom::NetworkServiceTestRequest request) {}));
return std::make_unique<network::NetworkServiceImpl>(std::move(registry)); return std::make_unique<network::NetworkService>(std::move(registry));
} }
} // namespace } // namespace

@@ -45,7 +45,7 @@
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "ppapi/features/features.h" #include "ppapi/features/features.h"
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "storage/browser/blob/blob_registry_impl.h" #include "storage/browser/blob/blob_registry_impl.h"
@@ -267,8 +267,7 @@ class StoragePartitionImpl::NetworkContextOwner {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
context_getter_ = std::move(context_getter); context_getter_ = std::move(context_getter);
network_context_ = std::make_unique<network::NetworkContext>( network_context_ = std::make_unique<network::NetworkContext>(
static_cast<network::NetworkServiceImpl*>(GetNetworkServiceImpl()), GetNetworkServiceImpl(), std::move(network_context_request),
std::move(network_context_request),
context_getter_->GetURLRequestContext()); context_getter_->GetURLRequestContext());
} }

@@ -1,4 +1,5 @@
include_rules = [ include_rules = [
"+services/network/network_service.h",
"+services/network/public/cpp", "+services/network/public/cpp",
] ]

@@ -10,7 +10,7 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "net/base/mock_network_change_notifier.h" #include "net/base/mock_network_change_notifier.h"
#include "services/network/public/cpp/network_service.h" #include "services/network/network_service.h"
#include "services/network/public/interfaces/network_change_manager.mojom.h" #include "services/network/public/interfaces/network_change_manager.mojom.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"

@@ -40,7 +40,7 @@
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/redirect_info.h" #include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/network_service.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_response.h" #include "services/network/public/cpp/resource_response.h"
#include "services/network/public/cpp/url_loader_completion_status.h" #include "services/network/public/cpp/url_loader_completion_status.h"

@@ -23,6 +23,7 @@ include_rules = [
"+services/device/public/cpp/generic_sensor", "+services/device/public/cpp/generic_sensor",
"+services/network/public/cpp", "+services/network/public/cpp",
"+services/network/public/interfaces", "+services/network/public/interfaces",
"+services/network/url_request_context_builder_mojo.h",
"+services/proxy_resolver", "+services/proxy_resolver",
"+services/service_manager/public", "+services/service_manager/public",
"+ui/base/resource/data_pack.h", "+ui/base/resource/data_pack.h",

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "services/network/public/cpp/url_request_context_builder_mojo.h" #include "services/network/url_request_context_builder_mojo.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"

@@ -21,7 +21,7 @@
#include "media/media_features.h" #include "media/media_features.h"
#include "services/data_decoder/data_decoder_service.h" #include "services/data_decoder/data_decoder_service.h"
#include "services/data_decoder/public/interfaces/constants.mojom.h" #include "services/data_decoder/public/interfaces/constants.mojom.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/service_manager/public/interfaces/service.mojom.h" #include "services/service_manager/public/interfaces/service.mojom.h"
#include "services/shape_detection/public/interfaces/constants.mojom.h" #include "services/shape_detection/public/interfaces/constants.mojom.h"
@@ -175,7 +175,7 @@ void UtilityServiceFactory::OnLoadFailed() {
std::unique_ptr<service_manager::Service> std::unique_ptr<service_manager::Service>
UtilityServiceFactory::CreateNetworkService() { UtilityServiceFactory::CreateNetworkService() {
return std::make_unique<network::NetworkServiceImpl>( return std::make_unique<network::NetworkService>(
std::move(network_registry_)); std::move(network_registry_));
} }

@@ -8,7 +8,7 @@ import("//services/service_manager/public/cpp/service.gni")
import("//services/service_manager/public/service_manifest.gni") import("//services/service_manager/public/service_manifest.gni")
import("//services/service_manager/public/tools/test/service_test.gni") import("//services/service_manager/public/tools/test/service_test.gni")
static_library("network_service") { component("network_service") {
sources = [ sources = [
"cache_url_loader.cc", "cache_url_loader.cc",
"cache_url_loader.h", "cache_url_loader.h",
@@ -24,8 +24,8 @@ static_library("network_service") {
"network_context.h", "network_context.h",
"network_sandbox_hook_linux.cc", "network_sandbox_hook_linux.cc",
"network_sandbox_hook_linux.h", "network_sandbox_hook_linux.h",
"network_service_impl.cc", "network_service.cc",
"network_service_impl.h", "network_service.h",
"network_service_url_loader_factory.cc", "network_service_url_loader_factory.cc",
"network_service_url_loader_factory.h", "network_service_url_loader_factory.h",
"proxy_config_service_mojo.cc", "proxy_config_service_mojo.cc",
@@ -53,6 +53,7 @@ static_library("network_service") {
"url_loader.cc", "url_loader.cc",
"url_loader.h", "url_loader.h",
"url_request_context_builder_mojo.cc", "url_request_context_builder_mojo.cc",
"url_request_context_builder_mojo.h",
] ]
deps = [ deps = [
@@ -90,6 +91,8 @@ static_library("network_service") {
] ]
deps += [ "//net:net_browser_services" ] deps += [ "//net:net_browser_services" ]
} }
defines = [ "IS_NETWORK_SERVICE_IMPL" ]
} }
source_set("tests") { source_set("tests") {

@@ -9,6 +9,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
@@ -23,7 +24,8 @@ namespace network {
// This is an IO thread object; all methods on this object must be called on // This is an IO thread object; all methods on this object must be called on
// the IO thread. Note that this does not restrict the locations from which // the IO thread. Note that this does not restrict the locations from which
// mojo messages may be sent to the object. // mojo messages may be sent to the object.
class CookieManager : public network::mojom::CookieManager { class COMPONENT_EXPORT(NETWORK_SERVICE) CookieManager
: public network::mojom::CookieManager {
public: public:
// Construct a CookieService that can serve mojo requests for the underlying // Construct a CookieService that can serve mojo requests for the underlying
// cookie store. |*cookie_store| must outlive this object. // cookie store. |*cookie_store| must outlive this object.

@@ -9,6 +9,7 @@
#include <memory> #include <memory>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
@@ -26,7 +27,8 @@ class IOBuffer;
namespace network { namespace network {
// A subclass of net::UploadElementReader to read data pipes. // A subclass of net::UploadElementReader to read data pipes.
class DataPipeElementReader : public net::UploadElementReader { class COMPONENT_EXPORT(NETWORK_SERVICE) DataPipeElementReader
: public net::UploadElementReader {
public: public:
// |resource_request_body| is just passed in to keep the object around for the // |resource_request_body| is just passed in to keep the object around for the
// life of the ElementReader. // life of the ElementReader.

@@ -9,6 +9,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
@@ -21,7 +22,7 @@ namespace network {
// done through mojo on the main thread. This registers itself to receive // done through mojo on the main thread. This registers itself to receive
// broadcasts from net::NetworkChangeNotifier and rebroadcasts the notifications // broadcasts from net::NetworkChangeNotifier and rebroadcasts the notifications
// to mojom::NetworkChangeManagerClients through mojo pipes. // to mojom::NetworkChangeManagerClients through mojo pipes.
class NetworkChangeManager class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkChangeManager
: public mojom::NetworkChangeManager, : public mojom::NetworkChangeManager,
public net::NetworkChangeNotifier::NetworkChangeObserver { public net::NetworkChangeNotifier::NetworkChangeObserver {
public: public:

@@ -40,19 +40,19 @@
#include "net/url_request/url_request_context_builder.h" #include "net/url_request/url_request_context_builder.h"
#include "services/network/cache_url_loader.h" #include "services/network/cache_url_loader.h"
#include "services/network/http_server_properties_pref_delegate.h" #include "services/network/http_server_properties_pref_delegate.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/network_service_url_loader_factory.h" #include "services/network/network_service_url_loader_factory.h"
#include "services/network/proxy_config_service_mojo.h" #include "services/network/proxy_config_service_mojo.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/ignore_errors_cert_verifier.h" #include "services/network/public/cpp/ignore_errors_cert_verifier.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/url_request_context_builder_mojo.h"
#include "services/network/restricted_cookie_manager.h" #include "services/network/restricted_cookie_manager.h"
#include "services/network/throttling/network_conditions.h" #include "services/network/throttling/network_conditions.h"
#include "services/network/throttling/throttling_controller.h" #include "services/network/throttling/throttling_controller.h"
#include "services/network/throttling/throttling_network_transaction_factory.h" #include "services/network/throttling/throttling_network_transaction_factory.h"
#include "services/network/udp_socket_factory.h" #include "services/network/udp_socket_factory.h"
#include "services/network/url_loader.h" #include "services/network/url_loader.h"
#include "services/network/url_request_context_builder_mojo.h"
namespace network { namespace network {
@@ -85,7 +85,7 @@ class WrappedTestingCertVerifier : public net::CertVerifier {
} // namespace } // namespace
NetworkContext::NetworkContext(NetworkServiceImpl* network_service, NetworkContext::NetworkContext(NetworkService* network_service,
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params) mojom::NetworkContextParamsPtr params)
: network_service_(network_service), : network_service_(network_service),
@@ -104,7 +104,7 @@ NetworkContext::NetworkContext(NetworkServiceImpl* network_service,
// constructors. Can only share them once consumer code is ready for its // constructors. Can only share them once consumer code is ready for its
// corresponding options to be overwritten. // corresponding options to be overwritten.
NetworkContext::NetworkContext( NetworkContext::NetworkContext(
NetworkServiceImpl* network_service, NetworkService* network_service,
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params, mojom::NetworkContextParamsPtr params,
std::unique_ptr<URLRequestContextBuilderMojo> builder) std::unique_ptr<URLRequestContextBuilderMojo> builder)
@@ -120,7 +120,7 @@ NetworkContext::NetworkContext(
std::make_unique<CookieManager>(url_request_context_->cookie_store()); std::make_unique<CookieManager>(url_request_context_->cookie_store());
} }
NetworkContext::NetworkContext(NetworkServiceImpl* network_service, NetworkContext::NetworkContext(NetworkService* network_service,
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
net::URLRequestContext* url_request_context) net::URLRequestContext* url_request_context)
: network_service_(network_service), : network_service_(network_service),

@@ -12,6 +12,7 @@
#include <string> #include <string>
#include "base/callback.h" #include "base/callback.h"
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
@@ -28,7 +29,7 @@ class URLRequestContext;
} // namespace net } // namespace net
namespace network { namespace network {
class NetworkServiceImpl; class NetworkService;
class UDPSocketFactory; class UDPSocketFactory;
class URLLoader; class URLLoader;
class URLRequestContextBuilderMojo; class URLRequestContextBuilderMojo;
@@ -41,20 +42,21 @@ class URLRequestContextBuilderMojo;
// destroyed when either one is torn down. // destroyed when either one is torn down.
// //
// When the network service is disabled, NetworkContexts may be created through // When the network service is disabled, NetworkContexts may be created through
// NetworkServiceImpl::CreateNetworkContextWithBuilder, and take in a // NetworkService::CreateNetworkContextWithBuilder, and take in a
// URLRequestContextBuilderMojo to seed construction of the NetworkContext's // URLRequestContextBuilderMojo to seed construction of the NetworkContext's
// URLRequestContext. When that happens, the consumer takes ownership of the // URLRequestContext. When that happens, the consumer takes ownership of the
// NetworkContext directly, has direct access to its URLRequestContext, and is // NetworkContext directly, has direct access to its URLRequestContext, and is
// responsible for destroying it before the NetworkService. // responsible for destroying it before the NetworkService.
class NetworkContext : public mojom::NetworkContext { class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
: public mojom::NetworkContext {
public: public:
NetworkContext(NetworkServiceImpl* network_service, NetworkContext(NetworkService* network_service,
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params); mojom::NetworkContextParamsPtr params);
// Temporary constructor that allows creating an in-process NetworkContext // Temporary constructor that allows creating an in-process NetworkContext
// with a pre-populated URLRequestContextBuilderMojo. // with a pre-populated URLRequestContextBuilderMojo.
NetworkContext(NetworkServiceImpl* network_service, NetworkContext(NetworkService* network_service,
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params, mojom::NetworkContextParamsPtr params,
std::unique_ptr<URLRequestContextBuilderMojo> builder); std::unique_ptr<URLRequestContextBuilderMojo> builder);
@@ -62,7 +64,7 @@ class NetworkContext : public mojom::NetworkContext {
// Creates a NetworkContext that wraps a consumer-provided URLRequestContext // Creates a NetworkContext that wraps a consumer-provided URLRequestContext
// that the NetworkContext does not own. // that the NetworkContext does not own.
// TODO(mmenke): Remove this constructor when the network service ships. // TODO(mmenke): Remove this constructor when the network service ships.
NetworkContext(NetworkServiceImpl* network_service, NetworkContext(NetworkService* network_service,
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
net::URLRequestContext* url_request_context); net::URLRequestContext* url_request_context);
@@ -75,7 +77,7 @@ class NetworkContext : public mojom::NetworkContext {
net::URLRequestContext* url_request_context() { return url_request_context_; } net::URLRequestContext* url_request_context() { return url_request_context_; }
NetworkServiceImpl* network_service() { return network_service_; } NetworkService* network_service() { return network_service_; }
// These are called by individual url loaders as they are being created and // These are called by individual url loaders as they are being created and
// destroyed. // destroyed.
@@ -103,7 +105,7 @@ class NetworkContext : public mojom::NetworkContext {
bool include_subdomains, bool include_subdomains,
AddHSTSForTestingCallback callback) override; AddHSTSForTestingCallback callback) override;
// Called when the associated NetworkServiceImpl is going away. Guaranteed to // Called when the associated NetworkService is going away. Guaranteed to
// destroy NetworkContext's URLRequestContext. // destroy NetworkContext's URLRequestContext.
void Cleanup(); void Cleanup();
@@ -128,7 +130,7 @@ class NetworkContext : public mojom::NetworkContext {
URLRequestContextOwner MakeURLRequestContext( URLRequestContextOwner MakeURLRequestContext(
mojom::NetworkContextParams* network_context_params); mojom::NetworkContextParams* network_context_params);
NetworkServiceImpl* const network_service_; NetworkService* const network_service_;
// Holds owning pointer to |url_request_context_|. Will contain a nullptr for // Holds owning pointer to |url_request_context_|. Will contain a nullptr for
// |url_request_context| when the NetworkContextImpl doesn't own its own // |url_request_context| when the NetworkContextImpl doesn't own its own

@@ -46,7 +46,7 @@
#include "net/url_request/url_request_context_builder.h" #include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_job_factory.h" #include "net/url_request/url_request_job_factory.h"
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/interfaces/network_service.mojom.h" #include "services/network/public/interfaces/network_service.mojom.h"
#include "services/network/public/interfaces/proxy_config.mojom.h" #include "services/network/public/interfaces/proxy_config.mojom.h"
@@ -73,7 +73,7 @@ class NetworkContextTest : public testing::Test {
NetworkContextTest() NetworkContextTest()
: scoped_task_environment_( : scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO), base::test::ScopedTaskEnvironment::MainThreadType::IO),
network_service_(NetworkServiceImpl::CreateForTesting()) {} network_service_(NetworkService::CreateForTesting()) {}
~NetworkContextTest() override {} ~NetworkContextTest() override {}
std::unique_ptr<NetworkContext> CreateContextWithParams( std::unique_ptr<NetworkContext> CreateContextWithParams(
@@ -110,7 +110,7 @@ class NetworkContextTest : public testing::Test {
protected: protected:
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<NetworkServiceImpl> network_service_; std::unique_ptr<NetworkService> network_service_;
// Stores the NetworkContextPtr of the most recently created NetworkContext, // Stores the NetworkContextPtr of the most recently created NetworkContext,
// since destroying this before the NetworkContext itself triggers deletion of // since destroying this before the NetworkContext itself triggers deletion of
// the NetworkContext. These tests are probably fine anyways, since the // the NetworkContext. These tests are probably fine anyways, since the

@@ -5,10 +5,12 @@
#ifndef SERVICES_NETWORK_NETWORK_SANDBOX_HOOK_LINUX_H_ #ifndef SERVICES_NETWORK_NETWORK_SANDBOX_HOOK_LINUX_H_
#define SERVICES_NETWORK_NETWORK_SANDBOX_HOOK_LINUX_H_ #define SERVICES_NETWORK_NETWORK_SANDBOX_HOOK_LINUX_H_
#include "base/component_export.h"
#include "services/service_manager/sandbox/linux/sandbox_linux.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h"
namespace network { namespace network {
COMPONENT_EXPORT(NETWORK_SERVICE)
bool NetworkPreSandboxHook(service_manager::SandboxLinux::Options options); bool NetworkPreSandboxHook(service_manager::SandboxLinux::Options options);
} // namespace network } // namespace network

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include <utility> #include <utility>
@@ -20,7 +20,7 @@
#include "net/url_request/url_request_context_builder.h" #include "net/url_request/url_request_context_builder.h"
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/url_request_context_builder_mojo.h" #include "services/network/url_request_context_builder_mojo.h"
namespace network { namespace network {
@@ -50,14 +50,7 @@ CreateNetworkChangeNotifierIfNeeded() {
} // namespace } // namespace
std::unique_ptr<NetworkService> NetworkService::Create( class NetworkService::MojoNetLog : public net::NetLog {
mojom::NetworkServiceRequest request,
net::NetLog* net_log) {
return std::make_unique<NetworkServiceImpl>(nullptr, std::move(request),
net_log);
}
class NetworkServiceImpl::MojoNetLog : public net::NetLog {
public: public:
MojoNetLog() {} MojoNetLog() {}
@@ -89,7 +82,7 @@ class NetworkServiceImpl::MojoNetLog : public net::NetLog {
DISALLOW_COPY_AND_ASSIGN(MojoNetLog); DISALLOW_COPY_AND_ASSIGN(MojoNetLog);
}; };
NetworkServiceImpl::NetworkServiceImpl( NetworkService::NetworkService(
std::unique_ptr<service_manager::BinderRegistry> registry, std::unique_ptr<service_manager::BinderRegistry> registry,
mojom::NetworkServiceRequest request, mojom::NetworkServiceRequest request,
net::NetLog* net_log) net::NetLog* net_log)
@@ -101,7 +94,7 @@ NetworkServiceImpl::NetworkServiceImpl(
if (registry_) { if (registry_) {
DCHECK(!request.is_pending()); DCHECK(!request.is_pending());
registry_->AddInterface<mojom::NetworkService>( registry_->AddInterface<mojom::NetworkService>(
base::BindRepeating(&NetworkServiceImpl::Bind, base::Unretained(this))); base::BindRepeating(&NetworkService::Bind, base::Unretained(this)));
} else if (request.is_pending()) { } else if (request.is_pending()) {
Bind(std::move(request)); Bind(std::move(request));
} }
@@ -127,7 +120,7 @@ NetworkServiceImpl::NetworkServiceImpl(
new net::LoggingNetworkChangeObserver(net_log_)); new net::LoggingNetworkChangeObserver(net_log_));
} }
NetworkServiceImpl::~NetworkServiceImpl() { NetworkService::~NetworkService() {
// Call each Network and ask it to release its net::URLRequestContext, as they // Call each Network and ask it to release its net::URLRequestContext, as they
// may have references to shared objects owned by the NetworkService. The // may have references to shared objects owned by the NetworkService. The
// NetworkContexts deregister themselves in Cleanup(), so have to be careful. // NetworkContexts deregister themselves in Cleanup(), so have to be careful.
@@ -135,8 +128,14 @@ NetworkServiceImpl::~NetworkServiceImpl() {
(*network_contexts_.begin())->Cleanup(); (*network_contexts_.begin())->Cleanup();
} }
std::unique_ptr<NetworkService> NetworkService::Create(
mojom::NetworkServiceRequest request,
net::NetLog* net_log) {
return std::make_unique<NetworkService>(nullptr, std::move(request), net_log);
}
std::unique_ptr<mojom::NetworkContext> std::unique_ptr<mojom::NetworkContext>
NetworkServiceImpl::CreateNetworkContextWithBuilder( NetworkService::CreateNetworkContextWithBuilder(
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params, mojom::NetworkContextParamsPtr params,
std::unique_ptr<URLRequestContextBuilderMojo> builder, std::unique_ptr<URLRequestContextBuilderMojo> builder,
@@ -148,30 +147,28 @@ NetworkServiceImpl::CreateNetworkContextWithBuilder(
return network_context; return network_context;
} }
std::unique_ptr<NetworkServiceImpl> NetworkServiceImpl::CreateForTesting() { std::unique_ptr<NetworkService> NetworkService::CreateForTesting() {
return base::WrapUnique(new NetworkServiceImpl( return base::WrapUnique(
std::make_unique<service_manager::BinderRegistry>())); new NetworkService(std::make_unique<service_manager::BinderRegistry>()));
} }
void NetworkServiceImpl::RegisterNetworkContext( void NetworkService::RegisterNetworkContext(NetworkContext* network_context) {
NetworkContext* network_context) {
DCHECK_EQ(0u, network_contexts_.count(network_context)); DCHECK_EQ(0u, network_contexts_.count(network_context));
network_contexts_.insert(network_context); network_contexts_.insert(network_context);
if (quic_disabled_) if (quic_disabled_)
network_context->DisableQuic(); network_context->DisableQuic();
} }
void NetworkServiceImpl::DeregisterNetworkContext( void NetworkService::DeregisterNetworkContext(NetworkContext* network_context) {
NetworkContext* network_context) {
DCHECK_EQ(1u, network_contexts_.count(network_context)); DCHECK_EQ(1u, network_contexts_.count(network_context));
network_contexts_.erase(network_context); network_contexts_.erase(network_context);
} }
void NetworkServiceImpl::SetClient(mojom::NetworkServiceClientPtr client) { void NetworkService::SetClient(mojom::NetworkServiceClientPtr client) {
client_ = std::move(client); client_ = std::move(client);
} }
void NetworkServiceImpl::CreateNetworkContext( void NetworkService::CreateNetworkContext(
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params) { mojom::NetworkContextParamsPtr params) {
// The NetworkContext will destroy itself on connection error, or when the // The NetworkContext will destroy itself on connection error, or when the
@@ -179,7 +176,7 @@ void NetworkServiceImpl::CreateNetworkContext(
new NetworkContext(this, std::move(request), std::move(params)); new NetworkContext(this, std::move(request), std::move(params));
} }
void NetworkServiceImpl::DisableQuic() { void NetworkService::DisableQuic() {
quic_disabled_ = true; quic_disabled_ = true;
for (auto* network_context : network_contexts_) { for (auto* network_context : network_contexts_) {
@@ -187,7 +184,7 @@ void NetworkServiceImpl::DisableQuic() {
} }
} }
void NetworkServiceImpl::SetRawHeadersAccess(uint32_t process_id, bool allow) { void NetworkService::SetRawHeadersAccess(uint32_t process_id, bool allow) {
DCHECK(process_id); DCHECK(process_id);
if (allow) if (allow)
processes_with_raw_headers_access_.insert(process_id); processes_with_raw_headers_access_.insert(process_id);
@@ -195,7 +192,7 @@ void NetworkServiceImpl::SetRawHeadersAccess(uint32_t process_id, bool allow) {
processes_with_raw_headers_access_.erase(process_id); processes_with_raw_headers_access_.erase(process_id);
} }
bool NetworkServiceImpl::HasRawHeadersAccess(uint32_t process_id) const { bool NetworkService::HasRawHeadersAccess(uint32_t process_id) const {
// Allow raw headers for browser-initiated requests. // Allow raw headers for browser-initiated requests.
if (!process_id) if (!process_id)
return true; return true;
@@ -203,23 +200,23 @@ bool NetworkServiceImpl::HasRawHeadersAccess(uint32_t process_id) const {
processes_with_raw_headers_access_.end(); processes_with_raw_headers_access_.end();
} }
net::NetLog* NetworkServiceImpl::net_log() const { net::NetLog* NetworkService::net_log() const {
return net_log_; return net_log_;
} }
void NetworkServiceImpl::GetNetworkChangeManager( void NetworkService::GetNetworkChangeManager(
mojom::NetworkChangeManagerRequest request) { mojom::NetworkChangeManagerRequest request) {
network_change_manager_->AddRequest(std::move(request)); network_change_manager_->AddRequest(std::move(request));
} }
void NetworkServiceImpl::OnBindInterface( void NetworkService::OnBindInterface(
const service_manager::BindSourceInfo& source_info, const service_manager::BindSourceInfo& source_info,
const std::string& interface_name, const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) { mojo::ScopedMessagePipeHandle interface_pipe) {
registry_->BindInterface(interface_name, std::move(interface_pipe)); registry_->BindInterface(interface_name, std::move(interface_pipe));
} }
void NetworkServiceImpl::Bind(mojom::NetworkServiceRequest request) { void NetworkService::Bind(mojom::NetworkServiceRequest request) {
DCHECK(!binding_.is_bound()); DCHECK(!binding_.is_bound());
binding_.Bind(std::move(request)); binding_.Bind(std::move(request));
} }

@@ -2,17 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef SERVICES_NETWORK_NETWORK_SERVICE_IMPL_H_ #ifndef SERVICES_NETWORK_NETWORK_SERVICE_H_
#define SERVICES_NETWORK_NETWORK_SERVICE_IMPL_H_ #define SERVICES_NETWORK_NETWORK_SERVICE_H_
#include <memory> #include <memory>
#include <set> #include <set>
#include <string> #include <string>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "services/network/network_change_manager.h" #include "services/network/network_change_manager.h"
#include "services/network/public/cpp/network_service.h" #include "services/network/network_service.h"
#include "services/network/public/interfaces/network_change_manager.mojom.h" #include "services/network/public/interfaces/network_change_manager.mojom.h"
#include "services/network/public/interfaces/network_service.mojom.h" #include "services/network/public/interfaces/network_service.mojom.h"
#include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/binder_registry.h"
@@ -21,37 +22,60 @@
namespace net { namespace net {
class NetLog; class NetLog;
class LoggingNetworkChangeObserver; class LoggingNetworkChangeObserver;
class URLRequestContext;
} // namespace net } // namespace net
namespace network { namespace network {
class NetworkContext; class NetworkContext;
class URLRequestContextBuilderMojo;
class NetworkServiceImpl : public service_manager::Service, class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkService
public NetworkService { : public service_manager::Service,
public network::mojom::NetworkService {
public: public:
// |net_log| is an optional shared NetLog, which will be used instead of the // |net_log| is an optional shared NetLog, which will be used instead of the
// service's own NetLog. It must outlive the NetworkService. // service's own NetLog. It must outlive the NetworkService.
// //
// TODO(https://crbug.com/767450): Once the NetworkService can always create // TODO(https://crbug.com/767450): Once the NetworkService can always create
// its own NetLog in production, remove the |net_log| argument. // its own NetLog in production, remove the |net_log| argument.
NetworkServiceImpl(std::unique_ptr<service_manager::BinderRegistry> registry, NetworkService(std::unique_ptr<service_manager::BinderRegistry> registry,
mojom::NetworkServiceRequest request = nullptr, mojom::NetworkServiceRequest request = nullptr,
net::NetLog* net_log = nullptr); net::NetLog* net_log = nullptr);
~NetworkServiceImpl() override; ~NetworkService() override;
// Can be used to seed a NetworkContext with a consumer-configured
// URLRequestContextBuilder, which |params| will then be applied to. The
// results URLRequestContext will be written to |url_request_context|, which
// is owned by the NetworkContext, and can be further modified before first
// use. The returned NetworkContext must be destroyed before the
// NetworkService.
//
// This method is intended to ease the transition to an out-of-process
// NetworkService, and will be removed once that ships. It should only be
// called if the network service is disabled.
std::unique_ptr<mojom::NetworkContext> CreateNetworkContextWithBuilder( std::unique_ptr<mojom::NetworkContext> CreateNetworkContextWithBuilder(
mojom::NetworkContextRequest request, mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params, mojom::NetworkContextParamsPtr params,
std::unique_ptr<URLRequestContextBuilderMojo> builder, std::unique_ptr<URLRequestContextBuilderMojo> builder,
net::URLRequestContext** url_request_context) override; net::URLRequestContext** url_request_context);
// Allows late binding if the mojo request wasn't specified in the // Allows late binding if the mojo request wasn't specified in the
// constructor. // constructor.
void Bind(mojom::NetworkServiceRequest request); void Bind(mojom::NetworkServiceRequest request);
static std::unique_ptr<NetworkServiceImpl> CreateForTesting(); // Creates a NetworkService instance on the current thread, optionally using
// the passed-in NetLog. Does not take ownership of |net_log|. Must be
// destroyed before |net_log|.
//
// TODO(https://crbug.com/767450): Make it so NetworkService can always create
// its own NetLog, instead of sharing one.
static std::unique_ptr<NetworkService> Create(
network::mojom::NetworkServiceRequest request,
net::NetLog* net_log = nullptr);
static std::unique_ptr<NetworkService> CreateForTesting();
// These are called by NetworkContexts as they are being created and // These are called by NetworkContexts as they are being created and
// destroyed. // destroyed.
@@ -110,9 +134,9 @@ class NetworkServiceImpl : public service_manager::Service,
bool quic_disabled_ = false; bool quic_disabled_ = false;
DISALLOW_COPY_AND_ASSIGN(NetworkServiceImpl); DISALLOW_COPY_AND_ASSIGN(NetworkService);
}; };
} // namespace network } // namespace network
#endif // SERVICES_NETWORK_NETWORK_SERVICE_IMPL_H_ #endif // SERVICES_NETWORK_NETWORK_SERVICE_H_

@@ -14,7 +14,7 @@
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/interfaces/network_change_manager.mojom.h" #include "services/network/public/interfaces/network_change_manager.mojom.h"
#include "services/network/public/interfaces/network_service.mojom.h" #include "services/network/public/interfaces/network_service.mojom.h"
#include "services/network/test/test_url_loader_client.h" #include "services/network/test/test_url_loader_client.h"
@@ -42,7 +42,7 @@ class NetworkServiceTest : public testing::Test {
NetworkServiceTest() NetworkServiceTest()
: scoped_task_environment_( : scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO), base::test::ScopedTaskEnvironment::MainThreadType::IO),
service_(NetworkServiceImpl::CreateForTesting()) {} service_(NetworkService::CreateForTesting()) {}
~NetworkServiceTest() override {} ~NetworkServiceTest() override {}
NetworkService* service() const { return service_.get(); } NetworkService* service() const { return service_.get(); }
@@ -106,7 +106,7 @@ class ServiceTestClient : public service_manager::test::ServiceTestClient,
service_manager::mojom::PIDReceiverPtr pid_receiver) override { service_manager::mojom::PIDReceiverPtr pid_receiver) override {
if (name == kNetworkServiceName) { if (name == kNetworkServiceName) {
service_context_.reset(new service_manager::ServiceContext( service_context_.reset(new service_manager::ServiceContext(
NetworkServiceImpl::CreateForTesting(), std::move(request))); NetworkService::CreateForTesting(), std::move(request)));
} }
} }
@@ -372,7 +372,7 @@ class NetworkChangeTest : public testing::Test {
NetworkChangeTest() NetworkChangeTest()
: scoped_task_environment_( : scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO) { base::test::ScopedTaskEnvironment::MainThreadType::IO) {
service_ = NetworkServiceImpl::CreateForTesting(); service_ = NetworkService::CreateForTesting();
} }
~NetworkChangeTest() override {} ~NetworkChangeTest() override {}
@@ -431,7 +431,7 @@ class NetworkServiceNetworkChangeTest
service_manager::mojom::PIDReceiverPtr pid_receiver) override { service_manager::mojom::PIDReceiverPtr pid_receiver) override {
if (name == kNetworkServiceName) { if (name == kNetworkServiceName) {
service_context_.reset(new service_manager::ServiceContext( service_context_.reset(new service_manager::ServiceContext(
NetworkServiceImpl::CreateForTesting(), std::move(request))); NetworkService::CreateForTesting(), std::move(request)));
// Send a broadcast after NetworkService is actually created. // Send a broadcast after NetworkService is actually created.
// Otherwise, this NotifyObservers is a no-op. // Otherwise, this NotifyObservers is a no-op.
net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests(

@@ -6,7 +6,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/resource_request.h"
#include "services/network/url_loader.h" #include "services/network/url_loader.h"
@@ -31,7 +31,7 @@ void NetworkServiceURLLoaderFactory::CreateLoaderAndStart(
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) { const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
bool report_raw_headers = false; bool report_raw_headers = false;
if (url_request.report_raw_headers) { if (url_request.report_raw_headers) {
const NetworkServiceImpl* service = context_->network_service(); const NetworkService* service = context_->network_service();
report_raw_headers = service && service->HasRawHeadersAccess(process_id_); report_raw_headers = service && service->HasRawHeadersAccess(process_id_);
if (!report_raw_headers) if (!report_raw_headers)
DLOG(ERROR) << "Denying raw headers request by process " << process_id_; DLOG(ERROR) << "Denying raw headers request by process " << process_id_;

@@ -5,6 +5,7 @@
#ifndef SERVICES_NETWORK_PROXY_CONFIG_SERVICE_MOJO_H_ #ifndef SERVICES_NETWORK_PROXY_CONFIG_SERVICE_MOJO_H_
#define SERVICES_NETWORK_PROXY_CONFIG_SERVICE_MOJO_H_ #define SERVICES_NETWORK_PROXY_CONFIG_SERVICE_MOJO_H_
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/optional.h" #include "base/optional.h"
@@ -20,8 +21,9 @@ class ProxyConfig;
namespace network { namespace network {
// ProxyConfigService that gets its proxy configuration over a Mojo pipe. // ProxyConfigService that gets its proxy configuration over a Mojo pipe.
class ProxyConfigServiceMojo : public net::ProxyConfigService, class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyConfigServiceMojo
public mojom::ProxyConfigClient { : public net::ProxyConfigService,
public mojom::ProxyConfigClient {
public: public:
// |proxy_config_client_request| is the Mojo pipe over which new // |proxy_config_client_request| is the Mojo pipe over which new
// configurations are received. |initial_proxy_config| is the initial proxy // configurations are received. |initial_proxy_config| is the initial proxy

@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
@@ -26,7 +27,8 @@ namespace network {
// Implementation of ProxyResolverFactory that connects to a Mojo service to // Implementation of ProxyResolverFactory that connects to a Mojo service to
// create implementations of a Mojo proxy resolver to back a ProxyResolverMojo. // create implementations of a Mojo proxy resolver to back a ProxyResolverMojo.
class ProxyResolverFactoryMojo : public net::ProxyResolverFactory { class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolverFactoryMojo
: public net::ProxyResolverFactory {
public: public:
ProxyResolverFactoryMojo( ProxyResolverFactoryMojo(
proxy_resolver::mojom::ProxyResolverFactoryPtr mojo_proxy_factory, proxy_resolver::mojom::ProxyResolverFactoryPtr mojo_proxy_factory,

@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "base/component_export.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher.h" #include "net/proxy_resolution/dhcp_pac_file_fetcher.h"
#include "services/proxy_resolver/public/interfaces/proxy_resolver.mojom.h" #include "services/proxy_resolver/public/interfaces/proxy_resolver.mojom.h"
@@ -34,6 +35,7 @@ namespace network {
// |host_resolver| points to the host resolving dependency the PAC script // |host_resolver| points to the host resolving dependency the PAC script
// should use for any DNS queries. It must remain valid throughout the // should use for any DNS queries. It must remain valid throughout the
// lifetime of the ProxyResolutionService. // lifetime of the ProxyResolutionService.
COMPONENT_EXPORT(NETWORK_SERVICE)
std::unique_ptr<net::ProxyResolutionService> CreateProxyServiceUsingMojoFactory( std::unique_ptr<net::ProxyResolutionService> CreateProxyServiceUsingMojoFactory(
proxy_resolver::mojom::ProxyResolverFactoryPtr mojo_proxy_factory, proxy_resolver::mojom::ProxyResolverFactoryPtr mojo_proxy_factory,
std::unique_ptr<net::ProxyConfigService> proxy_config_service, std::unique_ptr<net::ProxyConfigService> proxy_config_service,

@@ -20,14 +20,12 @@ component("cpp") {
"mutable_partial_network_traffic_annotation_tag_struct_traits.h", "mutable_partial_network_traffic_annotation_tag_struct_traits.h",
"net_adapters.cc", "net_adapters.cc",
"net_adapters.h", "net_adapters.h",
"network_service.h",
"network_switches.cc", "network_switches.cc",
"network_switches.h", "network_switches.h",
"proxy_resolving_client_socket.cc", "proxy_resolving_client_socket.cc",
"proxy_resolving_client_socket.h", "proxy_resolving_client_socket.h",
"proxy_resolving_client_socket_factory.cc", "proxy_resolving_client_socket_factory.cc",
"proxy_resolving_client_socket_factory.h", "proxy_resolving_client_socket_factory.h",
"url_request_context_builder_mojo.h",
"url_request_context_owner.cc", "url_request_context_owner.cc",
"url_request_context_owner.h", "url_request_context_owner.h",
] ]

@@ -1,59 +0,0 @@
// Copyright 2017 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.
#ifndef SERVICES_NETWORK_PUBLIC_CPP_NETWORK_SERVICE_H_
#define SERVICES_NETWORK_PUBLIC_CPP_NETWORK_SERVICE_H_
#include <memory>
#include "services/network/public/interfaces/network_service.mojom.h"
namespace net {
class NetLog;
class URLRequestContext;
} // namespace net
namespace network {
class URLRequestContextBuilderMojo;
// Allows an in-process NetworkService to be set up.
class NetworkService : public network::mojom::NetworkService {
public:
// Creates a NetworkService instance on the current thread, optionally using
// the passed-in NetLog. Does not take ownership of |net_log|. Must be
// destroyed before |net_log|.
//
// TODO(https://crbug.com/767450): Make it so NetworkService can always create
// its own NetLog, instead of sharing one.
static std::unique_ptr<NetworkService> Create(
network::mojom::NetworkServiceRequest request,
net::NetLog* net_log = nullptr);
// Can be used to seed a NetworkContext with a consumer-configured
// URLRequestContextBuilder, which |params| will then be applied to. The
// results URLRequestContext will be written to |url_request_context|, which
// is owned by the NetworkContext, and can be further modified before first
// use. The returned NetworkContext must be destroyed before the
// NetworkService.
//
// This method is intended to ease the transition to an out-of-process
// NetworkService, and will be removed once that ships. It should only be
// called if the network service is disabled.
virtual std::unique_ptr<network::mojom::NetworkContext>
CreateNetworkContextWithBuilder(
network::mojom::NetworkContextRequest request,
network::mojom::NetworkContextParamsPtr params,
std::unique_ptr<URLRequestContextBuilderMojo> builder,
net::URLRequestContext** url_request_context) = 0;
~NetworkService() override {}
protected:
NetworkService() {}
};
} // namespace network
#endif // SERVICES_NETWORK_PUBLIC_CPP_NETWORK_SERVICE_H_

@@ -7,6 +7,7 @@
#include <string> #include <string>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
@@ -27,7 +28,8 @@ namespace network {
// Instances of this class must be created and used on the I/O thread. Instances // Instances of this class must be created and used on the I/O thread. Instances
// are created by CreateMojoService() and are bound to the lifetimes of the // are created by CreateMojoService() and are bound to the lifetimes of the
// mojo connections that they serve, via mojo::StrongBinding. // mojo connections that they serve, via mojo::StrongBinding.
class RestrictedCookieManager : public mojom::RestrictedCookieManager { class COMPONENT_EXPORT(NETWORK_SERVICE) RestrictedCookieManager
: public mojom::RestrictedCookieManager {
public: public:
RestrictedCookieManager(net::CookieStore* cookie_store, RestrictedCookieManager(net::CookieStore* cookie_store,
int render_process_id, int render_process_id,

@@ -8,12 +8,13 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
namespace network { namespace network {
// NetworkConditions holds information about desired network conditions. // NetworkConditions holds information about desired network conditions.
class NetworkConditions { class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkConditions {
public: public:
NetworkConditions(); NetworkConditions();
~NetworkConditions(); ~NetworkConditions();

@@ -9,6 +9,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
@@ -19,7 +20,7 @@ class ThrottlingNetworkInterceptor;
// ThrottlingController manages interceptors identified by client id // ThrottlingController manages interceptors identified by client id
// and their throttling conditions. // and their throttling conditions.
class ThrottlingController { class COMPONENT_EXPORT(NETWORK_SERVICE) ThrottlingController {
public: public:
// Applies network emulation configuration. // Applies network emulation configuration.
static void SetConditions(const std::string& client_id, static void SetConditions(const std::string& client_id,

@@ -13,6 +13,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
@@ -26,7 +27,7 @@ class NetworkConditions;
// ThrottlingNetworkInterceptor emulates network conditions for transactions // ThrottlingNetworkInterceptor emulates network conditions for transactions
// with specific client id. // with specific client id.
class ThrottlingNetworkInterceptor { class COMPONENT_EXPORT(NETWORK_SERVICE) ThrottlingNetworkInterceptor {
public: public:
using ThrottleCallback = base::Callback<void(int, int64_t)>; using ThrottleCallback = base::Callback<void(int, int64_t)>;

@@ -9,6 +9,7 @@
#include <memory> #include <memory>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
@@ -41,7 +42,8 @@ class ThrottlingUploadDataStream;
// parameter is saved and replaced with proxy callback. Fail method should be // parameter is saved and replaced with proxy callback. Fail method should be
// used to simulate network outage. It runs saved callback (if any) with // used to simulate network outage. It runs saved callback (if any) with
// net::ERR_INTERNET_DISCONNECTED result value. // net::ERR_INTERNET_DISCONNECTED result value.
class ThrottlingNetworkTransaction : public net::HttpTransaction { class COMPONENT_EXPORT(NETWORK_SERVICE) ThrottlingNetworkTransaction
: public net::HttpTransaction {
public: public:
static const char kDevToolsEmulateNetworkConditionsClientId[]; static const char kDevToolsEmulateNetworkConditionsClientId[];

@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
#include "net/http/http_transaction_factory.h" #include "net/http/http_transaction_factory.h"
@@ -20,7 +21,8 @@ class HttpTransaction;
namespace network { namespace network {
// NetworkTransactionFactory wraps HttpNetworkTransactions. // NetworkTransactionFactory wraps HttpNetworkTransactions.
class ThrottlingNetworkTransactionFactory : public net::HttpTransactionFactory { class COMPONENT_EXPORT(NETWORK_SERVICE) ThrottlingNetworkTransactionFactory
: public net::HttpTransactionFactory {
public: public:
explicit ThrottlingNetworkTransactionFactory( explicit ThrottlingNetworkTransactionFactory(
net::HttpNetworkSession* session); net::HttpNetworkSession* session);

@@ -9,6 +9,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/containers/span.h" #include "base/containers/span.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
@@ -29,7 +30,7 @@ class IOBufferWithSize;
namespace network { namespace network {
class UDPSocket : public mojom::UDPSocket { class COMPONENT_EXPORT(NETWORK_SERVICE) UDPSocket : public mojom::UDPSocket {
public: public:
// Number of Send()/SendTo() requests that are queued internally. Public for // Number of Send()/SendTo() requests that are queued internally. Public for
// testing. // testing.

@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "services/network/public/interfaces/udp_socket.mojom.h" #include "services/network/public/interfaces/udp_socket.mojom.h"
@@ -17,7 +18,7 @@ class UDPSocket;
// Helper class that handles UDPSocketRequest. It takes care of destroying the // Helper class that handles UDPSocketRequest. It takes care of destroying the
// UDPSocket implementation instances when mojo pipes are broken. // UDPSocket implementation instances when mojo pipes are broken.
class UDPSocketFactory { class COMPONENT_EXPORT(NETWORK_SERVICE) UDPSocketFactory {
public: public:
UDPSocketFactory(); UDPSocketFactory();
virtual ~UDPSocketFactory(); virtual ~UDPSocketFactory();

@@ -8,6 +8,7 @@
#include <stdint.h> #include <stdint.h>
#include "base/callback.h" #include "base/callback.h"
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
@@ -28,7 +29,7 @@ namespace network {
// UploadProgressTracker watches the upload progress of a URL loading, and sends // UploadProgressTracker watches the upload progress of a URL loading, and sends
// the progress to the client in a suitable granularity and frequency. // the progress to the client in a suitable granularity and frequency.
class UploadProgressTracker { class COMPONENT_EXPORT(NETWORK_SERVICE) UploadProgressTracker {
public: public:
using UploadProgressReportCallback = using UploadProgressReportCallback =
base::RepeatingCallback<void(const net::UploadProgress&)>; base::RepeatingCallback<void(const net::UploadProgress&)>;

@@ -23,7 +23,7 @@
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "services/network/data_pipe_element_reader.h" #include "services/network/data_pipe_element_reader.h"
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/network_service_impl.h" #include "services/network/network_service.h"
#include "services/network/public/cpp/loader_util.h" #include "services/network/public/cpp/loader_util.h"
#include "services/network/public/cpp/net_adapters.h" #include "services/network/public/cpp/net_adapters.h"
#include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/resource_request.h"

@@ -9,6 +9,7 @@
#include <memory> #include <memory>
#include "base/component_export.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/data_pipe.h" #include "mojo/public/cpp/system/data_pipe.h"
@@ -30,7 +31,9 @@ class NetworkContext;
class NetToMojoPendingBuffer; class NetToMojoPendingBuffer;
struct ResourceResponse; struct ResourceResponse;
class URLLoader : public mojom::URLLoader, public net::URLRequest::Delegate { class COMPONENT_EXPORT(NETWORK_SERVICE) URLLoader
: public mojom::URLLoader,
public net::URLRequest::Delegate {
public: public:
URLLoader(NetworkContext* context, URLLoader(NetworkContext* context,
mojom::URLLoaderRequest url_loader_request, mojom::URLLoaderRequest url_loader_request,

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "services/network/public/cpp/url_request_context_builder_mojo.h" #include "services/network/url_request_context_builder_mojo.h"
#include "base/logging.h" #include "base/logging.h"
#include "build/build_config.h" #include "build/build_config.h"

@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef SERVICES_NETWORK_PUBLIC_CPP_URL_REQUEST_CONTEXT_BUILDER_MOJO_H_ #ifndef SERVICES_NETWORK_URL_REQUEST_CONTEXT_BUILDER_MOJO_H_
#define SERVICES_NETWORK_PUBLIC_CPP_URL_REQUEST_CONTEXT_BUILDER_MOJO_H_ #define SERVICES_NETWORK_URL_REQUEST_CONTEXT_BUILDER_MOJO_H_
#include <memory> #include <memory>
#include "base/component_export.h"
#include "base/macros.h" #include "base/macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher_factory.h" #include "net/proxy_resolution/dhcp_pac_file_fetcher_factory.h"
@@ -30,7 +31,8 @@ namespace network {
// responsible for providing the proxy_resolver::mojom::ProxyResolverFactory. // responsible for providing the proxy_resolver::mojom::ProxyResolverFactory.
// If a ProxyResolutionService is set directly via the URLRequestContextBuilder // If a ProxyResolutionService is set directly via the URLRequestContextBuilder
// API, it will be used instead. // API, it will be used instead.
class URLRequestContextBuilderMojo : public net::URLRequestContextBuilder { class COMPONENT_EXPORT(NETWORK_SERVICE) URLRequestContextBuilderMojo
: public net::URLRequestContextBuilder {
public: public:
URLRequestContextBuilderMojo(); URLRequestContextBuilderMojo();
~URLRequestContextBuilderMojo() override; ~URLRequestContextBuilderMojo() override;
@@ -74,4 +76,4 @@ class URLRequestContextBuilderMojo : public net::URLRequestContextBuilder {
} // namespace network } // namespace network
#endif // SERVICES_NETWORK_PUBLIC_CPP_URL_REQUEST_CONTEXT_BUILDER_MOJO_H_ #endif // SERVICES_NETWORK_URL_REQUEST_CONTEXT_BUILDER_MOJO_H_