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 kSpdyFieldTrialHoldbackGroupName[] = "SpdyDisabled"; | 137 const char kSpdyFieldTrialHoldbackGroupName[] = "SpdyDisabled"; |
138 const char kSpdyFieldTrialHoldbackControlGroupName[] = "Control"; | 138 const char kSpdyFieldTrialHoldbackControlGroupName[] = "Control"; |
139 const char kSpdyFieldTrialSpdy4GroupName[] = "Spdy4Enabled"; | 139 const char kSpdyFieldTrialSpdy4GroupName[] = "Spdy4Enabled"; |
140 const char kSpdyFieldTrialSpdy4ControlGroupName[] = "Spdy4Control"; | 140 const char kSpdyFieldTrialSpdy4ControlGroupName[] = "Spdy4Control"; |
141 | 141 |
| 142 // Field trial for Cache-Control: stale-while-revalidate directive. |
| 143 const char kStaleWhileRevalidateFieldTrialName[] = "StaleWhileRevalidate"; |
| 144 |
142 #if defined(OS_MACOSX) && !defined(OS_IOS) | 145 #if defined(OS_MACOSX) && !defined(OS_IOS) |
143 void ObserveKeychainEvents() { | 146 void ObserveKeychainEvents() { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
145 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); | 148 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); |
146 } | 149 } |
147 #endif | 150 #endif |
148 | 151 |
149 // Used for the "system" URLRequestContext. | 152 // Used for the "system" URLRequestContext. |
150 class SystemURLRequestContext : public net::URLRequestContext { | 153 class SystemURLRequestContext : public net::URLRequestContext { |
151 public: | 154 public: |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 IOThread::Globals:: | 424 IOThread::Globals:: |
422 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { | 425 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { |
423 if (globals_->system_request_context.get()) | 426 if (globals_->system_request_context.get()) |
424 globals_->system_request_context->AssertNoURLRequests(); | 427 globals_->system_request_context->AssertNoURLRequests(); |
425 } | 428 } |
426 | 429 |
427 IOThread::Globals::Globals() | 430 IOThread::Globals::Globals() |
428 : system_request_context_leak_checker(this), | 431 : system_request_context_leak_checker(this), |
429 enable_ssl_connect_job_waiting(false), | 432 enable_ssl_connect_job_waiting(false), |
430 ignore_certificate_errors(false), | 433 ignore_certificate_errors(false), |
| 434 use_stale_while_revalidate(false), |
431 testing_fixed_http_port(0), | 435 testing_fixed_http_port(0), |
432 testing_fixed_https_port(0), | 436 testing_fixed_https_port(0), |
433 enable_user_alternate_protocol_ports(false) { | 437 enable_user_alternate_protocol_ports(false) { |
434 } | 438 } |
435 | 439 |
436 IOThread::Globals::~Globals() {} | 440 IOThread::Globals::~Globals() {} |
437 | 441 |
438 // |local_state| is passed in explicitly in order to (1) reduce implicit | 442 // |local_state| is passed in explicitly in order to (1) reduce implicit |
439 // dependencies and (2) make IOThread more flexible for testing. | 443 // dependencies and (2) make IOThread more flexible for testing. |
440 IOThread::IOThread( | 444 IOThread::IOThread( |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 if (command_line.HasSwitch(switches::kHostRules)) { | 698 if (command_line.HasSwitch(switches::kHostRules)) { |
695 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); | 699 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); |
696 globals_->host_mapping_rules->SetRulesFromString( | 700 globals_->host_mapping_rules->SetRulesFromString( |
697 command_line.GetSwitchValueASCII(switches::kHostRules)); | 701 command_line.GetSwitchValueASCII(switches::kHostRules)); |
698 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); | 702 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); |
699 } | 703 } |
700 if (command_line.HasSwitch(switches::kEnableSSLConnectJobWaiting)) | 704 if (command_line.HasSwitch(switches::kEnableSSLConnectJobWaiting)) |
701 globals_->enable_ssl_connect_job_waiting = true; | 705 globals_->enable_ssl_connect_job_waiting = true; |
702 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) | 706 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) |
703 globals_->ignore_certificate_errors = true; | 707 globals_->ignore_certificate_errors = true; |
| 708 if (command_line.HasSwitch(switches::kEnableStaleWhileRevalidate)) |
| 709 globals_->use_stale_while_revalidate = true; |
| 710 if (base::FieldTrialList::FindFullName(kStaleWhileRevalidateFieldTrialName) == |
| 711 "Enabled") |
| 712 globals_->use_stale_while_revalidate = true; |
704 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { | 713 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
705 globals_->testing_fixed_http_port = | 714 globals_->testing_fixed_http_port = |
706 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); | 715 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); |
707 } | 716 } |
708 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | 717 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
709 globals_->testing_fixed_https_port = | 718 globals_->testing_fixed_https_port = |
710 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); | 719 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); |
711 } | 720 } |
712 ConfigureQuic(command_line); | 721 ConfigureQuic(command_line); |
713 if (command_line.HasSwitch( | 722 if (command_line.HasSwitch( |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 params->transport_security_state = globals.transport_security_state.get(); | 1020 params->transport_security_state = globals.transport_security_state.get(); |
1012 params->ssl_config_service = globals.ssl_config_service.get(); | 1021 params->ssl_config_service = globals.ssl_config_service.get(); |
1013 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); | 1022 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); |
1014 params->http_server_properties = | 1023 params->http_server_properties = |
1015 globals.http_server_properties->GetWeakPtr(); | 1024 globals.http_server_properties->GetWeakPtr(); |
1016 params->network_delegate = globals.system_network_delegate.get(); | 1025 params->network_delegate = globals.system_network_delegate.get(); |
1017 params->host_mapping_rules = globals.host_mapping_rules.get(); | 1026 params->host_mapping_rules = globals.host_mapping_rules.get(); |
1018 params->enable_ssl_connect_job_waiting = | 1027 params->enable_ssl_connect_job_waiting = |
1019 globals.enable_ssl_connect_job_waiting; | 1028 globals.enable_ssl_connect_job_waiting; |
1020 params->ignore_certificate_errors = globals.ignore_certificate_errors; | 1029 params->ignore_certificate_errors = globals.ignore_certificate_errors; |
| 1030 params->use_stale_while_revalidate = globals.use_stale_while_revalidate; |
1021 params->testing_fixed_http_port = globals.testing_fixed_http_port; | 1031 params->testing_fixed_http_port = globals.testing_fixed_http_port; |
1022 params->testing_fixed_https_port = globals.testing_fixed_https_port; | 1032 params->testing_fixed_https_port = globals.testing_fixed_https_port; |
1023 | 1033 |
1024 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( | 1034 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( |
1025 ¶ms->spdy_initial_max_concurrent_streams); | 1035 ¶ms->spdy_initial_max_concurrent_streams); |
1026 globals.force_spdy_single_domain.CopyToIfSet( | 1036 globals.force_spdy_single_domain.CopyToIfSet( |
1027 ¶ms->force_spdy_single_domain); | 1037 ¶ms->force_spdy_single_domain); |
1028 globals.enable_spdy_compression.CopyToIfSet( | 1038 globals.enable_spdy_compression.CopyToIfSet( |
1029 ¶ms->enable_spdy_compression); | 1039 ¶ms->enable_spdy_compression); |
1030 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( | 1040 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1402 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1393 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1403 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1394 net::QuicVersion version = supported_versions[i]; | 1404 net::QuicVersion version = supported_versions[i]; |
1395 if (net::QuicVersionToString(version) == quic_version) { | 1405 if (net::QuicVersionToString(version) == quic_version) { |
1396 return version; | 1406 return version; |
1397 } | 1407 } |
1398 } | 1408 } |
1399 | 1409 |
1400 return net::QUIC_VERSION_UNSUPPORTED; | 1410 return net::QUIC_VERSION_UNSUPPORTED; |
1401 } | 1411 } |
OLD | NEW |