| OLD | NEW |
| 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 "chrome/browser/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // operators to do feature detection rather than UA-sniffing. As such, this | 132 // operators to do feature detection rather than UA-sniffing. As such, this |
| 133 // trial runs continuously. | 133 // trial runs continuously. |
| 134 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and | 134 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and |
| 135 // eventual SPDY/4 deployment. | 135 // eventual SPDY/4 deployment. |
| 136 const char kSpdyFieldTrialName[] = "SPDY"; | 136 const char kSpdyFieldTrialName[] = "SPDY"; |
| 137 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; | 137 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; |
| 138 const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled"; | 138 const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled"; |
| 139 const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled"; | 139 const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled"; |
| 140 const char kSpdyFieldTrialParametrizedPrefix[] = "Parametrized"; | 140 const char kSpdyFieldTrialParametrizedPrefix[] = "Parametrized"; |
| 141 | 141 |
| 142 // Field trial for Cache-Control: stale-while-revalidate directive. | |
| 143 const char kStaleWhileRevalidateFieldTrialName[] = "StaleWhileRevalidate"; | |
| 144 | |
| 145 #if defined(OS_MACOSX) && !defined(OS_IOS) | 142 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 146 void ObserveKeychainEvents() { | 143 void ObserveKeychainEvents() { |
| 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 148 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); | 145 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); |
| 149 } | 146 } |
| 150 #endif | 147 #endif |
| 151 | 148 |
| 152 // Used for the "system" URLRequestContext. | 149 // Used for the "system" URLRequestContext. |
| 153 class SystemURLRequestContext : public net::URLRequestContext { | 150 class SystemURLRequestContext : public net::URLRequestContext { |
| 154 public: | 151 public: |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 const std::string& GetVariationParam( | 293 const std::string& GetVariationParam( |
| 297 const std::map<std::string, std::string>& params, | 294 const std::map<std::string, std::string>& params, |
| 298 const std::string& key) { | 295 const std::string& key) { |
| 299 std::map<std::string, std::string>::const_iterator it = params.find(key); | 296 std::map<std::string, std::string>::const_iterator it = params.find(key); |
| 300 if (it == params.end()) | 297 if (it == params.end()) |
| 301 return base::EmptyString(); | 298 return base::EmptyString(); |
| 302 | 299 |
| 303 return it->second; | 300 return it->second; |
| 304 } | 301 } |
| 305 | 302 |
| 306 // Return true if stale-while-revalidate support should be enabled. | |
| 307 bool IsStaleWhileRevalidateEnabled(const base::CommandLine& command_line) { | |
| 308 if (command_line.HasSwitch(switches::kEnableStaleWhileRevalidate)) | |
| 309 return true; | |
| 310 const std::string group_name = | |
| 311 base::FieldTrialList::FindFullName(kStaleWhileRevalidateFieldTrialName); | |
| 312 return group_name == "Enabled"; | |
| 313 } | |
| 314 | |
| 315 // Parse kUseSpdy command line flag options, which may contain the following: | 303 // Parse kUseSpdy command line flag options, which may contain the following: |
| 316 // | 304 // |
| 317 // "off" : Disables SPDY support entirely. | 305 // "off" : Disables SPDY support entirely. |
| 318 // "no-ping" : Disables SPDY ping connection testing. | 306 // "no-ping" : Disables SPDY ping connection testing. |
| 319 // "exclude=<host>" : Disables SPDY support for the host <host>. | 307 // "exclude=<host>" : Disables SPDY support for the host <host>. |
| 320 // "no-compress" : Disables SPDY header compression. | 308 // "no-compress" : Disables SPDY header compression. |
| 321 // "no-alt-protocols : Disables alternate protocol support. | 309 // "no-alt-protocols : Disables alternate protocol support. |
| 322 // "init-max-streams=<limit>" : Specifies the maximum number of concurrent | 310 // "init-max-streams=<limit>" : Specifies the maximum number of concurrent |
| 323 // streams for a SPDY session, unless the | 311 // streams for a SPDY session, unless the |
| 324 // specifies a different value via SETTINGS. | 312 // specifies a different value via SETTINGS. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 471 |
| 484 IOThread::Globals:: | 472 IOThread::Globals:: |
| 485 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { | 473 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { |
| 486 if (globals_->system_request_context.get()) | 474 if (globals_->system_request_context.get()) |
| 487 globals_->system_request_context->AssertNoURLRequests(); | 475 globals_->system_request_context->AssertNoURLRequests(); |
| 488 } | 476 } |
| 489 | 477 |
| 490 IOThread::Globals::Globals() | 478 IOThread::Globals::Globals() |
| 491 : system_request_context_leak_checker(this), | 479 : system_request_context_leak_checker(this), |
| 492 ignore_certificate_errors(false), | 480 ignore_certificate_errors(false), |
| 493 use_stale_while_revalidate(false), | |
| 494 testing_fixed_http_port(0), | 481 testing_fixed_http_port(0), |
| 495 testing_fixed_https_port(0), | 482 testing_fixed_https_port(0), |
| 496 enable_user_alternate_protocol_ports(false) { | 483 enable_user_alternate_protocol_ports(false) { |
| 497 } | 484 } |
| 498 | 485 |
| 499 IOThread::Globals::~Globals() {} | 486 IOThread::Globals::~Globals() {} |
| 500 | 487 |
| 501 // |local_state| is passed in explicitly in order to (1) reduce implicit | 488 // |local_state| is passed in explicitly in order to (1) reduce implicit |
| 502 // dependencies and (2) make IOThread more flexible for testing. | 489 // dependencies and (2) make IOThread more flexible for testing. |
| 503 IOThread::IOThread( | 490 IOThread::IOThread( |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 788 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 802 "466432 IOThread::InitAsync::CommandLineConfiguration")); | 789 "466432 IOThread::InitAsync::CommandLineConfiguration")); |
| 803 if (command_line.HasSwitch(switches::kHostRules)) { | 790 if (command_line.HasSwitch(switches::kHostRules)) { |
| 804 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); | 791 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); |
| 805 globals_->host_mapping_rules->SetRulesFromString( | 792 globals_->host_mapping_rules->SetRulesFromString( |
| 806 command_line.GetSwitchValueASCII(switches::kHostRules)); | 793 command_line.GetSwitchValueASCII(switches::kHostRules)); |
| 807 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); | 794 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); |
| 808 } | 795 } |
| 809 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) | 796 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) |
| 810 globals_->ignore_certificate_errors = true; | 797 globals_->ignore_certificate_errors = true; |
| 811 globals_->use_stale_while_revalidate = | |
| 812 IsStaleWhileRevalidateEnabled(command_line); | |
| 813 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { | 798 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
| 814 globals_->testing_fixed_http_port = | 799 globals_->testing_fixed_http_port = |
| 815 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); | 800 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); |
| 816 } | 801 } |
| 817 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | 802 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
| 818 globals_->testing_fixed_https_port = | 803 globals_->testing_fixed_https_port = |
| 819 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); | 804 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); |
| 820 } | 805 } |
| 821 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 806 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 822 // is fixed. | 807 // is fixed. |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 params->cert_policy_enforcer = globals.cert_policy_enforcer.get(); | 1126 params->cert_policy_enforcer = globals.cert_policy_enforcer.get(); |
| 1142 params->channel_id_service = globals.system_channel_id_service.get(); | 1127 params->channel_id_service = globals.system_channel_id_service.get(); |
| 1143 params->transport_security_state = globals.transport_security_state.get(); | 1128 params->transport_security_state = globals.transport_security_state.get(); |
| 1144 params->ssl_config_service = globals.ssl_config_service.get(); | 1129 params->ssl_config_service = globals.ssl_config_service.get(); |
| 1145 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); | 1130 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); |
| 1146 params->http_server_properties = | 1131 params->http_server_properties = |
| 1147 globals.http_server_properties->GetWeakPtr(); | 1132 globals.http_server_properties->GetWeakPtr(); |
| 1148 params->network_delegate = globals.system_network_delegate.get(); | 1133 params->network_delegate = globals.system_network_delegate.get(); |
| 1149 params->host_mapping_rules = globals.host_mapping_rules.get(); | 1134 params->host_mapping_rules = globals.host_mapping_rules.get(); |
| 1150 params->ignore_certificate_errors = globals.ignore_certificate_errors; | 1135 params->ignore_certificate_errors = globals.ignore_certificate_errors; |
| 1151 params->use_stale_while_revalidate = globals.use_stale_while_revalidate; | |
| 1152 params->testing_fixed_http_port = globals.testing_fixed_http_port; | 1136 params->testing_fixed_http_port = globals.testing_fixed_http_port; |
| 1153 params->testing_fixed_https_port = globals.testing_fixed_https_port; | 1137 params->testing_fixed_https_port = globals.testing_fixed_https_port; |
| 1154 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( | 1138 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( |
| 1155 ¶ms->enable_tcp_fast_open_for_ssl); | 1139 ¶ms->enable_tcp_fast_open_for_ssl); |
| 1156 | 1140 |
| 1157 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( | 1141 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( |
| 1158 ¶ms->spdy_initial_max_concurrent_streams); | 1142 ¶ms->spdy_initial_max_concurrent_streams); |
| 1159 globals.enable_spdy_compression.CopyToIfSet( | 1143 globals.enable_spdy_compression.CopyToIfSet( |
| 1160 ¶ms->enable_spdy_compression); | 1144 ¶ms->enable_spdy_compression); |
| 1161 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( | 1145 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1600 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1617 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1601 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1618 net::QuicVersion version = supported_versions[i]; | 1602 net::QuicVersion version = supported_versions[i]; |
| 1619 if (net::QuicVersionToString(version) == quic_version) { | 1603 if (net::QuicVersionToString(version) == quic_version) { |
| 1620 return version; | 1604 return version; |
| 1621 } | 1605 } |
| 1622 } | 1606 } |
| 1623 | 1607 |
| 1624 return net::QUIC_VERSION_UNSUPPORTED; | 1608 return net::QUIC_VERSION_UNSUPPORTED; |
| 1625 } | 1609 } |
| OLD | NEW |