Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: chrome/browser/io_thread.cc

Issue 455623003: stale-while-revalidate experimental implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // operators to do feature detection rather than UA-sniffing. As such, this 129 // operators to do feature detection rather than UA-sniffing. As such, this
130 // trial runs continuously. 130 // trial runs continuously.
131 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and 131 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and
132 // eventual SPDY/4 deployment. 132 // eventual SPDY/4 deployment.
133 const char kSpdyFieldTrialName[] = "SPDY"; 133 const char kSpdyFieldTrialName[] = "SPDY";
134 const char kSpdyFieldTrialHoldbackGroupName[] = "SpdyDisabled"; 134 const char kSpdyFieldTrialHoldbackGroupName[] = "SpdyDisabled";
135 const char kSpdyFieldTrialHoldbackControlGroupName[] = "Control"; 135 const char kSpdyFieldTrialHoldbackControlGroupName[] = "Control";
136 const char kSpdyFieldTrialSpdy4GroupName[] = "Spdy4Enabled"; 136 const char kSpdyFieldTrialSpdy4GroupName[] = "Spdy4Enabled";
137 const char kSpdyFieldTrialSpdy4ControlGroupName[] = "Spdy4Control"; 137 const char kSpdyFieldTrialSpdy4ControlGroupName[] = "Spdy4Control";
138 138
139 // Field trial for Cache-Control: stale-while-revalidate directive.
140 const char kStaleWhileRevalidateFieldTrialName[] = "StaleWhileRevalidate";
141
139 #if defined(OS_MACOSX) && !defined(OS_IOS) 142 #if defined(OS_MACOSX) && !defined(OS_IOS)
140 void ObserveKeychainEvents() { 143 void ObserveKeychainEvents() {
141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
142 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); 145 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents();
143 } 146 }
144 #endif 147 #endif
145 148
146 // Used for the "system" URLRequestContext. 149 // Used for the "system" URLRequestContext.
147 class SystemURLRequestContext : public net::URLRequestContext { 150 class SystemURLRequestContext : public net::URLRequestContext {
148 public: 151 public:
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 IOThread::Globals:: 421 IOThread::Globals::
419 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { 422 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() {
420 if (globals_->system_request_context.get()) 423 if (globals_->system_request_context.get())
421 globals_->system_request_context->AssertNoURLRequests(); 424 globals_->system_request_context->AssertNoURLRequests();
422 } 425 }
423 426
424 IOThread::Globals::Globals() 427 IOThread::Globals::Globals()
425 : system_request_context_leak_checker(this), 428 : system_request_context_leak_checker(this),
426 enable_ssl_connect_job_waiting(false), 429 enable_ssl_connect_job_waiting(false),
427 ignore_certificate_errors(false), 430 ignore_certificate_errors(false),
431 use_stale_while_revalidate(false),
428 testing_fixed_http_port(0), 432 testing_fixed_http_port(0),
429 testing_fixed_https_port(0), 433 testing_fixed_https_port(0),
430 enable_user_alternate_protocol_ports(false) { 434 enable_user_alternate_protocol_ports(false) {
431 } 435 }
432 436
433 IOThread::Globals::~Globals() {} 437 IOThread::Globals::~Globals() {}
434 438
435 // |local_state| is passed in explicitly in order to (1) reduce implicit 439 // |local_state| is passed in explicitly in order to (1) reduce implicit
436 // dependencies and (2) make IOThread more flexible for testing. 440 // dependencies and (2) make IOThread more flexible for testing.
437 IOThread::IOThread( 441 IOThread::IOThread(
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 if (command_line.HasSwitch(switches::kHostRules)) { 653 if (command_line.HasSwitch(switches::kHostRules)) {
650 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); 654 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString");
651 globals_->host_mapping_rules->SetRulesFromString( 655 globals_->host_mapping_rules->SetRulesFromString(
652 command_line.GetSwitchValueASCII(switches::kHostRules)); 656 command_line.GetSwitchValueASCII(switches::kHostRules));
653 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); 657 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString");
654 } 658 }
655 if (command_line.HasSwitch(switches::kEnableSSLConnectJobWaiting)) 659 if (command_line.HasSwitch(switches::kEnableSSLConnectJobWaiting))
656 globals_->enable_ssl_connect_job_waiting = true; 660 globals_->enable_ssl_connect_job_waiting = true;
657 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) 661 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors))
658 globals_->ignore_certificate_errors = true; 662 globals_->ignore_certificate_errors = true;
663 if (command_line.HasSwitch(switches::kEnableStaleWhileRevalidate))
Alexei Svitkine (slow) 2014/10/09 21:33:39 I didn't review this part earlier, but now that I
Adam Rice 2014/10/20 09:31:24 Done in https://crrev.com/665023002/
664 globals_->use_stale_while_revalidate = true;
665 if (base::FieldTrialList::FindFullName(kStaleWhileRevalidateFieldTrialName) ==
666 "Enabled")
667 globals_->use_stale_while_revalidate = true;
mmenke 2014/10/09 14:29:58 nit: Use braces when the conditional of an if sta
Adam Rice 2014/10/20 09:31:24 Indirectly fixed by change requested by asvitkine.
659 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { 668 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) {
660 globals_->testing_fixed_http_port = 669 globals_->testing_fixed_http_port =
661 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); 670 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort);
662 } 671 }
663 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { 672 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
664 globals_->testing_fixed_https_port = 673 globals_->testing_fixed_https_port =
665 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); 674 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort);
666 } 675 }
667 ConfigureQuic(command_line); 676 ConfigureQuic(command_line);
668 if (command_line.HasSwitch( 677 if (command_line.HasSwitch(
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 params->transport_security_state = globals.transport_security_state.get(); 987 params->transport_security_state = globals.transport_security_state.get();
979 params->ssl_config_service = globals.ssl_config_service.get(); 988 params->ssl_config_service = globals.ssl_config_service.get();
980 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); 989 params->http_auth_handler_factory = globals.http_auth_handler_factory.get();
981 params->http_server_properties = 990 params->http_server_properties =
982 globals.http_server_properties->GetWeakPtr(); 991 globals.http_server_properties->GetWeakPtr();
983 params->network_delegate = globals.system_network_delegate.get(); 992 params->network_delegate = globals.system_network_delegate.get();
984 params->host_mapping_rules = globals.host_mapping_rules.get(); 993 params->host_mapping_rules = globals.host_mapping_rules.get();
985 params->enable_ssl_connect_job_waiting = 994 params->enable_ssl_connect_job_waiting =
986 globals.enable_ssl_connect_job_waiting; 995 globals.enable_ssl_connect_job_waiting;
987 params->ignore_certificate_errors = globals.ignore_certificate_errors; 996 params->ignore_certificate_errors = globals.ignore_certificate_errors;
997 params->use_stale_while_revalidate = globals.use_stale_while_revalidate;
988 params->testing_fixed_http_port = globals.testing_fixed_http_port; 998 params->testing_fixed_http_port = globals.testing_fixed_http_port;
989 params->testing_fixed_https_port = globals.testing_fixed_https_port; 999 params->testing_fixed_https_port = globals.testing_fixed_https_port;
990 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( 1000 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet(
991 &params->enable_tcp_fast_open_for_ssl); 1001 &params->enable_tcp_fast_open_for_ssl);
992 1002
993 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( 1003 globals.initial_max_spdy_concurrent_streams.CopyToIfSet(
994 &params->spdy_initial_max_concurrent_streams); 1004 &params->spdy_initial_max_concurrent_streams);
995 globals.force_spdy_single_domain.CopyToIfSet( 1005 globals.force_spdy_single_domain.CopyToIfSet(
996 &params->force_spdy_single_domain); 1006 &params->force_spdy_single_domain);
997 globals.enable_spdy_compression.CopyToIfSet( 1007 globals.enable_spdy_compression.CopyToIfSet(
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1412 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1403 for (size_t i = 0; i < supported_versions.size(); ++i) { 1413 for (size_t i = 0; i < supported_versions.size(); ++i) {
1404 net::QuicVersion version = supported_versions[i]; 1414 net::QuicVersion version = supported_versions[i];
1405 if (net::QuicVersionToString(version) == quic_version) { 1415 if (net::QuicVersionToString(version) == quic_version) {
1406 return version; 1416 return version;
1407 } 1417 }
1408 } 1418 }
1409 1419
1410 return net::QUIC_VERSION_UNSUPPORTED; 1420 return net::QUIC_VERSION_UNSUPPORTED;
1411 } 1421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698