OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/ios_chrome_io_thread.h" | 5 #include "ios/chrome/browser/ios_chrome_io_thread.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
27 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
29 #include "base/trace_event/trace_event.h" | 29 #include "base/trace_event/trace_event.h" |
30 #include "components/net_log/chrome_net_log.h" | 30 #include "components/net_log/chrome_net_log.h" |
31 #include "components/network_session_configurator/network_session_configurator.h
" | 31 #include "components/network_session_configurator/network_session_configurator.h
" |
32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
| 33 #include "components/proxy_config/ios/proxy_service_factory.h" |
33 #include "components/proxy_config/pref_proxy_config_tracker.h" | 34 #include "components/proxy_config/pref_proxy_config_tracker.h" |
34 #include "components/variations/variations_associated_data.h" | 35 #include "components/variations/variations_associated_data.h" |
35 #include "components/version_info/version_info.h" | 36 #include "components/version_info/version_info.h" |
36 #include "ios/chrome/browser/chrome_switches.h" | 37 #include "ios/chrome/browser/chrome_switches.h" |
37 #include "ios/chrome/browser/net/cookie_util.h" | 38 #include "ios/chrome/browser/net/cookie_util.h" |
38 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h" | 39 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h" |
39 #include "ios/chrome/browser/net/proxy_service_factory.h" | |
40 #include "ios/chrome/common/channel_info.h" | 40 #include "ios/chrome/common/channel_info.h" |
41 #include "ios/web/public/user_agent.h" | 41 #include "ios/web/public/user_agent.h" |
42 #include "ios/web/public/web_client.h" | 42 #include "ios/web/public/web_client.h" |
43 #include "ios/web/public/web_thread.h" | 43 #include "ios/web/public/web_thread.h" |
44 #include "net/base/sdch_manager.h" | 44 #include "net/base/sdch_manager.h" |
45 #include "net/cert/cert_verifier.h" | 45 #include "net/cert/cert_verifier.h" |
46 #include "net/cert/ct_known_logs.h" | 46 #include "net/cert/ct_known_logs.h" |
47 #include "net/cert/ct_log_verifier.h" | 47 #include "net/cert/ct_log_verifier.h" |
48 #include "net/cert/ct_policy_enforcer.h" | 48 #include "net/cert/ct_policy_enforcer.h" |
49 #include "net/cert/ct_verifier.h" | 49 #include "net/cert/ct_verifier.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 // |local_state| is passed in explicitly in order to (1) reduce implicit | 271 // |local_state| is passed in explicitly in order to (1) reduce implicit |
272 // dependencies and (2) make IOSChromeIOThread more flexible for testing. | 272 // dependencies and (2) make IOSChromeIOThread more flexible for testing. |
273 IOSChromeIOThread::IOSChromeIOThread(PrefService* local_state, | 273 IOSChromeIOThread::IOSChromeIOThread(PrefService* local_state, |
274 net_log::ChromeNetLog* net_log) | 274 net_log::ChromeNetLog* net_log) |
275 : net_log_(net_log), | 275 : net_log_(net_log), |
276 globals_(nullptr), | 276 globals_(nullptr), |
277 creation_time_(base::TimeTicks::Now()), | 277 creation_time_(base::TimeTicks::Now()), |
278 weak_factory_(this) { | 278 weak_factory_(this) { |
279 pref_proxy_config_tracker_ = | 279 pref_proxy_config_tracker_ = |
280 ios::ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 280 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
281 local_state); | 281 local_state); |
282 IOSChromeNetworkDelegate::InitializePrefsOnUIThread(nullptr, local_state); | 282 IOSChromeNetworkDelegate::InitializePrefsOnUIThread(nullptr, local_state); |
283 ssl_config_service_manager_.reset( | 283 ssl_config_service_manager_.reset( |
284 ssl_config::SSLConfigServiceManager::CreateDefaultManager( | 284 ssl_config::SSLConfigServiceManager::CreateDefaultManager( |
285 local_state, | 285 local_state, |
286 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO))); | 286 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO))); |
287 | 287 |
288 web::WebThread::SetDelegate(web::WebThread::IO, this); | 288 web::WebThread::SetDelegate(web::WebThread::IO, this); |
289 } | 289 } |
290 | 290 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // in about:net-internals. | 491 // in about:net-internals. |
492 ClearHostCache(); | 492 ClearHostCache(); |
493 } | 493 } |
494 | 494 |
495 void IOSChromeIOThread::InitSystemRequestContext() { | 495 void IOSChromeIOThread::InitSystemRequestContext() { |
496 if (system_url_request_context_getter_.get()) | 496 if (system_url_request_context_getter_.get()) |
497 return; | 497 return; |
498 // If we're in unit_tests, IOSChromeIOThread may not be run. | 498 // If we're in unit_tests, IOSChromeIOThread may not be run. |
499 if (!web::WebThread::IsMessageLoopValid(web::WebThread::IO)) | 499 if (!web::WebThread::IsMessageLoopValid(web::WebThread::IO)) |
500 return; | 500 return; |
501 system_proxy_config_service_ = | 501 system_proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService( |
502 ios::ProxyServiceFactory::CreateProxyConfigService( | 502 pref_proxy_config_tracker_.get()); |
503 pref_proxy_config_tracker_.get()); | |
504 | 503 |
505 system_url_request_context_getter_ = new SystemURLRequestContextGetter(this); | 504 system_url_request_context_getter_ = new SystemURLRequestContextGetter(this); |
506 // Safe to post an unretained this pointer, since IOSChromeIOThread is | 505 // Safe to post an unretained this pointer, since IOSChromeIOThread is |
507 // guaranteed to outlive the IO WebThread. | 506 // guaranteed to outlive the IO WebThread. |
508 web::WebThread::PostTask( | 507 web::WebThread::PostTask( |
509 web::WebThread::IO, FROM_HERE, | 508 web::WebThread::IO, FROM_HERE, |
510 base::Bind(&IOSChromeIOThread::InitSystemRequestContextOnIOThread, | 509 base::Bind(&IOSChromeIOThread::InitSystemRequestContextOnIOThread, |
511 base::Unretained(this))); | 510 base::Unretained(this))); |
512 } | 511 } |
513 | 512 |
514 void IOSChromeIOThread::InitSystemRequestContextOnIOThread() { | 513 void IOSChromeIOThread::InitSystemRequestContextOnIOThread() { |
515 DCHECK_CURRENTLY_ON(web::WebThread::IO); | 514 DCHECK_CURRENTLY_ON(web::WebThread::IO); |
516 DCHECK(!globals_->system_proxy_service.get()); | 515 DCHECK(!globals_->system_proxy_service.get()); |
517 DCHECK(system_proxy_config_service_.get()); | 516 DCHECK(system_proxy_config_service_.get()); |
518 | 517 |
519 globals_->system_proxy_service = ios::ProxyServiceFactory::CreateProxyService( | 518 globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService( |
520 net_log_, nullptr, globals_->system_network_delegate.get(), | 519 net_log_, nullptr, globals_->system_network_delegate.get(), |
521 std::move(system_proxy_config_service_), true /* quick_check_enabled */); | 520 std::move(system_proxy_config_service_), true /* quick_check_enabled */); |
522 | 521 |
523 globals_->system_request_context.reset( | 522 globals_->system_request_context.reset( |
524 ConstructSystemRequestContext(globals_, params_, net_log_)); | 523 ConstructSystemRequestContext(globals_, params_, net_log_)); |
525 } | 524 } |
526 | 525 |
527 net::URLRequestContext* IOSChromeIOThread::ConstructSystemRequestContext( | 526 net::URLRequestContext* IOSChromeIOThread::ConstructSystemRequestContext( |
528 IOSChromeIOThread::Globals* globals, | 527 IOSChromeIOThread::Globals* globals, |
529 const net::HttpNetworkSession::Params& params, | 528 const net::HttpNetworkSession::Params& params, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 567 |
569 globals->system_http_network_session.reset( | 568 globals->system_http_network_session.reset( |
570 new net::HttpNetworkSession(system_params)); | 569 new net::HttpNetworkSession(system_params)); |
571 globals->system_http_transaction_factory.reset( | 570 globals->system_http_transaction_factory.reset( |
572 new net::HttpNetworkLayer(globals->system_http_network_session.get())); | 571 new net::HttpNetworkLayer(globals->system_http_network_session.get())); |
573 context->set_http_transaction_factory( | 572 context->set_http_transaction_factory( |
574 globals->system_http_transaction_factory.get()); | 573 globals->system_http_transaction_factory.get()); |
575 | 574 |
576 return context; | 575 return context; |
577 } | 576 } |
OLD | NEW |