| 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 <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/bind.h" | 12 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 15 #include "base/debug/leak_tracker.h" | 16 #include "base/debug/leak_tracker.h" |
| 16 #include "base/environment.h" | 17 #include "base/environment.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 *base::CommandLine::ForCurrentProcess(); | 142 *base::CommandLine::ForCurrentProcess(); |
| 142 | 143 |
| 143 scoped_ptr<net::HostResolver> global_host_resolver = | 144 scoped_ptr<net::HostResolver> global_host_resolver = |
| 144 net::HostResolver::CreateSystemResolver(net::HostResolver::Options(), | 145 net::HostResolver::CreateSystemResolver(net::HostResolver::Options(), |
| 145 net_log); | 146 net_log); |
| 146 | 147 |
| 147 // If hostname remappings were specified on the command-line, layer these | 148 // If hostname remappings were specified on the command-line, layer these |
| 148 // rules on top of the real host resolver. This allows forwarding all requests | 149 // rules on top of the real host resolver. This allows forwarding all requests |
| 149 // through a designated test server. | 150 // through a designated test server. |
| 150 if (!command_line.HasSwitch(switches::kIOSHostResolverRules)) | 151 if (!command_line.HasSwitch(switches::kIOSHostResolverRules)) |
| 151 return global_host_resolver.Pass(); | 152 return global_host_resolver; |
| 152 | 153 |
| 153 scoped_ptr<net::MappedHostResolver> remapped_resolver( | 154 scoped_ptr<net::MappedHostResolver> remapped_resolver( |
| 154 new net::MappedHostResolver(global_host_resolver.Pass())); | 155 new net::MappedHostResolver(std::move(global_host_resolver))); |
| 155 remapped_resolver->SetRulesFromString( | 156 remapped_resolver->SetRulesFromString( |
| 156 command_line.GetSwitchValueASCII(switches::kIOSHostResolverRules)); | 157 command_line.GetSwitchValueASCII(switches::kIOSHostResolverRules)); |
| 157 return remapped_resolver.Pass(); | 158 return std::move(remapped_resolver); |
| 158 } | 159 } |
| 159 | 160 |
| 160 int GetSwitchValueAsInt(const base::CommandLine& command_line, | 161 int GetSwitchValueAsInt(const base::CommandLine& command_line, |
| 161 const std::string& switch_name) { | 162 const std::string& switch_name) { |
| 162 int value; | 163 int value; |
| 163 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), | 164 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), |
| 164 &value)) { | 165 &value)) { |
| 165 return 0; | 166 return 0; |
| 166 } | 167 } |
| 167 return value; | 168 return value; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be | 376 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
| 376 // logging the network change before other IO thread consumers respond to it. | 377 // logging the network change before other IO thread consumers respond to it. |
| 377 network_change_observer_.reset(new LoggingNetworkChangeObserver(net_log_)); | 378 network_change_observer_.reset(new LoggingNetworkChangeObserver(net_log_)); |
| 378 | 379 |
| 379 // Setup the HistogramWatcher to run on the IO thread. | 380 // Setup the HistogramWatcher to run on the IO thread. |
| 380 net::NetworkChangeNotifier::InitHistogramWatcher(); | 381 net::NetworkChangeNotifier::InitHistogramWatcher(); |
| 381 | 382 |
| 382 scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate( | 383 scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate( |
| 383 new IOSChromeNetworkDelegate()); | 384 new IOSChromeNetworkDelegate()); |
| 384 | 385 |
| 385 globals_->system_network_delegate = chrome_network_delegate.Pass(); | 386 globals_->system_network_delegate = std::move(chrome_network_delegate); |
| 386 globals_->host_resolver = CreateGlobalHostResolver(net_log_); | 387 globals_->host_resolver = CreateGlobalHostResolver(net_log_); |
| 387 | 388 |
| 388 std::map<std::string, std::string> network_quality_estimator_params; | 389 std::map<std::string, std::string> network_quality_estimator_params; |
| 389 variations::GetVariationParams(kNetworkQualityEstimatorFieldTrialName, | 390 variations::GetVariationParams(kNetworkQualityEstimatorFieldTrialName, |
| 390 &network_quality_estimator_params); | 391 &network_quality_estimator_params); |
| 391 | 392 |
| 392 scoped_ptr<net::ExternalEstimateProvider> external_estimate_provider; | 393 scoped_ptr<net::ExternalEstimateProvider> external_estimate_provider; |
| 393 // Pass ownership. | 394 // Pass ownership. |
| 394 globals_->network_quality_estimator.reset(new net::NetworkQualityEstimator( | 395 globals_->network_quality_estimator.reset(new net::NetworkQualityEstimator( |
| 395 external_estimate_provider.Pass(), network_quality_estimator_params)); | 396 std::move(external_estimate_provider), network_quality_estimator_params)); |
| 396 | 397 |
| 397 globals_->cert_verifier.reset( | 398 globals_->cert_verifier.reset( |
| 398 new net::MultiThreadedCertVerifier(net::CertVerifyProc::CreateDefault())); | 399 new net::MultiThreadedCertVerifier(net::CertVerifyProc::CreateDefault())); |
| 399 | 400 |
| 400 globals_->transport_security_state.reset(new net::TransportSecurityState()); | 401 globals_->transport_security_state.reset(new net::TransportSecurityState()); |
| 401 | 402 |
| 402 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( | 403 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( |
| 403 net::ct::CreateLogVerifiersForKnownLogs()); | 404 net::ct::CreateLogVerifiersForKnownLogs()); |
| 404 | 405 |
| 405 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); | 406 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 } | 568 } |
| 568 | 569 |
| 569 void IOSChromeIOThread::CreateDefaultAuthHandlerFactory() { | 570 void IOSChromeIOThread::CreateDefaultAuthHandlerFactory() { |
| 570 std::vector<std::string> supported_schemes = | 571 std::vector<std::string> supported_schemes = |
| 571 base::SplitString(kSupportedAuthSchemes, ",", base::TRIM_WHITESPACE, | 572 base::SplitString(kSupportedAuthSchemes, ",", base::TRIM_WHITESPACE, |
| 572 base::SPLIT_WANT_NONEMPTY); | 573 base::SPLIT_WANT_NONEMPTY); |
| 573 globals_->http_auth_preferences.reset( | 574 globals_->http_auth_preferences.reset( |
| 574 new net::HttpAuthPreferences(supported_schemes, std::string())); | 575 new net::HttpAuthPreferences(supported_schemes, std::string())); |
| 575 globals_->http_auth_handler_factory = | 576 globals_->http_auth_handler_factory = |
| 576 net::HttpAuthHandlerRegistryFactory::Create( | 577 net::HttpAuthHandlerRegistryFactory::Create( |
| 577 globals_->http_auth_preferences.get(), globals_->host_resolver.get()) | 578 globals_->http_auth_preferences.get(), globals_->host_resolver.get()); |
| 578 .Pass(); | |
| 579 } | 579 } |
| 580 | 580 |
| 581 void IOSChromeIOThread::ClearHostCache() { | 581 void IOSChromeIOThread::ClearHostCache() { |
| 582 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO); | 582 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO); |
| 583 | 583 |
| 584 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 584 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 585 if (host_cache) | 585 if (host_cache) |
| 586 host_cache->clear(); | 586 host_cache->clear(); |
| 587 } | 587 } |
| 588 | 588 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 base::Unretained(this))); | 685 base::Unretained(this))); |
| 686 } | 686 } |
| 687 | 687 |
| 688 void IOSChromeIOThread::InitSystemRequestContextOnIOThread() { | 688 void IOSChromeIOThread::InitSystemRequestContextOnIOThread() { |
| 689 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO); | 689 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO); |
| 690 DCHECK(!globals_->system_proxy_service.get()); | 690 DCHECK(!globals_->system_proxy_service.get()); |
| 691 DCHECK(system_proxy_config_service_.get()); | 691 DCHECK(system_proxy_config_service_.get()); |
| 692 | 692 |
| 693 globals_->system_proxy_service = ios::ProxyServiceFactory::CreateProxyService( | 693 globals_->system_proxy_service = ios::ProxyServiceFactory::CreateProxyService( |
| 694 net_log_, nullptr, globals_->system_network_delegate.get(), | 694 net_log_, nullptr, globals_->system_network_delegate.get(), |
| 695 system_proxy_config_service_.Pass(), true /* quick_check_enabled */); | 695 std::move(system_proxy_config_service_), true /* quick_check_enabled */); |
| 696 | 696 |
| 697 globals_->system_request_context.reset( | 697 globals_->system_request_context.reset( |
| 698 ConstructSystemRequestContext(globals_, net_log_)); | 698 ConstructSystemRequestContext(globals_, net_log_)); |
| 699 } | 699 } |
| 700 | 700 |
| 701 void IOSChromeIOThread::ConfigureQuic() { | 701 void IOSChromeIOThread::ConfigureQuic() { |
| 702 // Always fetch the field trial group to ensure it is reported correctly. | 702 // Always fetch the field trial group to ensure it is reported correctly. |
| 703 // The command line flags will be associated with a group that is reported | 703 // The command line flags will be associated with a group that is reported |
| 704 // so long as trial is actually queried. | 704 // so long as trial is actually queried. |
| 705 std::string group = base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 705 std::string group = base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 | 1010 |
| 1011 globals->system_http_network_session.reset( | 1011 globals->system_http_network_session.reset( |
| 1012 new net::HttpNetworkSession(system_params)); | 1012 new net::HttpNetworkSession(system_params)); |
| 1013 globals->system_http_transaction_factory.reset( | 1013 globals->system_http_transaction_factory.reset( |
| 1014 new net::HttpNetworkLayer(globals->system_http_network_session.get())); | 1014 new net::HttpNetworkLayer(globals->system_http_network_session.get())); |
| 1015 context->set_http_transaction_factory( | 1015 context->set_http_transaction_factory( |
| 1016 globals->system_http_transaction_factory.get()); | 1016 globals->system_http_transaction_factory.get()); |
| 1017 | 1017 |
| 1018 return context; | 1018 return context; |
| 1019 } | 1019 } |
| OLD | NEW |