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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CommandLine& command_line) { |
| 316 const std::string group_name = |
| 317 base::FieldTrialList::FindFullName(kStaleWhileRevalidateFieldTrialName); |
| 318 if (command_line.HasSwitch(switches::kEnableStaleWhileRevalidate)) |
| 319 return true; |
| 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 Loading... |
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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1417 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1412 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1418 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1413 net::QuicVersion version = supported_versions[i]; | 1419 net::QuicVersion version = supported_versions[i]; |
1414 if (net::QuicVersionToString(version) == quic_version) { | 1420 if (net::QuicVersionToString(version) == quic_version) { |
1415 return version; | 1421 return version; |
1416 } | 1422 } |
1417 } | 1423 } |
1418 | 1424 |
1419 return net::QUIC_VERSION_UNSUPPORTED; | 1425 return net::QUIC_VERSION_UNSUPPORTED; |
1420 } | 1426 } |
OLD | NEW |