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

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

Issue 665023002: Post-commit fixes for "stale-while-revalidate..." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/net/chrome_network_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const std::string& GetVariationParam( 304 const std::string& GetVariationParam(
305 const std::map<std::string, std::string>& params, 305 const std::map<std::string, std::string>& params,
306 const std::string& key) { 306 const std::string& key) {
307 std::map<std::string, std::string>::const_iterator it = params.find(key); 307 std::map<std::string, std::string>::const_iterator it = params.find(key);
308 if (it == params.end()) 308 if (it == params.end())
309 return base::EmptyString(); 309 return base::EmptyString();
310 310
311 return it->second; 311 return it->second;
312 } 312 }
313 313
314 // Return true if stale-while-revalidate support should be enabled.
315 bool IsStaleWhileRevalidateEnabled(const base::CommandLine& command_line) {
316 if (command_line.HasSwitch(switches::kEnableStaleWhileRevalidate))
317 return true;
318 const std::string group_name =
319 base::FieldTrialList::FindFullName(kStaleWhileRevalidateFieldTrialName);
320 return group_name == "Enabled";
321 }
322
314 } // namespace 323 } // namespace
315 324
316 class IOThread::LoggingNetworkChangeObserver 325 class IOThread::LoggingNetworkChangeObserver
317 : public net::NetworkChangeNotifier::IPAddressObserver, 326 : public net::NetworkChangeNotifier::IPAddressObserver,
318 public net::NetworkChangeNotifier::ConnectionTypeObserver, 327 public net::NetworkChangeNotifier::ConnectionTypeObserver,
319 public net::NetworkChangeNotifier::NetworkChangeObserver { 328 public net::NetworkChangeNotifier::NetworkChangeObserver {
320 public: 329 public:
321 // |net_log| must remain valid throughout our lifetime. 330 // |net_log| must remain valid throughout our lifetime.
322 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) 331 explicit LoggingNetworkChangeObserver(net::NetLog* net_log)
323 : net_log_(net_log) { 332 : net_log_(net_log) {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 if (command_line.HasSwitch(switches::kHostRules)) { 662 if (command_line.HasSwitch(switches::kHostRules)) {
654 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); 663 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString");
655 globals_->host_mapping_rules->SetRulesFromString( 664 globals_->host_mapping_rules->SetRulesFromString(
656 command_line.GetSwitchValueASCII(switches::kHostRules)); 665 command_line.GetSwitchValueASCII(switches::kHostRules));
657 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); 666 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString");
658 } 667 }
659 if (command_line.HasSwitch(switches::kEnableSSLConnectJobWaiting)) 668 if (command_line.HasSwitch(switches::kEnableSSLConnectJobWaiting))
660 globals_->enable_ssl_connect_job_waiting = true; 669 globals_->enable_ssl_connect_job_waiting = true;
661 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) 670 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors))
662 globals_->ignore_certificate_errors = true; 671 globals_->ignore_certificate_errors = true;
663 if (command_line.HasSwitch(switches::kEnableStaleWhileRevalidate)) 672 globals_->use_stale_while_revalidate =
664 globals_->use_stale_while_revalidate = true; 673 IsStaleWhileRevalidateEnabled(command_line);
665 if (base::FieldTrialList::FindFullName(kStaleWhileRevalidateFieldTrialName) ==
666 "Enabled")
667 globals_->use_stale_while_revalidate = true;
668 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { 674 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) {
669 globals_->testing_fixed_http_port = 675 globals_->testing_fixed_http_port =
670 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); 676 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort);
671 } 677 }
672 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { 678 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
673 globals_->testing_fixed_https_port = 679 globals_->testing_fixed_https_port =
674 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); 680 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort);
675 } 681 }
676 ConfigureQuic(command_line); 682 ConfigureQuic(command_line);
677 if (command_line.HasSwitch( 683 if (command_line.HasSwitch(
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1438 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1433 for (size_t i = 0; i < supported_versions.size(); ++i) { 1439 for (size_t i = 0; i < supported_versions.size(); ++i) {
1434 net::QuicVersion version = supported_versions[i]; 1440 net::QuicVersion version = supported_versions[i];
1435 if (net::QuicVersionToString(version) == quic_version) { 1441 if (net::QuicVersionToString(version) == quic_version) {
1436 return version; 1442 return version;
1437 } 1443 }
1438 } 1444 }
1439 1445
1440 return net::QUIC_VERSION_UNSUPPORTED; 1446 return net::QUIC_VERSION_UNSUPPORTED;
1441 } 1447 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/chrome_network_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698