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

Unified Diff: net/url_request/url_request_context_builder.cc

Issue 2881613002: Allow use of Mojo/V8 ProxyResolvers with URLRequestContextBuilder. (Closed)
Patch Set: Merge 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 40e842dca12717b8dc5a0b8b994866eb6230d33e..cd43ff03a8e773775bdcfbb47d8cdfe8d12802cf 100644
--- a/net/url_request/url_request_context_builder.cc
+++ b/net/url_request/url_request_context_builder.cc
@@ -139,7 +139,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();
eroman 2017/05/16 20:21:20 If this is the destructor for URLRequestContext, i
mmenke 2017/05/17 02:29:58 This is the destructor of the child class, and it
+
+ AssertNoURLRequests();
+ }
URLRequestContextStorage* storage() {
return &storage_;
@@ -358,22 +365,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_) {
@@ -440,6 +431,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);
http_network_session_params_.ConfigureSessionParams(&network_session_params);
@@ -525,4 +533,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