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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 PrefService* local_state, | 514 PrefService* local_state, |
515 policy::PolicyService* policy_service, | 515 policy::PolicyService* policy_service, |
516 ChromeNetLog* net_log, | 516 ChromeNetLog* net_log, |
517 extensions::EventRouterForwarder* extension_event_router_forwarder) | 517 extensions::EventRouterForwarder* extension_event_router_forwarder) |
518 : net_log_(net_log), | 518 : net_log_(net_log), |
519 #if defined(ENABLE_EXTENSIONS) | 519 #if defined(ENABLE_EXTENSIONS) |
520 extension_event_router_forwarder_(extension_event_router_forwarder), | 520 extension_event_router_forwarder_(extension_event_router_forwarder), |
521 #endif | 521 #endif |
522 globals_(NULL), | 522 globals_(NULL), |
523 is_spdy_disabled_by_policy_(false), | 523 is_spdy_disabled_by_policy_(false), |
| 524 is_quic_allowed_by_policy_(true), |
524 creation_time_(base::TimeTicks::Now()), | 525 creation_time_(base::TimeTicks::Now()), |
525 weak_factory_(this) { | 526 weak_factory_(this) { |
526 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 527 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
527 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 528 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
528 prefs::kDisableAuthNegotiateCnameLookup); | 529 prefs::kDisableAuthNegotiateCnameLookup); |
529 negotiate_enable_port_ = local_state->GetBoolean( | 530 negotiate_enable_port_ = local_state->GetBoolean( |
530 prefs::kEnableAuthNegotiatePort); | 531 prefs::kEnableAuthNegotiatePort); |
531 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 532 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
532 auth_delegate_whitelist_ = local_state->GetString( | 533 auth_delegate_whitelist_ = local_state->GetString( |
533 prefs::kAuthNegotiateDelegateWhitelist); | 534 prefs::kAuthNegotiateDelegateWhitelist); |
(...skipping 26 matching lines...) Expand all Loading... |
560 | 561 |
561 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 562 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
562 local_state); | 563 local_state); |
563 quick_check_enabled_.MoveToThread( | 564 quick_check_enabled_.MoveToThread( |
564 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 565 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
565 | 566 |
566 #if defined(ENABLE_CONFIGURATION_POLICY) | 567 #if defined(ENABLE_CONFIGURATION_POLICY) |
567 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 568 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
568 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 569 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
569 policy::key::kDisableSpdy) != NULL; | 570 policy::key::kDisableSpdy) != NULL; |
| 571 |
| 572 const base::Value* value = policy_service->GetPolicies( |
| 573 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 574 std::string())).GetValue(policy::key::kQuicAllowed); |
| 575 if (value) |
| 576 value->GetAsBoolean(&is_quic_allowed_by_policy_); |
570 #endif // ENABLE_CONFIGURATION_POLICY | 577 #endif // ENABLE_CONFIGURATION_POLICY |
571 | 578 |
572 BrowserThread::SetDelegate(BrowserThread::IO, this); | 579 BrowserThread::SetDelegate(BrowserThread::IO, this); |
573 } | 580 } |
574 | 581 |
575 IOThread::~IOThread() { | 582 IOThread::~IOThread() { |
576 // This isn't needed for production code, but in tests, IOThread may | 583 // This isn't needed for production code, but in tests, IOThread may |
577 // be multiply constructed. | 584 // be multiply constructed. |
578 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 585 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
579 | 586 |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 // Always fetch the field trial group to ensure it is reported correctly. | 1306 // Always fetch the field trial group to ensure it is reported correctly. |
1300 // The command line flags will be associated with a group that is reported | 1307 // The command line flags will be associated with a group that is reported |
1301 // so long as trial is actually queried. | 1308 // so long as trial is actually queried. |
1302 std::string group = | 1309 std::string group = |
1303 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1310 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
1304 VariationParameters params; | 1311 VariationParameters params; |
1305 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1312 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
1306 params.clear(); | 1313 params.clear(); |
1307 } | 1314 } |
1308 | 1315 |
1309 ConfigureQuicGlobals(command_line, group, params, globals_); | 1316 ConfigureQuicGlobals(command_line, group, params, is_quic_allowed_by_policy_, |
| 1317 globals_); |
1310 } | 1318 } |
1311 | 1319 |
1312 // static | 1320 // static |
1313 void IOThread::ConfigureQuicGlobals( | 1321 void IOThread::ConfigureQuicGlobals( |
1314 const base::CommandLine& command_line, | 1322 const base::CommandLine& command_line, |
1315 base::StringPiece quic_trial_group, | 1323 base::StringPiece quic_trial_group, |
1316 const VariationParameters& quic_trial_params, | 1324 const VariationParameters& quic_trial_params, |
| 1325 bool quic_allowed_by_policy, |
1317 IOThread::Globals* globals) { | 1326 IOThread::Globals* globals) { |
1318 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1327 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group, |
| 1328 quic_allowed_by_policy); |
1319 globals->enable_quic.set(enable_quic); | 1329 globals->enable_quic.set(enable_quic); |
1320 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(command_line, | 1330 bool enable_quic_for_proxies = ShouldEnableQuicForProxies( |
1321 quic_trial_group); | 1331 command_line, quic_trial_group, quic_allowed_by_policy); |
1322 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); | 1332 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); |
1323 if (enable_quic) { | 1333 if (enable_quic) { |
1324 globals->quic_always_require_handshake_confirmation.set( | 1334 globals->quic_always_require_handshake_confirmation.set( |
1325 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); | 1335 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); |
1326 globals->quic_disable_connection_pooling.set( | 1336 globals->quic_disable_connection_pooling.set( |
1327 ShouldQuicDisableConnectionPooling(quic_trial_params)); | 1337 ShouldQuicDisableConnectionPooling(quic_trial_params)); |
1328 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); | 1338 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); |
1329 if (receive_buffer_size != 0) { | 1339 if (receive_buffer_size != 0) { |
1330 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); | 1340 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); |
1331 } | 1341 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 net::HostPortPair quic_origin = | 1402 net::HostPortPair quic_origin = |
1393 net::HostPortPair::FromString( | 1403 net::HostPortPair::FromString( |
1394 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); | 1404 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); |
1395 if (!quic_origin.IsEmpty()) { | 1405 if (!quic_origin.IsEmpty()) { |
1396 globals->origin_to_force_quic_on.set(quic_origin); | 1406 globals->origin_to_force_quic_on.set(quic_origin); |
1397 } | 1407 } |
1398 } | 1408 } |
1399 } | 1409 } |
1400 | 1410 |
1401 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, | 1411 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, |
1402 base::StringPiece quic_trial_group) { | 1412 base::StringPiece quic_trial_group, |
1403 if (command_line.HasSwitch(switches::kDisableQuic)) | 1413 bool quic_allowed_by_policy) { |
| 1414 if (command_line.HasSwitch(switches::kDisableQuic) || !quic_allowed_by_policy) |
1404 return false; | 1415 return false; |
1405 | 1416 |
1406 if (command_line.HasSwitch(switches::kEnableQuic)) | 1417 if (command_line.HasSwitch(switches::kEnableQuic)) |
1407 return true; | 1418 return true; |
1408 | 1419 |
1409 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || | 1420 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || |
1410 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); | 1421 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); |
1411 } | 1422 } |
1412 | 1423 |
1413 // static | 1424 // static |
1414 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, | 1425 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, |
1415 base::StringPiece quic_trial_group) { | 1426 base::StringPiece quic_trial_group, |
1416 return ShouldEnableQuic(command_line, quic_trial_group) || | 1427 bool quic_allowed_by_policy) { |
| 1428 return ShouldEnableQuic( |
| 1429 command_line, quic_trial_group, quic_allowed_by_policy) || |
1417 ShouldEnableQuicForDataReductionProxy(); | 1430 ShouldEnableQuicForDataReductionProxy(); |
1418 } | 1431 } |
1419 | 1432 |
1420 // static | 1433 // static |
1421 bool IOThread::ShouldEnableQuicForDataReductionProxy() { | 1434 bool IOThread::ShouldEnableQuicForDataReductionProxy() { |
1422 const base::CommandLine& command_line = | 1435 const base::CommandLine& command_line = |
1423 *base::CommandLine::ForCurrentProcess(); | 1436 *base::CommandLine::ForCurrentProcess(); |
1424 | 1437 |
1425 if (command_line.HasSwitch(switches::kDisableQuic)) | 1438 if (command_line.HasSwitch(switches::kDisableQuic)) |
1426 return false; | 1439 return false; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1638 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1626 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1639 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1627 net::QuicVersion version = supported_versions[i]; | 1640 net::QuicVersion version = supported_versions[i]; |
1628 if (net::QuicVersionToString(version) == quic_version) { | 1641 if (net::QuicVersionToString(version) == quic_version) { |
1629 return version; | 1642 return version; |
1630 } | 1643 } |
1631 } | 1644 } |
1632 | 1645 |
1633 return net::QUIC_VERSION_UNSUPPORTED; | 1646 return net::QUIC_VERSION_UNSUPPORTED; |
1634 } | 1647 } |
OLD | NEW |