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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 PrefService* local_state, | 449 PrefService* local_state, |
450 policy::PolicyService* policy_service, | 450 policy::PolicyService* policy_service, |
451 ChromeNetLog* net_log, | 451 ChromeNetLog* net_log, |
452 extensions::EventRouterForwarder* extension_event_router_forwarder) | 452 extensions::EventRouterForwarder* extension_event_router_forwarder) |
453 : net_log_(net_log), | 453 : net_log_(net_log), |
454 #if defined(ENABLE_EXTENSIONS) | 454 #if defined(ENABLE_EXTENSIONS) |
455 extension_event_router_forwarder_(extension_event_router_forwarder), | 455 extension_event_router_forwarder_(extension_event_router_forwarder), |
456 #endif | 456 #endif |
457 globals_(NULL), | 457 globals_(NULL), |
458 is_spdy_disabled_by_policy_(false), | 458 is_spdy_disabled_by_policy_(false), |
| 459 is_quic_allowed_by_policy_(true), |
459 creation_time_(base::TimeTicks::Now()), | 460 creation_time_(base::TimeTicks::Now()), |
460 weak_factory_(this) { | 461 weak_factory_(this) { |
461 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 462 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
462 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 463 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
463 prefs::kDisableAuthNegotiateCnameLookup); | 464 prefs::kDisableAuthNegotiateCnameLookup); |
464 negotiate_enable_port_ = local_state->GetBoolean( | 465 negotiate_enable_port_ = local_state->GetBoolean( |
465 prefs::kEnableAuthNegotiatePort); | 466 prefs::kEnableAuthNegotiatePort); |
466 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 467 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
467 auth_delegate_whitelist_ = local_state->GetString( | 468 auth_delegate_whitelist_ = local_state->GetString( |
468 prefs::kAuthNegotiateDelegateWhitelist); | 469 prefs::kAuthNegotiateDelegateWhitelist); |
(...skipping 27 matching lines...) Expand all Loading... |
496 | 497 |
497 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 498 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
498 local_state); | 499 local_state); |
499 quick_check_enabled_.MoveToThread( | 500 quick_check_enabled_.MoveToThread( |
500 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 501 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
501 | 502 |
502 #if defined(ENABLE_CONFIGURATION_POLICY) | 503 #if defined(ENABLE_CONFIGURATION_POLICY) |
503 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 504 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
504 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 505 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
505 policy::key::kDisableSpdy) != NULL; | 506 policy::key::kDisableSpdy) != NULL; |
| 507 |
| 508 const base::Value* value = policy_service->GetPolicies( |
| 509 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 510 std::string())).GetValue(policy::key::kQuicAllowed); |
| 511 if (value) |
| 512 value->GetAsBoolean(&is_quic_allowed_by_policy_); |
506 #endif // ENABLE_CONFIGURATION_POLICY | 513 #endif // ENABLE_CONFIGURATION_POLICY |
507 | 514 |
508 BrowserThread::SetDelegate(BrowserThread::IO, this); | 515 BrowserThread::SetDelegate(BrowserThread::IO, this); |
509 } | 516 } |
510 | 517 |
511 IOThread::~IOThread() { | 518 IOThread::~IOThread() { |
512 // This isn't needed for production code, but in tests, IOThread may | 519 // This isn't needed for production code, but in tests, IOThread may |
513 // be multiply constructed. | 520 // be multiply constructed. |
514 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 521 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
515 | 522 |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 // Always fetch the field trial group to ensure it is reported correctly. | 1228 // Always fetch the field trial group to ensure it is reported correctly. |
1222 // The command line flags will be associated with a group that is reported | 1229 // The command line flags will be associated with a group that is reported |
1223 // so long as trial is actually queried. | 1230 // so long as trial is actually queried. |
1224 std::string group = | 1231 std::string group = |
1225 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1232 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
1226 VariationParameters params; | 1233 VariationParameters params; |
1227 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1234 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
1228 params.clear(); | 1235 params.clear(); |
1229 } | 1236 } |
1230 | 1237 |
1231 ConfigureQuicGlobals(command_line, group, params, globals_); | 1238 ConfigureQuicGlobals(command_line, group, params, is_quic_allowed_by_policy_, |
| 1239 globals_); |
1232 } | 1240 } |
1233 | 1241 |
1234 // static | 1242 // static |
1235 void IOThread::ConfigureQuicGlobals( | 1243 void IOThread::ConfigureQuicGlobals( |
1236 const base::CommandLine& command_line, | 1244 const base::CommandLine& command_line, |
1237 base::StringPiece quic_trial_group, | 1245 base::StringPiece quic_trial_group, |
1238 const VariationParameters& quic_trial_params, | 1246 const VariationParameters& quic_trial_params, |
| 1247 bool quic_allowed_by_policy, |
1239 IOThread::Globals* globals) { | 1248 IOThread::Globals* globals) { |
1240 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1249 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group, |
| 1250 quic_allowed_by_policy); |
1241 globals->enable_quic.set(enable_quic); | 1251 globals->enable_quic.set(enable_quic); |
1242 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(command_line, | 1252 bool enable_quic_for_proxies = ShouldEnableQuicForProxies( |
1243 quic_trial_group); | 1253 command_line, quic_trial_group, quic_allowed_by_policy); |
1244 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); | 1254 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); |
1245 if (enable_quic) { | 1255 if (enable_quic) { |
1246 globals->quic_always_require_handshake_confirmation.set( | 1256 globals->quic_always_require_handshake_confirmation.set( |
1247 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); | 1257 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); |
1248 globals->quic_disable_connection_pooling.set( | 1258 globals->quic_disable_connection_pooling.set( |
1249 ShouldQuicDisableConnectionPooling(quic_trial_params)); | 1259 ShouldQuicDisableConnectionPooling(quic_trial_params)); |
1250 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); | 1260 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); |
1251 if (receive_buffer_size != 0) { | 1261 if (receive_buffer_size != 0) { |
1252 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); | 1262 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); |
1253 } | 1263 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 net::HostPortPair quic_origin = | 1315 net::HostPortPair quic_origin = |
1306 net::HostPortPair::FromString( | 1316 net::HostPortPair::FromString( |
1307 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); | 1317 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); |
1308 if (!quic_origin.IsEmpty()) { | 1318 if (!quic_origin.IsEmpty()) { |
1309 globals->origin_to_force_quic_on.set(quic_origin); | 1319 globals->origin_to_force_quic_on.set(quic_origin); |
1310 } | 1320 } |
1311 } | 1321 } |
1312 } | 1322 } |
1313 | 1323 |
1314 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, | 1324 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, |
1315 base::StringPiece quic_trial_group) { | 1325 base::StringPiece quic_trial_group, |
1316 if (command_line.HasSwitch(switches::kDisableQuic)) | 1326 bool quic_allowed_by_policy) { |
| 1327 if (command_line.HasSwitch(switches::kDisableQuic) || !quic_allowed_by_policy) |
1317 return false; | 1328 return false; |
1318 | 1329 |
1319 if (command_line.HasSwitch(switches::kEnableQuic)) | 1330 if (command_line.HasSwitch(switches::kEnableQuic)) |
1320 return true; | 1331 return true; |
1321 | 1332 |
1322 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || | 1333 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || |
1323 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); | 1334 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); |
1324 } | 1335 } |
1325 | 1336 |
1326 // static | 1337 // static |
1327 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, | 1338 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, |
1328 base::StringPiece quic_trial_group) { | 1339 base::StringPiece quic_trial_group, |
1329 return ShouldEnableQuic(command_line, quic_trial_group) || | 1340 bool quic_allowed_by_policy) { |
| 1341 return ShouldEnableQuic( |
| 1342 command_line, quic_trial_group, quic_allowed_by_policy) || |
1330 ShouldEnableQuicForDataReductionProxy(); | 1343 ShouldEnableQuicForDataReductionProxy(); |
1331 } | 1344 } |
1332 | 1345 |
1333 // static | 1346 // static |
1334 bool IOThread::ShouldEnableQuicForDataReductionProxy() { | 1347 bool IOThread::ShouldEnableQuicForDataReductionProxy() { |
1335 const base::CommandLine& command_line = | 1348 const base::CommandLine& command_line = |
1336 *base::CommandLine::ForCurrentProcess(); | 1349 *base::CommandLine::ForCurrentProcess(); |
1337 | 1350 |
1338 if (command_line.HasSwitch(switches::kDisableQuic)) | 1351 if (command_line.HasSwitch(switches::kDisableQuic)) |
1339 return false; | 1352 return false; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1527 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1515 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1528 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1516 net::QuicVersion version = supported_versions[i]; | 1529 net::QuicVersion version = supported_versions[i]; |
1517 if (net::QuicVersionToString(version) == quic_version) { | 1530 if (net::QuicVersionToString(version) == quic_version) { |
1518 return version; | 1531 return version; |
1519 } | 1532 } |
1520 } | 1533 } |
1521 | 1534 |
1522 return net::QUIC_VERSION_UNSUPPORTED; | 1535 return net::QUIC_VERSION_UNSUPPORTED; |
1523 } | 1536 } |
OLD | NEW |