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

Side by Side Diff: net/url_request/url_request_context_builder.cc

Issue 2881613002: Allow use of Mojo/V8 ProxyResolvers with URLRequestContextBuilder. (Closed)
Patch Set: Missed some ENABLE_MOJOs 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_context_builder.h" 5 #include "net/url_request/url_request_context_builder.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 bool OnCanAccessFile(const URLRequest& request, 127 bool OnCanAccessFile(const URLRequest& request,
128 const base::FilePath& path) const override { 128 const base::FilePath& path) const override {
129 return true; 129 return true;
130 } 130 }
131 131
132 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate); 132 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate);
133 }; 133 };
134 134
135 // Define a context class that can self-manage the ownership of its components 135 // Define a context class that can self-manage the ownership of its components
136 // via a UrlRequestContextStorage object. 136 // via a UrlRequestContextStorage object. Since it cancels requests in its
137 class ContainerURLRequestContext : public URLRequestContext { 137 // destructor, it's not safe to subclass this.
138 class ContainerURLRequestContext final : public URLRequestContext {
138 public: 139 public:
139 explicit ContainerURLRequestContext( 140 explicit ContainerURLRequestContext(
140 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) 141 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner)
141 : file_task_runner_(file_task_runner), storage_(this) {} 142 : file_task_runner_(file_task_runner), storage_(this) {}
142 ~ContainerURLRequestContext() override { AssertNoURLRequests(); } 143
144 ~ContainerURLRequestContext() override {
145 // Shut down the ProxyService, as it may have pending URLRequests using this
146 // context. Since this cancels requests, it's not safe to subclass this, as
147 // some parts of the URLRequestContext may then be torn down before this
148 // cancels the ProxyService's URLRequests.
149 proxy_service()->OnShutdown();
150
151 AssertNoURLRequests();
152 }
143 153
144 URLRequestContextStorage* storage() { 154 URLRequestContextStorage* storage() {
145 return &storage_; 155 return &storage_;
146 } 156 }
147 157
148 scoped_refptr<base::SingleThreadTaskRunner>& GetFileTaskRunner() { 158 scoped_refptr<base::SingleThreadTaskRunner>& GetFileTaskRunner() {
149 // Create a new thread to run file tasks, if needed. 159 // Create a new thread to run file tasks, if needed.
150 if (!file_task_runner_) { 160 if (!file_task_runner_) {
151 DCHECK(!file_thread_); 161 DCHECK(!file_thread_);
152 file_thread_.reset(new base::Thread("Network File Thread")); 162 file_thread_.reset(new base::Thread("Network File Thread"));
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 context->set_net_log(net_log_); 361 context->set_net_log(net_log_);
352 } else { 362 } else {
353 storage->set_net_log(base::WrapUnique(new NetLog)); 363 storage->set_net_log(base::WrapUnique(new NetLog));
354 } 364 }
355 365
356 if (!host_resolver_) { 366 if (!host_resolver_) {
357 host_resolver_ = HostResolver::CreateDefaultResolver(context->net_log()); 367 host_resolver_ = HostResolver::CreateDefaultResolver(context->net_log());
358 } 368 }
359 storage->set_host_resolver(std::move(host_resolver_)); 369 storage->set_host_resolver(std::move(host_resolver_));
360 370
361 if (!proxy_service_) {
362 // TODO(willchan): Switch to using this code when
363 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
364 #if !defined(OS_LINUX) && !defined(OS_ANDROID)
365 if (!proxy_config_service_) {
366 proxy_config_service_ = ProxyService::CreateSystemProxyConfigService(
367 base::ThreadTaskRunnerHandle::Get().get(),
368 context->GetFileTaskRunner());
369 }
370 #endif // !defined(OS_LINUX) && !defined(OS_ANDROID)
371 proxy_service_ = ProxyService::CreateUsingSystemProxyResolver(
372 std::move(proxy_config_service_),
373 context->net_log());
374 }
375 storage->set_proxy_service(std::move(proxy_service_));
376
377 storage->set_ssl_config_service(new SSLConfigServiceDefaults); 371 storage->set_ssl_config_service(new SSLConfigServiceDefaults);
378 372
379 if (!http_auth_handler_factory_) { 373 if (!http_auth_handler_factory_) {
380 http_auth_handler_factory_ = 374 http_auth_handler_factory_ =
381 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver()); 375 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver());
382 } 376 }
383 377
384 storage->set_http_auth_handler_factory(std::move(http_auth_handler_factory_)); 378 storage->set_http_auth_handler_factory(std::move(http_auth_handler_factory_));
385 379
386 if (cookie_store_set_by_client_) { 380 if (cookie_store_set_by_client_) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 ct_verifier->AddLogs(ct::CreateLogVerifiersForKnownLogs()); 427 ct_verifier->AddLogs(ct::CreateLogVerifiersForKnownLogs());
434 storage->set_cert_transparency_verifier(std::move(ct_verifier)); 428 storage->set_cert_transparency_verifier(std::move(ct_verifier));
435 } 429 }
436 storage->set_ct_policy_enforcer(base::MakeUnique<CTPolicyEnforcer>()); 430 storage->set_ct_policy_enforcer(base::MakeUnique<CTPolicyEnforcer>());
437 431
438 if (throttling_enabled_) { 432 if (throttling_enabled_) {
439 storage->set_throttler_manager( 433 storage->set_throttler_manager(
440 base::MakeUnique<URLRequestThrottlerManager>()); 434 base::MakeUnique<URLRequestThrottlerManager>());
441 } 435 }
442 436
437 if (!proxy_service_) {
438 #if !defined(OS_LINUX) && !defined(OS_ANDROID)
439 // TODO(willchan): Switch to using this code when
440 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
441 if (!proxy_config_service_) {
442 proxy_config_service_ = ProxyService::CreateSystemProxyConfigService(
443 base::ThreadTaskRunnerHandle::Get().get(),
444 context->GetFileTaskRunner());
445 }
446 #endif // !defined(OS_LINUX) && !defined(OS_ANDROID)
447 proxy_service_ =
448 CreateProxyService(std::move(proxy_config_service_), context.get(),
449 context->host_resolver(),
450 context->network_delegate(), context->net_log());
451 }
452 storage->set_proxy_service(std::move(proxy_service_));
453
443 HttpNetworkSession::Params network_session_params; 454 HttpNetworkSession::Params network_session_params;
444 SetHttpNetworkSessionComponents(context.get(), &network_session_params); 455 SetHttpNetworkSessionComponents(context.get(), &network_session_params);
445 http_network_session_params_.ConfigureSessionParams(&network_session_params); 456 http_network_session_params_.ConfigureSessionParams(&network_session_params);
446 457
447 if (proxy_delegate_) { 458 if (proxy_delegate_) {
448 network_session_params.proxy_delegate = proxy_delegate_.get(); 459 network_session_params.proxy_delegate = proxy_delegate_.get();
449 storage->set_proxy_delegate(std::move(proxy_delegate_)); 460 storage->set_proxy_delegate(std::move(proxy_delegate_));
450 } 461 }
451 if (socket_performance_watcher_factory_) { 462 if (socket_performance_watcher_factory_) {
452 network_session_params.socket_performance_watcher_factory = 463 network_session_params.socket_performance_watcher_factory =
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 std::move(top_job_factory), std::move(*i))); 529 std::move(top_job_factory), std::move(*i)));
519 } 530 }
520 url_request_interceptors_.clear(); 531 url_request_interceptors_.clear();
521 } 532 }
522 storage->set_job_factory(std::move(top_job_factory)); 533 storage->set_job_factory(std::move(top_job_factory));
523 // TODO(willchan): Support sdch. 534 // TODO(willchan): Support sdch.
524 535
525 return std::move(context); 536 return std::move(context);
526 } 537 }
527 538
539 std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService(
540 std::unique_ptr<ProxyConfigService> proxy_config_service,
541 URLRequestContext* url_request_context,
542 HostResolver* host_resolver,
543 NetworkDelegate* network_delegate,
544 NetLog* net_log) {
545 return ProxyService::CreateUsingSystemProxyResolver(
546 std::move(proxy_config_service), net_log);
547 }
548
528 } // namespace net 549 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_context_builder.h ('k') | net/url_request/url_request_context_builder_v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698