Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1811)

Unified Diff: net/url_request/url_request_context_builder.cc

Issue 2881613002: Allow use of Mojo/V8 ProxyResolvers with URLRequestContextBuilder. (Closed)
Patch Set: Forgot to remove WaitForConnectionsListener Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request_context_builder.cc
diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc
index 90c240bc066c782bb82749cbe6cd03ad6ed61c05..aa68ca71349694d076e54546d1f1aec8e8c82c4e 100644
--- a/net/url_request/url_request_context_builder.cc
+++ b/net/url_request/url_request_context_builder.cc
@@ -138,7 +138,14 @@ class ContainerURLRequestContext : public URLRequestContext {
explicit ContainerURLRequestContext(
const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner)
: file_task_runner_(file_task_runner), storage_(this) {}
- ~ContainerURLRequestContext() override { AssertNoURLRequests(); }
+
+ ~ContainerURLRequestContext() override {
+ // Shut down the ProxyService, as it may have pending URLRequests using this
+ // context.
+ proxy_service()->OnShutdown();
+
+ AssertNoURLRequests();
+ }
URLRequestContextStorage* storage() {
return &storage_;
@@ -329,22 +336,6 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
}
storage->set_host_resolver(std::move(host_resolver_));
- if (!proxy_service_) {
- // TODO(willchan): Switch to using this code when
- // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
-#if !defined(OS_LINUX) && !defined(OS_ANDROID)
- if (!proxy_config_service_) {
- proxy_config_service_ = ProxyService::CreateSystemProxyConfigService(
- base::ThreadTaskRunnerHandle::Get().get(),
- context->GetFileTaskRunner());
- }
-#endif // !defined(OS_LINUX) && !defined(OS_ANDROID)
- proxy_service_ = ProxyService::CreateUsingSystemProxyResolver(
- std::move(proxy_config_service_),
- context->net_log());
- }
- storage->set_proxy_service(std::move(proxy_service_));
-
storage->set_ssl_config_service(new SSLConfigServiceDefaults);
if (!http_auth_handler_factory_) {
@@ -411,6 +402,23 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
base::MakeUnique<URLRequestThrottlerManager>());
}
+ if (!proxy_service_) {
+#if !defined(OS_LINUX) && !defined(OS_ANDROID)
+ // TODO(willchan): Switch to using this code when
+ // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
+ if (!proxy_config_service_) {
+ proxy_config_service_ = ProxyService::CreateSystemProxyConfigService(
+ base::ThreadTaskRunnerHandle::Get().get(),
+ context->GetFileTaskRunner());
+ }
+#endif // !defined(OS_LINUX) && !defined(OS_ANDROID)
+ proxy_service_ =
+ CreateProxyService(std::move(proxy_config_service_), context.get(),
+ context->host_resolver(),
+ context->network_delegate(), context->net_log());
+ }
+ storage->set_proxy_service(std::move(proxy_service_));
+
HttpNetworkSession::Params network_session_params;
SetHttpNetworkSessionComponents(context.get(), &network_session_params);
@@ -524,4 +532,14 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
return std::move(context);
}
+std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService(
+ std::unique_ptr<ProxyConfigService> proxy_config_service,
+ URLRequestContext* url_request_context,
+ HostResolver* host_resolver,
+ NetworkDelegate* network_delegate,
+ NetLog* net_log) {
+ return ProxyService::CreateUsingSystemProxyResolver(
+ std::move(proxy_config_service), net_log);
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698