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

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

Issue 2888043008: Revert of Allow use of Mojo/V8 ProxyResolvers with URLRequestContextBuilder. (Closed)
Patch Set: 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. Since it cancels requests in its 136 // via a UrlRequestContextStorage object.
137 // destructor, it's not safe to subclass this. 137 class ContainerURLRequestContext : public URLRequestContext {
138 class ContainerURLRequestContext final : public URLRequestContext {
139 public: 138 public:
140 explicit ContainerURLRequestContext( 139 explicit ContainerURLRequestContext(
141 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) 140 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner)
142 : file_task_runner_(file_task_runner), storage_(this) {} 141 : file_task_runner_(file_task_runner), storage_(this) {}
143 142 ~ContainerURLRequestContext() override { AssertNoURLRequests(); }
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 }
153 143
154 URLRequestContextStorage* storage() { 144 URLRequestContextStorage* storage() {
155 return &storage_; 145 return &storage_;
156 } 146 }
157 147
158 scoped_refptr<base::SingleThreadTaskRunner>& GetFileTaskRunner() { 148 scoped_refptr<base::SingleThreadTaskRunner>& GetFileTaskRunner() {
159 // Create a new thread to run file tasks, if needed. 149 // Create a new thread to run file tasks, if needed.
160 if (!file_task_runner_) { 150 if (!file_task_runner_) {
161 DCHECK(!file_thread_); 151 DCHECK(!file_thread_);
162 file_thread_.reset(new base::Thread("Network File Thread")); 152 file_thread_.reset(new base::Thread("Network File Thread"));
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 context->set_net_log(net_log_); 351 context->set_net_log(net_log_);
362 } else { 352 } else {
363 storage->set_net_log(base::WrapUnique(new NetLog)); 353 storage->set_net_log(base::WrapUnique(new NetLog));
364 } 354 }
365 355
366 if (!host_resolver_) { 356 if (!host_resolver_) {
367 host_resolver_ = HostResolver::CreateDefaultResolver(context->net_log()); 357 host_resolver_ = HostResolver::CreateDefaultResolver(context->net_log());
368 } 358 }
369 storage->set_host_resolver(std::move(host_resolver_)); 359 storage->set_host_resolver(std::move(host_resolver_));
370 360
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
371 storage->set_ssl_config_service(new SSLConfigServiceDefaults); 377 storage->set_ssl_config_service(new SSLConfigServiceDefaults);
372 378
373 if (!http_auth_handler_factory_) { 379 if (!http_auth_handler_factory_) {
374 http_auth_handler_factory_ = 380 http_auth_handler_factory_ =
375 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver()); 381 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver());
376 } 382 }
377 383
378 storage->set_http_auth_handler_factory(std::move(http_auth_handler_factory_)); 384 storage->set_http_auth_handler_factory(std::move(http_auth_handler_factory_));
379 385
380 if (cookie_store_set_by_client_) { 386 if (cookie_store_set_by_client_) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 ct_verifier->AddLogs(ct::CreateLogVerifiersForKnownLogs()); 433 ct_verifier->AddLogs(ct::CreateLogVerifiersForKnownLogs());
428 storage->set_cert_transparency_verifier(std::move(ct_verifier)); 434 storage->set_cert_transparency_verifier(std::move(ct_verifier));
429 } 435 }
430 storage->set_ct_policy_enforcer(base::MakeUnique<CTPolicyEnforcer>()); 436 storage->set_ct_policy_enforcer(base::MakeUnique<CTPolicyEnforcer>());
431 437
432 if (throttling_enabled_) { 438 if (throttling_enabled_) {
433 storage->set_throttler_manager( 439 storage->set_throttler_manager(
434 base::MakeUnique<URLRequestThrottlerManager>()); 440 base::MakeUnique<URLRequestThrottlerManager>());
435 } 441 }
436 442
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
454 HttpNetworkSession::Params network_session_params; 443 HttpNetworkSession::Params network_session_params;
455 SetHttpNetworkSessionComponents(context.get(), &network_session_params); 444 SetHttpNetworkSessionComponents(context.get(), &network_session_params);
456 http_network_session_params_.ConfigureSessionParams(&network_session_params); 445 http_network_session_params_.ConfigureSessionParams(&network_session_params);
457 446
458 if (proxy_delegate_) { 447 if (proxy_delegate_) {
459 network_session_params.proxy_delegate = proxy_delegate_.get(); 448 network_session_params.proxy_delegate = proxy_delegate_.get();
460 storage->set_proxy_delegate(std::move(proxy_delegate_)); 449 storage->set_proxy_delegate(std::move(proxy_delegate_));
461 } 450 }
462 if (socket_performance_watcher_factory_) { 451 if (socket_performance_watcher_factory_) {
463 network_session_params.socket_performance_watcher_factory = 452 network_session_params.socket_performance_watcher_factory =
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 std::move(top_job_factory), std::move(*i))); 518 std::move(top_job_factory), std::move(*i)));
530 } 519 }
531 url_request_interceptors_.clear(); 520 url_request_interceptors_.clear();
532 } 521 }
533 storage->set_job_factory(std::move(top_job_factory)); 522 storage->set_job_factory(std::move(top_job_factory));
534 // TODO(willchan): Support sdch. 523 // TODO(willchan): Support sdch.
535 524
536 return std::move(context); 525 return std::move(context);
537 } 526 }
538 527
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
549 } // namespace net 528 } // 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