| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/debug/leak_tracker.h" | 16 #include "base/debug/leak_tracker.h" |
| 17 #include "base/environment.h" | 17 #include "base/environment.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 21 #include "base/metrics/field_trial.h" | 21 #include "base/metrics/field_trial.h" |
| 22 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_piece.h" | |
| 25 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
| 26 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 27 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
| 28 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
| 29 #include "base/threading/worker_pool.h" | 28 #include "base/threading/worker_pool.h" |
| 30 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 31 #include "base/trace_event/trace_event.h" | 30 #include "base/trace_event/trace_event.h" |
| 32 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 31 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 33 #include "components/net_log/chrome_net_log.h" | 32 #include "components/net_log/chrome_net_log.h" |
| 33 #include "components/network_session_configurator/network_session_configurator.h
" |
| 34 #include "components/prefs/pref_service.h" | 34 #include "components/prefs/pref_service.h" |
| 35 #include "components/proxy_config/pref_proxy_config_tracker.h" | 35 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 36 #include "components/variations/variations_associated_data.h" | 36 #include "components/variations/variations_associated_data.h" |
| 37 #include "components/version_info/version_info.h" | 37 #include "components/version_info/version_info.h" |
| 38 #include "ios/chrome/browser/chrome_switches.h" | 38 #include "ios/chrome/browser/chrome_switches.h" |
| 39 #include "ios/chrome/browser/net/cookie_util.h" | 39 #include "ios/chrome/browser/net/cookie_util.h" |
| 40 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h" | 40 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h" |
| 41 #include "ios/chrome/browser/net/proxy_service_factory.h" | 41 #include "ios/chrome/browser/net/proxy_service_factory.h" |
| 42 #include "ios/chrome/common/channel_info.h" | 42 #include "ios/chrome/common/channel_info.h" |
| 43 #include "ios/web/public/user_agent.h" | 43 #include "ios/web/public/user_agent.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 57 #include "net/cert_net/nss_ocsp.h" | 57 #include "net/cert_net/nss_ocsp.h" |
| 58 #include "net/cookies/cookie_monster.h" | 58 #include "net/cookies/cookie_monster.h" |
| 59 #include "net/cookies/cookie_store.h" | 59 #include "net/cookies/cookie_store.h" |
| 60 #include "net/dns/host_cache.h" | 60 #include "net/dns/host_cache.h" |
| 61 #include "net/dns/host_resolver.h" | 61 #include "net/dns/host_resolver.h" |
| 62 #include "net/dns/mapped_host_resolver.h" | 62 #include "net/dns/mapped_host_resolver.h" |
| 63 #include "net/http/http_auth_filter.h" | 63 #include "net/http/http_auth_filter.h" |
| 64 #include "net/http/http_auth_handler_factory.h" | 64 #include "net/http/http_auth_handler_factory.h" |
| 65 #include "net/http/http_auth_preferences.h" | 65 #include "net/http/http_auth_preferences.h" |
| 66 #include "net/http/http_network_layer.h" | 66 #include "net/http/http_network_layer.h" |
| 67 #include "net/http/http_network_session.h" | |
| 68 #include "net/http/http_server_properties_impl.h" | 67 #include "net/http/http_server_properties_impl.h" |
| 69 #include "net/proxy/proxy_config_service.h" | 68 #include "net/proxy/proxy_config_service.h" |
| 70 #include "net/proxy/proxy_script_fetcher_impl.h" | 69 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 71 #include "net/proxy/proxy_service.h" | 70 #include "net/proxy/proxy_service.h" |
| 72 #include "net/quic/crypto/crypto_protocol.h" | |
| 73 #include "net/quic/quic_protocol.h" | |
| 74 #include "net/quic/quic_utils.h" | |
| 75 #include "net/socket/tcp_client_socket.h" | 71 #include "net/socket/tcp_client_socket.h" |
| 76 #include "net/spdy/spdy_session.h" | 72 #include "net/spdy/spdy_session.h" |
| 77 #include "net/ssl/channel_id_service.h" | 73 #include "net/ssl/channel_id_service.h" |
| 78 #include "net/ssl/default_channel_id_store.h" | 74 #include "net/ssl/default_channel_id_store.h" |
| 79 #include "net/url_request/data_protocol_handler.h" | 75 #include "net/url_request/data_protocol_handler.h" |
| 80 #include "net/url_request/file_protocol_handler.h" | 76 #include "net/url_request/file_protocol_handler.h" |
| 81 #include "net/url_request/static_http_user_agent_settings.h" | 77 #include "net/url_request/static_http_user_agent_settings.h" |
| 82 #include "net/url_request/url_request_backoff_manager.h" | 78 #include "net/url_request/url_request_backoff_manager.h" |
| 83 #include "net/url_request/url_request_context.h" | 79 #include "net/url_request/url_request_context.h" |
| 84 #include "net/url_request/url_request_context_builder.h" | 80 #include "net/url_request/url_request_context_builder.h" |
| 85 #include "net/url_request/url_request_context_getter.h" | 81 #include "net/url_request/url_request_context_getter.h" |
| 86 #include "net/url_request/url_request_job_factory_impl.h" | 82 #include "net/url_request/url_request_job_factory_impl.h" |
| 87 #include "url/url_constants.h" | 83 #include "url/url_constants.h" |
| 88 | 84 |
| 89 // The IOSChromeIOThread object must outlive any tasks posted to the IO thread | 85 // The IOSChromeIOThread object must outlive any tasks posted to the IO thread |
| 90 // before the Quit task, so base::Bind() calls are not refcounted. | 86 // before the Quit task, so base::Bind() calls are not refcounted. |
| 91 | 87 |
| 92 namespace { | 88 namespace { |
| 93 | 89 |
| 94 const char kSupportedAuthSchemes[] = "basic,digest,ntlm"; | 90 const char kSupportedAuthSchemes[] = "basic,digest,ntlm"; |
| 95 | 91 |
| 96 const char kTCPFastOpenFieldTrialName[] = "TCPFastOpen"; | |
| 97 const char kTCPFastOpenHttpsEnabledGroupName[] = "HttpsEnabled"; | |
| 98 | |
| 99 const char kQuicFieldTrialName[] = "QUIC"; | |
| 100 const char kQuicFieldTrialEnabledGroupName[] = "Enabled"; | |
| 101 const char kQuicFieldTrialHttpsEnabledGroupName[] = "HttpsEnabled"; | |
| 102 | |
| 103 // The SPDY trial composes two different trial plus control groups: | |
| 104 // * A "holdback" group with SPDY disabled, and corresponding control | |
| 105 // (SPDY/3.1). The primary purpose of the holdback group is to encourage site | |
| 106 // operators to do feature detection rather than UA-sniffing. As such, this | |
| 107 // trial runs continuously. | |
| 108 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and | |
| 109 // eventual SPDY/4 deployment. | |
| 110 const char kSpdyFieldTrialName[] = "SPDY"; | |
| 111 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; | |
| 112 const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled"; | |
| 113 const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled"; | |
| 114 const char kSpdyFieldTrialParametrizedPrefix[] = "Parametrized"; | |
| 115 | |
| 116 // The AltSvc trial controls whether Alt-Svc headers are parsed. | |
| 117 // Disabled: | |
| 118 // Alt-Svc headers are not parsed. | |
| 119 // Alternate-Protocol headers are parsed. | |
| 120 // Enabled: | |
| 121 // Alt-Svc headers are parsed, but only same-host entries are used by | |
| 122 // default. (Use "enable_alternative_service_with_different_host" QUIC | |
| 123 // parameter to enable entries with different hosts.) | |
| 124 // Alternate-Protocol headers are ignored for responses that have an Alt-Svc | |
| 125 // header. | |
| 126 const char kAltSvcFieldTrialName[] = "ParseAltSvc"; | |
| 127 const char kAltSvcFieldTrialDisabledPrefix[] = "AltSvcDisabled"; | |
| 128 const char kAltSvcFieldTrialEnabledPrefix[] = "AltSvcEnabled"; | |
| 129 | |
| 130 // Field trial for network quality estimator. Seeds RTT and downstream | 92 // Field trial for network quality estimator. Seeds RTT and downstream |
| 131 // throughput observations with values that correspond to the connection type | 93 // throughput observations with values that correspond to the connection type |
| 132 // determined by the operating system. | 94 // determined by the operating system. |
| 133 const char kNetworkQualityEstimatorFieldTrialName[] = "NetworkQualityEstimator"; | 95 const char kNetworkQualityEstimatorFieldTrialName[] = "NetworkQualityEstimator"; |
| 134 | 96 |
| 135 // Field trial for NPN. | |
| 136 const char kNpnTrialName[] = "NPN"; | |
| 137 const char kNpnTrialEnabledGroupNamePrefix[] = "Enable"; | |
| 138 const char kNpnTrialDisabledGroupNamePrefix[] = "Disable"; | |
| 139 | |
| 140 // Field trial for priority dependencies. | |
| 141 const char kSpdyDependenciesFieldTrial[] = "SpdyEnableDependencies"; | |
| 142 const char kSpdyDependenciesFieldTrialEnable[] = "Enable"; | |
| 143 const char kSpdyDepencenciesFieldTrialDisable[] = "Disable"; | |
| 144 | |
| 145 // Used for the "system" URLRequestContext. | 97 // Used for the "system" URLRequestContext. |
| 146 class SystemURLRequestContext : public net::URLRequestContext { | 98 class SystemURLRequestContext : public net::URLRequestContext { |
| 147 public: | 99 public: |
| 148 SystemURLRequestContext() { | 100 SystemURLRequestContext() { |
| 149 #if defined(USE_NSS_VERIFIER) | 101 #if defined(USE_NSS_VERIFIER) |
| 150 net::SetURLRequestContextForNSSHttpIO(this); | 102 net::SetURLRequestContextForNSSHttpIO(this); |
| 151 #endif | 103 #endif |
| 152 } | 104 } |
| 153 | 105 |
| 154 private: | 106 private: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 int GetSwitchValueAsInt(const base::CommandLine& command_line, | 138 int GetSwitchValueAsInt(const base::CommandLine& command_line, |
| 187 const std::string& switch_name) { | 139 const std::string& switch_name) { |
| 188 int value; | 140 int value; |
| 189 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), | 141 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), |
| 190 &value)) { | 142 &value)) { |
| 191 return 0; | 143 return 0; |
| 192 } | 144 } |
| 193 return value; | 145 return value; |
| 194 } | 146 } |
| 195 | 147 |
| 196 // Returns the value associated with |key| in |params| or "" if the | |
| 197 // key is not present in the map. | |
| 198 const std::string& GetVariationParam( | |
| 199 const std::map<std::string, std::string>& params, | |
| 200 const std::string& key) { | |
| 201 std::map<std::string, std::string>::const_iterator it = params.find(key); | |
| 202 if (it == params.end()) | |
| 203 return base::EmptyString(); | |
| 204 | |
| 205 return it->second; | |
| 206 } | |
| 207 | |
| 208 } // namespace | 148 } // namespace |
| 209 | 149 |
| 210 class IOSChromeIOThread::LoggingNetworkChangeObserver | 150 class IOSChromeIOThread::LoggingNetworkChangeObserver |
| 211 : public net::NetworkChangeNotifier::IPAddressObserver, | 151 : public net::NetworkChangeNotifier::IPAddressObserver, |
| 212 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 152 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
| 213 public net::NetworkChangeNotifier::NetworkChangeObserver { | 153 public net::NetworkChangeNotifier::NetworkChangeObserver { |
| 214 public: | 154 public: |
| 215 // |net_log| must remain valid throughout our lifetime. | 155 // |net_log| must remain valid throughout our lifetime. |
| 216 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) | 156 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) |
| 217 : net_log_(net_log) { | 157 : net_log_(net_log) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 DCHECK(globals_); | 251 DCHECK(globals_); |
| 312 } | 252 } |
| 313 | 253 |
| 314 IOSChromeIOThread::Globals::SystemRequestContextLeakChecker:: | 254 IOSChromeIOThread::Globals::SystemRequestContextLeakChecker:: |
| 315 ~SystemRequestContextLeakChecker() { | 255 ~SystemRequestContextLeakChecker() { |
| 316 if (globals_->system_request_context.get()) | 256 if (globals_->system_request_context.get()) |
| 317 globals_->system_request_context->AssertNoURLRequests(); | 257 globals_->system_request_context->AssertNoURLRequests(); |
| 318 } | 258 } |
| 319 | 259 |
| 320 IOSChromeIOThread::Globals::Globals() | 260 IOSChromeIOThread::Globals::Globals() |
| 321 : system_request_context_leak_checker(this), | 261 : system_request_context_leak_checker(this) {} |
| 322 testing_fixed_http_port(0), | |
| 323 testing_fixed_https_port(0) {} | |
| 324 | 262 |
| 325 IOSChromeIOThread::Globals::~Globals() {} | 263 IOSChromeIOThread::Globals::~Globals() {} |
| 326 | 264 |
| 327 // |local_state| is passed in explicitly in order to (1) reduce implicit | 265 // |local_state| is passed in explicitly in order to (1) reduce implicit |
| 328 // dependencies and (2) make IOSChromeIOThread more flexible for testing. | 266 // dependencies and (2) make IOSChromeIOThread more flexible for testing. |
| 329 IOSChromeIOThread::IOSChromeIOThread(PrefService* local_state, | 267 IOSChromeIOThread::IOSChromeIOThread(PrefService* local_state, |
| 330 net_log::ChromeNetLog* net_log) | 268 net_log::ChromeNetLog* net_log) |
| 331 : net_log_(net_log), | 269 : net_log_(net_log), |
| 332 globals_(nullptr), | 270 globals_(nullptr), |
| 333 creation_time_(base::TimeTicks::Now()), | 271 creation_time_(base::TimeTicks::Now()), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 globals_->transport_security_state.reset(new net::TransportSecurityState()); | 366 globals_->transport_security_state.reset(new net::TransportSecurityState()); |
| 429 | 367 |
| 430 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( | 368 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( |
| 431 net::ct::CreateLogVerifiersForKnownLogs()); | 369 net::ct::CreateLogVerifiersForKnownLogs()); |
| 432 | 370 |
| 433 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); | 371 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); |
| 434 globals_->cert_transparency_verifier.reset(ct_verifier); | 372 globals_->cert_transparency_verifier.reset(ct_verifier); |
| 435 // Add built-in logs | 373 // Add built-in logs |
| 436 ct_verifier->AddLogs(ct_logs); | 374 ct_verifier->AddLogs(ct_logs); |
| 437 | 375 |
| 438 net::CTPolicyEnforcer* policy_enforcer = new net::CTPolicyEnforcer; | 376 params_.ct_policy_enforcer = new net::CTPolicyEnforcer; |
| 439 globals_->ct_policy_enforcer.reset(policy_enforcer); | |
| 440 | 377 |
| 441 globals_->ssl_config_service = GetSSLConfigService(); | 378 globals_->ssl_config_service = GetSSLConfigService(); |
| 442 | 379 |
| 443 CreateDefaultAuthHandlerFactory(); | 380 CreateDefaultAuthHandlerFactory(); |
| 444 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 381 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 445 // In-memory cookie store. | 382 // In-memory cookie store. |
| 446 globals_->system_cookie_store.reset(new net::CookieMonster(nullptr, nullptr)); | 383 globals_->system_cookie_store.reset(new net::CookieMonster(nullptr, nullptr)); |
| 447 // In-memory channel ID store. | 384 // In-memory channel ID store. |
| 448 globals_->system_channel_id_service.reset( | 385 globals_->system_channel_id_service.reset( |
| 449 new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr), | 386 new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr), |
| 450 base::WorkerPool::GetTaskRunner(true))); | 387 base::WorkerPool::GetTaskRunner(true))); |
| 451 globals_->system_cookie_store->SetChannelIDServiceID( | 388 globals_->system_cookie_store->SetChannelIDServiceID( |
| 452 globals_->system_channel_id_service->GetUniqueID()); | 389 globals_->system_channel_id_service->GetUniqueID()); |
| 453 globals_->http_user_agent_settings.reset(new net::StaticHttpUserAgentSettings( | 390 globals_->http_user_agent_settings.reset(new net::StaticHttpUserAgentSettings( |
| 454 std::string(), web::GetWebClient()->GetUserAgent(false))); | 391 std::string(), web::GetWebClient()->GetUserAgent(false))); |
| 455 if (command_line.HasSwitch(switches::kIOSTestingFixedHttpPort)) { | 392 if (command_line.HasSwitch(switches::kIOSTestingFixedHttpPort)) { |
| 456 globals_->testing_fixed_http_port = | 393 params_.testing_fixed_http_port = |
| 457 GetSwitchValueAsInt(command_line, switches::kIOSTestingFixedHttpPort); | 394 GetSwitchValueAsInt(command_line, switches::kIOSTestingFixedHttpPort); |
| 458 } | 395 } |
| 459 if (command_line.HasSwitch(switches::kIOSTestingFixedHttpsPort)) { | 396 if (command_line.HasSwitch(switches::kIOSTestingFixedHttpsPort)) { |
| 460 globals_->testing_fixed_https_port = | 397 params_.testing_fixed_https_port = |
| 461 GetSwitchValueAsInt(command_line, switches::kIOSTestingFixedHttpsPort); | 398 GetSwitchValueAsInt(command_line, switches::kIOSTestingFixedHttpsPort); |
| 462 } | 399 } |
| 463 ConfigureAltSvcGlobals( | |
| 464 base::FieldTrialList::FindFullName(kAltSvcFieldTrialName), globals_); | |
| 465 ConfigureQuic(); | |
| 466 ConfigurePriorityDependencies(); | |
| 467 InitializeNetworkOptions(); | |
| 468 | 400 |
| 401 params_.ignore_certificate_errors = false; |
| 402 params_.enable_quic_port_selection = false; |
| 403 params_.enable_user_alternate_protocol_ports = false; |
| 404 |
| 405 std::string quic_user_agent_id = ::GetChannelString(); |
| 406 if (!quic_user_agent_id.empty()) |
| 407 quic_user_agent_id.push_back(' '); |
| 408 quic_user_agent_id.append( |
| 409 version_info::GetProductNameAndVersionForUserAgent()); |
| 410 quic_user_agent_id.push_back(' '); |
| 411 quic_user_agent_id.append(web::BuildOSCpuInfo()); |
| 412 |
| 413 network_session_configurator::ParseFieldTrials(true, true, quic_user_agent_id, |
| 414 ¶ms_); |
| 469 const version_info::Channel channel = ::GetChannel(); | 415 const version_info::Channel channel = ::GetChannel(); |
| 470 if (channel == version_info::Channel::UNKNOWN || | 416 if (channel == version_info::Channel::UNKNOWN || |
| 471 channel == version_info::Channel::CANARY || | 417 channel == version_info::Channel::CANARY || |
| 472 channel == version_info::Channel::DEV) { | 418 channel == version_info::Channel::DEV) { |
| 473 globals_->url_request_backoff_manager.reset( | 419 globals_->url_request_backoff_manager.reset( |
| 474 new net::URLRequestBackoffManager()); | 420 new net::URLRequestBackoffManager()); |
| 475 } | 421 } |
| 476 | 422 |
| 477 // InitSystemRequestContext turns right around and posts a task back | 423 // InitSystemRequestContext turns right around and posts a task back |
| 478 // to the IO thread, so we can't let it run until we know the IO | 424 // to the IO thread, so we can't let it run until we know the IO |
| (...skipping 28 matching lines...) Expand all Loading... |
| 507 network_change_observer_.reset(); | 453 network_change_observer_.reset(); |
| 508 | 454 |
| 509 system_proxy_config_service_.reset(); | 455 system_proxy_config_service_.reset(); |
| 510 | 456 |
| 511 delete globals_; | 457 delete globals_; |
| 512 globals_ = nullptr; | 458 globals_ = nullptr; |
| 513 | 459 |
| 514 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); | 460 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
| 515 } | 461 } |
| 516 | 462 |
| 517 void IOSChromeIOThread::InitializeNetworkOptions() { | |
| 518 std::string group = base::FieldTrialList::FindFullName(kSpdyFieldTrialName); | |
| 519 VariationParameters params; | |
| 520 if (!variations::GetVariationParams(kSpdyFieldTrialName, ¶ms)) { | |
| 521 params.clear(); | |
| 522 } | |
| 523 ConfigureSpdyGlobals(group, params, globals_); | |
| 524 | |
| 525 ConfigureSSLTCPFastOpen(); | |
| 526 | |
| 527 ConfigureNPNGlobals(base::FieldTrialList::FindFullName(kNpnTrialName), | |
| 528 globals_); | |
| 529 | |
| 530 // TODO(rch): Make the client socket factory a per-network session | |
| 531 // instance, constructed from a NetworkSession::Params, to allow us | |
| 532 // to move this option to IOSChromeIOThread::Globals & | |
| 533 // HttpNetworkSession::Params. | |
| 534 } | |
| 535 | |
| 536 void IOSChromeIOThread::ConfigureSSLTCPFastOpen() { | |
| 537 const std::string trial_group = | |
| 538 base::FieldTrialList::FindFullName(kTCPFastOpenFieldTrialName); | |
| 539 if (trial_group == kTCPFastOpenHttpsEnabledGroupName) | |
| 540 globals_->enable_tcp_fast_open_for_ssl.set(true); | |
| 541 } | |
| 542 | |
| 543 // static | |
| 544 void IOSChromeIOThread::ConfigureSpdyGlobals( | |
| 545 base::StringPiece spdy_trial_group, | |
| 546 const VariationParameters& spdy_trial_params, | |
| 547 IOSChromeIOThread::Globals* globals) { | |
| 548 // No SPDY command-line flags have been specified. Examine trial groups. | |
| 549 if (spdy_trial_group.starts_with(kSpdyFieldTrialHoldbackGroupNamePrefix)) { | |
| 550 net::HttpStreamFactory::set_spdy_enabled(false); | |
| 551 return; | |
| 552 } | |
| 553 if (spdy_trial_group.starts_with(kSpdyFieldTrialSpdy31GroupNamePrefix)) { | |
| 554 globals->enable_spdy31.set(true); | |
| 555 globals->enable_http2.set(false); | |
| 556 return; | |
| 557 } | |
| 558 if (spdy_trial_group.starts_with(kSpdyFieldTrialSpdy4GroupNamePrefix)) { | |
| 559 globals->enable_spdy31.set(true); | |
| 560 globals->enable_http2.set(true); | |
| 561 return; | |
| 562 } | |
| 563 if (spdy_trial_group.starts_with(kSpdyFieldTrialParametrizedPrefix)) { | |
| 564 bool spdy_enabled = false; | |
| 565 globals->enable_spdy31.set(false); | |
| 566 globals->enable_http2.set(false); | |
| 567 if (base::LowerCaseEqualsASCII( | |
| 568 GetVariationParam(spdy_trial_params, "enable_http2"), "true")) { | |
| 569 spdy_enabled = true; | |
| 570 globals->enable_http2.set(true); | |
| 571 } | |
| 572 if (base::LowerCaseEqualsASCII( | |
| 573 GetVariationParam(spdy_trial_params, "enable_spdy31"), "true")) { | |
| 574 spdy_enabled = true; | |
| 575 globals->enable_spdy31.set(true); | |
| 576 } | |
| 577 // TODO(bnc): https://crbug.com/521597 | |
| 578 // HttpStreamFactory::spdy_enabled_ is redundant with globals->enable_http2 | |
| 579 // and enable_spdy31, can it be eliminated? | |
| 580 net::HttpStreamFactory::set_spdy_enabled(spdy_enabled); | |
| 581 return; | |
| 582 } | |
| 583 | |
| 584 // By default, enable HTTP/2. | |
| 585 globals->enable_spdy31.set(true); | |
| 586 globals->enable_http2.set(true); | |
| 587 } | |
| 588 | |
| 589 // static | |
| 590 void IOSChromeIOThread::ConfigureAltSvcGlobals( | |
| 591 base::StringPiece altsvc_trial_group, | |
| 592 IOSChromeIOThread::Globals* globals) { | |
| 593 if (altsvc_trial_group.starts_with(kAltSvcFieldTrialEnabledPrefix)) { | |
| 594 globals->parse_alternative_services.set(true); | |
| 595 return; | |
| 596 } | |
| 597 if (altsvc_trial_group.starts_with(kAltSvcFieldTrialDisabledPrefix)) { | |
| 598 globals->parse_alternative_services.set(false); | |
| 599 } | |
| 600 } | |
| 601 | |
| 602 // static | |
| 603 void IOSChromeIOThread::ConfigureNPNGlobals( | |
| 604 base::StringPiece npn_trial_group, | |
| 605 IOSChromeIOThread::Globals* globals) { | |
| 606 if (npn_trial_group.starts_with(kNpnTrialEnabledGroupNamePrefix)) { | |
| 607 globals->enable_npn.set(true); | |
| 608 } else if (npn_trial_group.starts_with(kNpnTrialDisabledGroupNamePrefix)) { | |
| 609 globals->enable_npn.set(false); | |
| 610 } | |
| 611 } | |
| 612 | |
| 613 void IOSChromeIOThread::CreateDefaultAuthHandlerFactory() { | 463 void IOSChromeIOThread::CreateDefaultAuthHandlerFactory() { |
| 614 std::vector<std::string> supported_schemes = | 464 std::vector<std::string> supported_schemes = |
| 615 base::SplitString(kSupportedAuthSchemes, ",", base::TRIM_WHITESPACE, | 465 base::SplitString(kSupportedAuthSchemes, ",", base::TRIM_WHITESPACE, |
| 616 base::SPLIT_WANT_NONEMPTY); | 466 base::SPLIT_WANT_NONEMPTY); |
| 617 globals_->http_auth_preferences.reset( | 467 globals_->http_auth_preferences.reset( |
| 618 new net::HttpAuthPreferences(supported_schemes, std::string())); | 468 new net::HttpAuthPreferences(supported_schemes, std::string())); |
| 619 globals_->http_auth_handler_factory = | 469 globals_->http_auth_handler_factory = |
| 620 net::HttpAuthHandlerRegistryFactory::Create( | 470 net::HttpAuthHandlerRegistryFactory::Create( |
| 621 globals_->http_auth_preferences.get(), globals_->host_resolver.get()); | 471 globals_->http_auth_preferences.get(), globals_->host_resolver.get()); |
| 622 } | 472 } |
| 623 | 473 |
| 624 void IOSChromeIOThread::ClearHostCache() { | 474 void IOSChromeIOThread::ClearHostCache() { |
| 625 DCHECK_CURRENTLY_ON(web::WebThread::IO); | 475 DCHECK_CURRENTLY_ON(web::WebThread::IO); |
| 626 | 476 |
| 627 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 477 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 628 if (host_cache) | 478 if (host_cache) |
| 629 host_cache->clear(); | 479 host_cache->clear(); |
| 630 } | 480 } |
| 631 | 481 |
| 632 void IOSChromeIOThread::InitializeNetworkSessionParams( | 482 const net::HttpNetworkSession::Params& IOSChromeIOThread::NetworkSessionParams() |
| 633 net::HttpNetworkSession::Params* params) { | 483 const { |
| 634 InitializeNetworkSessionParamsFromGlobals(*globals_, params); | 484 return params_; |
| 635 } | |
| 636 | |
| 637 void IOSChromeIOThread::InitializeNetworkSessionParamsFromGlobals( | |
| 638 const IOSChromeIOThread::Globals& globals, | |
| 639 net::HttpNetworkSession::Params* params) { | |
| 640 // The next two properties of the params don't seem to be | |
| 641 // elements of URLRequestContext, so they must be set here. | |
| 642 params->ct_policy_enforcer = globals.ct_policy_enforcer.get(); | |
| 643 | |
| 644 params->ignore_certificate_errors = false; | |
| 645 params->testing_fixed_http_port = globals.testing_fixed_http_port; | |
| 646 params->testing_fixed_https_port = globals.testing_fixed_https_port; | |
| 647 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( | |
| 648 ¶ms->enable_tcp_fast_open_for_ssl); | |
| 649 | |
| 650 globals.enable_spdy31.CopyToIfSet(¶ms->enable_spdy31); | |
| 651 globals.enable_http2.CopyToIfSet(¶ms->enable_http2); | |
| 652 globals.parse_alternative_services.CopyToIfSet( | |
| 653 ¶ms->parse_alternative_services); | |
| 654 globals.enable_alternative_service_with_different_host.CopyToIfSet( | |
| 655 ¶ms->enable_alternative_service_with_different_host); | |
| 656 | |
| 657 globals.enable_npn.CopyToIfSet(¶ms->enable_npn); | |
| 658 | |
| 659 globals.enable_priority_dependencies.CopyToIfSet( | |
| 660 ¶ms->enable_priority_dependencies); | |
| 661 | |
| 662 globals.enable_quic.CopyToIfSet(¶ms->enable_quic); | |
| 663 globals.enable_quic_for_proxies.CopyToIfSet(¶ms->enable_quic_for_proxies); | |
| 664 globals.quic_always_require_handshake_confirmation.CopyToIfSet( | |
| 665 ¶ms->quic_always_require_handshake_confirmation); | |
| 666 globals.quic_disable_connection_pooling.CopyToIfSet( | |
| 667 ¶ms->quic_disable_connection_pooling); | |
| 668 globals.quic_load_server_info_timeout_srtt_multiplier.CopyToIfSet( | |
| 669 ¶ms->quic_load_server_info_timeout_srtt_multiplier); | |
| 670 globals.quic_enable_connection_racing.CopyToIfSet( | |
| 671 ¶ms->quic_enable_connection_racing); | |
| 672 globals.quic_enable_non_blocking_io.CopyToIfSet( | |
| 673 ¶ms->quic_enable_non_blocking_io); | |
| 674 globals.quic_prefer_aes.CopyToIfSet(¶ms->quic_prefer_aes); | |
| 675 globals.quic_disable_disk_cache.CopyToIfSet(¶ms->quic_disable_disk_cache); | |
| 676 globals.quic_max_number_of_lossy_connections.CopyToIfSet( | |
| 677 ¶ms->quic_max_number_of_lossy_connections); | |
| 678 globals.quic_packet_loss_threshold.CopyToIfSet( | |
| 679 ¶ms->quic_packet_loss_threshold); | |
| 680 globals.quic_socket_receive_buffer_size.CopyToIfSet( | |
| 681 ¶ms->quic_socket_receive_buffer_size); | |
| 682 globals.quic_delay_tcp_race.CopyToIfSet(¶ms->quic_delay_tcp_race); | |
| 683 params->enable_quic_port_selection = false; | |
| 684 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); | |
| 685 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); | |
| 686 globals.quic_supported_versions.CopyToIfSet(¶ms->quic_supported_versions); | |
| 687 params->quic_connection_options = globals.quic_connection_options; | |
| 688 globals.quic_close_sessions_on_ip_change.CopyToIfSet( | |
| 689 ¶ms->quic_close_sessions_on_ip_change); | |
| 690 | |
| 691 params->enable_user_alternate_protocol_ports = false; | |
| 692 } | 485 } |
| 693 | 486 |
| 694 base::TimeTicks IOSChromeIOThread::creation_time() const { | 487 base::TimeTicks IOSChromeIOThread::creation_time() const { |
| 695 return creation_time_; | 488 return creation_time_; |
| 696 } | 489 } |
| 697 | 490 |
| 698 net::SSLConfigService* IOSChromeIOThread::GetSSLConfigService() { | 491 net::SSLConfigService* IOSChromeIOThread::GetSSLConfigService() { |
| 699 return ssl_config_service_manager_->Get(); | 492 return ssl_config_service_manager_->Get(); |
| 700 } | 493 } |
| 701 | 494 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 729 void IOSChromeIOThread::InitSystemRequestContextOnIOThread() { | 522 void IOSChromeIOThread::InitSystemRequestContextOnIOThread() { |
| 730 DCHECK_CURRENTLY_ON(web::WebThread::IO); | 523 DCHECK_CURRENTLY_ON(web::WebThread::IO); |
| 731 DCHECK(!globals_->system_proxy_service.get()); | 524 DCHECK(!globals_->system_proxy_service.get()); |
| 732 DCHECK(system_proxy_config_service_.get()); | 525 DCHECK(system_proxy_config_service_.get()); |
| 733 | 526 |
| 734 globals_->system_proxy_service = ios::ProxyServiceFactory::CreateProxyService( | 527 globals_->system_proxy_service = ios::ProxyServiceFactory::CreateProxyService( |
| 735 net_log_, nullptr, globals_->system_network_delegate.get(), | 528 net_log_, nullptr, globals_->system_network_delegate.get(), |
| 736 std::move(system_proxy_config_service_), true /* quick_check_enabled */); | 529 std::move(system_proxy_config_service_), true /* quick_check_enabled */); |
| 737 | 530 |
| 738 globals_->system_request_context.reset( | 531 globals_->system_request_context.reset( |
| 739 ConstructSystemRequestContext(globals_, net_log_)); | 532 ConstructSystemRequestContext(globals_, params_, net_log_)); |
| 740 } | |
| 741 | |
| 742 void IOSChromeIOThread::ConfigurePriorityDependencies() { | |
| 743 std::string group = | |
| 744 base::FieldTrialList::FindFullName(kSpdyDependenciesFieldTrial); | |
| 745 if (group == kSpdyDependenciesFieldTrialEnable) { | |
| 746 globals_->enable_priority_dependencies.set(true); | |
| 747 } else if (group == kSpdyDepencenciesFieldTrialDisable) { | |
| 748 globals_->enable_priority_dependencies.set(false); | |
| 749 } | |
| 750 } | |
| 751 | |
| 752 void IOSChromeIOThread::ConfigureQuic() { | |
| 753 // Always fetch the field trial group to ensure it is reported correctly. | |
| 754 // The command line flags will be associated with a group that is reported | |
| 755 // so long as trial is actually queried. | |
| 756 std::string group = base::FieldTrialList::FindFullName(kQuicFieldTrialName); | |
| 757 VariationParameters params; | |
| 758 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | |
| 759 params.clear(); | |
| 760 } | |
| 761 | |
| 762 ConfigureQuicGlobals(group, params, globals_); | |
| 763 } | |
| 764 | |
| 765 void IOSChromeIOThread::ConfigureQuicGlobals( | |
| 766 base::StringPiece quic_trial_group, | |
| 767 const VariationParameters& quic_trial_params, | |
| 768 IOSChromeIOThread::Globals* globals) { | |
| 769 bool enable_quic = ShouldEnableQuic(quic_trial_group); | |
| 770 globals->enable_quic.set(enable_quic); | |
| 771 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(quic_trial_group); | |
| 772 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); | |
| 773 | |
| 774 if (ShouldQuicEnableAlternativeServicesForDifferentHost(quic_trial_params)) { | |
| 775 globals->enable_alternative_service_with_different_host.set(true); | |
| 776 globals->parse_alternative_services.set(true); | |
| 777 } else { | |
| 778 globals->enable_alternative_service_with_different_host.set(false); | |
| 779 } | |
| 780 | |
| 781 if (enable_quic) { | |
| 782 globals->quic_always_require_handshake_confirmation.set( | |
| 783 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); | |
| 784 globals->quic_disable_connection_pooling.set( | |
| 785 ShouldQuicDisableConnectionPooling(quic_trial_params)); | |
| 786 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); | |
| 787 if (receive_buffer_size != 0) { | |
| 788 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); | |
| 789 } | |
| 790 globals->quic_delay_tcp_race.set(ShouldQuicDelayTcpRace(quic_trial_params)); | |
| 791 float load_server_info_timeout_srtt_multiplier = | |
| 792 GetQuicLoadServerInfoTimeoutSrttMultiplier(quic_trial_params); | |
| 793 if (load_server_info_timeout_srtt_multiplier != 0) { | |
| 794 globals->quic_load_server_info_timeout_srtt_multiplier.set( | |
| 795 load_server_info_timeout_srtt_multiplier); | |
| 796 } | |
| 797 globals->quic_enable_connection_racing.set( | |
| 798 ShouldQuicEnableConnectionRacing(quic_trial_params)); | |
| 799 globals->quic_enable_non_blocking_io.set( | |
| 800 ShouldQuicEnableNonBlockingIO(quic_trial_params)); | |
| 801 globals->quic_disable_disk_cache.set( | |
| 802 ShouldQuicDisableDiskCache(quic_trial_params)); | |
| 803 globals->quic_prefer_aes.set(ShouldQuicPreferAes(quic_trial_params)); | |
| 804 int max_number_of_lossy_connections = | |
| 805 GetQuicMaxNumberOfLossyConnections(quic_trial_params); | |
| 806 if (max_number_of_lossy_connections != 0) { | |
| 807 globals->quic_max_number_of_lossy_connections.set( | |
| 808 max_number_of_lossy_connections); | |
| 809 } | |
| 810 float packet_loss_threshold = GetQuicPacketLossThreshold(quic_trial_params); | |
| 811 if (packet_loss_threshold != 0) | |
| 812 globals->quic_packet_loss_threshold.set(packet_loss_threshold); | |
| 813 globals->quic_connection_options = | |
| 814 GetQuicConnectionOptions(quic_trial_params); | |
| 815 globals->quic_close_sessions_on_ip_change.set( | |
| 816 ShouldQuicCloseSessionsOnIpChange(quic_trial_params)); | |
| 817 } | |
| 818 | |
| 819 size_t max_packet_length = GetQuicMaxPacketLength(quic_trial_params); | |
| 820 if (max_packet_length != 0) { | |
| 821 globals->quic_max_packet_length.set(max_packet_length); | |
| 822 } | |
| 823 | |
| 824 std::string quic_user_agent_id = ::GetChannelString(); | |
| 825 if (!quic_user_agent_id.empty()) | |
| 826 quic_user_agent_id.push_back(' '); | |
| 827 quic_user_agent_id.append( | |
| 828 version_info::GetProductNameAndVersionForUserAgent()); | |
| 829 quic_user_agent_id.push_back(' '); | |
| 830 quic_user_agent_id.append(web::BuildOSCpuInfo()); | |
| 831 globals->quic_user_agent_id.set(quic_user_agent_id); | |
| 832 | |
| 833 net::QuicVersion version = GetQuicVersion(quic_trial_params); | |
| 834 if (version != net::QUIC_VERSION_UNSUPPORTED) { | |
| 835 net::QuicVersionVector supported_versions; | |
| 836 supported_versions.push_back(version); | |
| 837 globals->quic_supported_versions.set(supported_versions); | |
| 838 } | |
| 839 } | |
| 840 | |
| 841 bool IOSChromeIOThread::ShouldEnableQuic(base::StringPiece quic_trial_group) { | |
| 842 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || | |
| 843 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); | |
| 844 } | |
| 845 | |
| 846 bool IOSChromeIOThread::ShouldEnableQuicForProxies( | |
| 847 base::StringPiece quic_trial_group) { | |
| 848 return ShouldEnableQuic(quic_trial_group) || | |
| 849 ShouldEnableQuicForDataReductionProxy(); | |
| 850 } | |
| 851 | |
| 852 bool IOSChromeIOThread::ShouldEnableQuicForDataReductionProxy() { | |
| 853 return data_reduction_proxy::params::IsIncludedInQuicFieldTrial(); | |
| 854 } | |
| 855 | |
| 856 net::QuicTagVector IOSChromeIOThread::GetQuicConnectionOptions( | |
| 857 const VariationParameters& quic_trial_params) { | |
| 858 VariationParameters::const_iterator it = | |
| 859 quic_trial_params.find("connection_options"); | |
| 860 if (it == quic_trial_params.end()) { | |
| 861 return net::QuicTagVector(); | |
| 862 } | |
| 863 | |
| 864 return net::QuicUtils::ParseQuicConnectionOptions(it->second); | |
| 865 } | |
| 866 | |
| 867 bool IOSChromeIOThread::ShouldQuicAlwaysRequireHandshakeConfirmation( | |
| 868 const VariationParameters& quic_trial_params) { | |
| 869 return base::LowerCaseEqualsASCII( | |
| 870 GetVariationParam(quic_trial_params, | |
| 871 "always_require_handshake_confirmation"), | |
| 872 "true"); | |
| 873 } | |
| 874 | |
| 875 bool IOSChromeIOThread::ShouldQuicDisableConnectionPooling( | |
| 876 const VariationParameters& quic_trial_params) { | |
| 877 return base::LowerCaseEqualsASCII( | |
| 878 GetVariationParam(quic_trial_params, "disable_connection_pooling"), | |
| 879 "true"); | |
| 880 } | |
| 881 | |
| 882 float IOSChromeIOThread::GetQuicLoadServerInfoTimeoutSrttMultiplier( | |
| 883 const VariationParameters& quic_trial_params) { | |
| 884 double value; | |
| 885 if (base::StringToDouble( | |
| 886 GetVariationParam(quic_trial_params, "load_server_info_time_to_srtt"), | |
| 887 &value)) { | |
| 888 return static_cast<float>(value); | |
| 889 } | |
| 890 return 0.0f; | |
| 891 } | |
| 892 | |
| 893 bool IOSChromeIOThread::ShouldQuicEnableConnectionRacing( | |
| 894 const VariationParameters& quic_trial_params) { | |
| 895 return base::LowerCaseEqualsASCII( | |
| 896 GetVariationParam(quic_trial_params, "enable_connection_racing"), "true"); | |
| 897 } | |
| 898 | |
| 899 bool IOSChromeIOThread::ShouldQuicEnableNonBlockingIO( | |
| 900 const VariationParameters& quic_trial_params) { | |
| 901 return base::LowerCaseEqualsASCII( | |
| 902 GetVariationParam(quic_trial_params, "enable_non_blocking_io"), "true"); | |
| 903 } | |
| 904 | |
| 905 bool IOSChromeIOThread::ShouldQuicDisableDiskCache( | |
| 906 const VariationParameters& quic_trial_params) { | |
| 907 return base::LowerCaseEqualsASCII( | |
| 908 GetVariationParam(quic_trial_params, "disable_disk_cache"), "true"); | |
| 909 } | |
| 910 | |
| 911 bool IOSChromeIOThread::ShouldQuicPreferAes( | |
| 912 const VariationParameters& quic_trial_params) { | |
| 913 return base::LowerCaseEqualsASCII( | |
| 914 GetVariationParam(quic_trial_params, "prefer_aes"), "true"); | |
| 915 } | |
| 916 | |
| 917 bool IOSChromeIOThread::ShouldQuicEnableAlternativeServicesForDifferentHost( | |
| 918 const VariationParameters& quic_trial_params) { | |
| 919 // TODO(bnc): Remove inaccurately named "use_alternative_services" parameter. | |
| 920 return base::LowerCaseEqualsASCII( | |
| 921 GetVariationParam(quic_trial_params, "use_alternative_services"), | |
| 922 "true") || | |
| 923 base::LowerCaseEqualsASCII( | |
| 924 GetVariationParam( | |
| 925 quic_trial_params, | |
| 926 "enable_alternative_service_with_different_host"), | |
| 927 "true"); | |
| 928 } | |
| 929 | |
| 930 int IOSChromeIOThread::GetQuicMaxNumberOfLossyConnections( | |
| 931 const VariationParameters& quic_trial_params) { | |
| 932 int value; | |
| 933 if (base::StringToInt(GetVariationParam(quic_trial_params, | |
| 934 "max_number_of_lossy_connections"), | |
| 935 &value)) { | |
| 936 return value; | |
| 937 } | |
| 938 return 0; | |
| 939 } | |
| 940 | |
| 941 float IOSChromeIOThread::GetQuicPacketLossThreshold( | |
| 942 const VariationParameters& quic_trial_params) { | |
| 943 double value; | |
| 944 if (base::StringToDouble( | |
| 945 GetVariationParam(quic_trial_params, "packet_loss_threshold"), | |
| 946 &value)) { | |
| 947 return static_cast<float>(value); | |
| 948 } | |
| 949 return 0.0f; | |
| 950 } | |
| 951 | |
| 952 int IOSChromeIOThread::GetQuicSocketReceiveBufferSize( | |
| 953 const VariationParameters& quic_trial_params) { | |
| 954 int value; | |
| 955 if (base::StringToInt( | |
| 956 GetVariationParam(quic_trial_params, "receive_buffer_size"), | |
| 957 &value)) { | |
| 958 return value; | |
| 959 } | |
| 960 return 0; | |
| 961 } | |
| 962 | |
| 963 bool IOSChromeIOThread::ShouldQuicDelayTcpRace( | |
| 964 const VariationParameters& quic_trial_params) { | |
| 965 return base::LowerCaseEqualsASCII( | |
| 966 GetVariationParam(quic_trial_params, "delay_tcp_race"), "true"); | |
| 967 } | |
| 968 | |
| 969 bool IOSChromeIOThread::ShouldQuicCloseSessionsOnIpChange( | |
| 970 const VariationParameters& quic_trial_params) { | |
| 971 return base::LowerCaseEqualsASCII( | |
| 972 GetVariationParam(quic_trial_params, "close_sessions_on_ip_change"), | |
| 973 "true"); | |
| 974 } | |
| 975 | |
| 976 size_t IOSChromeIOThread::GetQuicMaxPacketLength( | |
| 977 const VariationParameters& quic_trial_params) { | |
| 978 unsigned value; | |
| 979 if (base::StringToUint( | |
| 980 GetVariationParam(quic_trial_params, "max_packet_length"), &value)) { | |
| 981 return value; | |
| 982 } | |
| 983 return 0; | |
| 984 } | |
| 985 | |
| 986 net::QuicVersion IOSChromeIOThread::GetQuicVersion( | |
| 987 const VariationParameters& quic_trial_params) { | |
| 988 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version")); | |
| 989 } | |
| 990 | |
| 991 net::QuicVersion IOSChromeIOThread::ParseQuicVersion( | |
| 992 const std::string& quic_version) { | |
| 993 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | |
| 994 for (size_t i = 0; i < supported_versions.size(); ++i) { | |
| 995 net::QuicVersion version = supported_versions[i]; | |
| 996 if (net::QuicVersionToString(version) == quic_version) { | |
| 997 return version; | |
| 998 } | |
| 999 } | |
| 1000 | |
| 1001 return net::QUIC_VERSION_UNSUPPORTED; | |
| 1002 } | 533 } |
| 1003 | 534 |
| 1004 net::URLRequestContext* IOSChromeIOThread::ConstructSystemRequestContext( | 535 net::URLRequestContext* IOSChromeIOThread::ConstructSystemRequestContext( |
| 1005 IOSChromeIOThread::Globals* globals, | 536 IOSChromeIOThread::Globals* globals, |
| 537 const net::HttpNetworkSession::Params& params, |
| 1006 net::NetLog* net_log) { | 538 net::NetLog* net_log) { |
| 1007 net::URLRequestContext* context = new SystemURLRequestContext; | 539 net::URLRequestContext* context = new SystemURLRequestContext; |
| 1008 context->set_net_log(net_log); | 540 context->set_net_log(net_log); |
| 1009 context->set_host_resolver(globals->host_resolver.get()); | 541 context->set_host_resolver(globals->host_resolver.get()); |
| 1010 context->set_cert_verifier(globals->cert_verifier.get()); | 542 context->set_cert_verifier(globals->cert_verifier.get()); |
| 1011 context->set_transport_security_state( | 543 context->set_transport_security_state( |
| 1012 globals->transport_security_state.get()); | 544 globals->transport_security_state.get()); |
| 1013 context->set_cert_transparency_verifier( | 545 context->set_cert_transparency_verifier( |
| 1014 globals->cert_transparency_verifier.get()); | 546 globals->cert_transparency_verifier.get()); |
| 1015 context->set_ssl_config_service(globals->ssl_config_service.get()); | 547 context->set_ssl_config_service(globals->ssl_config_service.get()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1032 context->set_network_delegate(globals->system_network_delegate.get()); | 564 context->set_network_delegate(globals->system_network_delegate.get()); |
| 1033 context->set_http_user_agent_settings( | 565 context->set_http_user_agent_settings( |
| 1034 globals->http_user_agent_settings.get()); | 566 globals->http_user_agent_settings.get()); |
| 1035 context->set_network_quality_estimator( | 567 context->set_network_quality_estimator( |
| 1036 globals->network_quality_estimator.get()); | 568 globals->network_quality_estimator.get()); |
| 1037 context->set_backoff_manager(globals->url_request_backoff_manager.get()); | 569 context->set_backoff_manager(globals->url_request_backoff_manager.get()); |
| 1038 | 570 |
| 1039 context->set_http_server_properties( | 571 context->set_http_server_properties( |
| 1040 globals->http_server_properties->GetWeakPtr()); | 572 globals->http_server_properties->GetWeakPtr()); |
| 1041 | 573 |
| 1042 net::HttpNetworkSession::Params system_params; | 574 net::HttpNetworkSession::Params system_params(params); |
| 1043 InitializeNetworkSessionParamsFromGlobals(*globals, &system_params); | |
| 1044 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( | 575 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( |
| 1045 context, &system_params); | 576 context, &system_params); |
| 1046 | 577 |
| 1047 globals->system_http_network_session.reset( | 578 globals->system_http_network_session.reset( |
| 1048 new net::HttpNetworkSession(system_params)); | 579 new net::HttpNetworkSession(system_params)); |
| 1049 globals->system_http_transaction_factory.reset( | 580 globals->system_http_transaction_factory.reset( |
| 1050 new net::HttpNetworkLayer(globals->system_http_network_session.get())); | 581 new net::HttpNetworkLayer(globals->system_http_network_session.get())); |
| 1051 context->set_http_transaction_factory( | 582 context->set_http_transaction_factory( |
| 1052 globals->system_http_transaction_factory.get()); | 583 globals->system_http_transaction_factory.get()); |
| 1053 | 584 |
| 1054 return context; | 585 return context; |
| 1055 } | 586 } |
| OLD | NEW |