Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 561 | 562 |
| 562 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 563 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
| 563 local_state); | 564 local_state); |
| 564 quick_check_enabled_.MoveToThread( | 565 quick_check_enabled_.MoveToThread( |
| 565 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 566 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 566 | 567 |
| 567 #if defined(ENABLE_CONFIGURATION_POLICY) | 568 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 568 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 569 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
| 569 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 570 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
| 570 policy::key::kDisableSpdy) != NULL; | 571 policy::key::kDisableSpdy) != NULL; |
| 572 | |
| 573 const base::Value* value = policy_service->GetPolicies( | |
| 574 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | |
| 575 std::string())).GetValue(policy::key::kQuicAllowed); | |
|
Andrew T Wilson (Slow)
2015/04/14 17:48:47
This line is mis-indented (should be indented anot
peletskyi
2015/04/27 11:05:50
Done.
| |
| 576 if (value) | |
| 577 value->GetAsBoolean(&is_quic_allowed_by_policy_); | |
| 571 #endif // ENABLE_CONFIGURATION_POLICY | 578 #endif // ENABLE_CONFIGURATION_POLICY |
| 572 | 579 |
| 573 BrowserThread::SetDelegate(BrowserThread::IO, this); | 580 BrowserThread::SetDelegate(BrowserThread::IO, this); |
| 574 } | 581 } |
| 575 | 582 |
| 576 IOThread::~IOThread() { | 583 IOThread::~IOThread() { |
| 577 // This isn't needed for production code, but in tests, IOThread may | 584 // This isn't needed for production code, but in tests, IOThread may |
| 578 // be multiply constructed. | 585 // be multiply constructed. |
| 579 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 586 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
| 580 | 587 |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1275 // Always fetch the field trial group to ensure it is reported correctly. | 1282 // Always fetch the field trial group to ensure it is reported correctly. |
| 1276 // The command line flags will be associated with a group that is reported | 1283 // The command line flags will be associated with a group that is reported |
| 1277 // so long as trial is actually queried. | 1284 // so long as trial is actually queried. |
| 1278 std::string group = | 1285 std::string group = |
| 1279 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1286 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
| 1280 VariationParameters params; | 1287 VariationParameters params; |
| 1281 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1288 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
| 1282 params.clear(); | 1289 params.clear(); |
| 1283 } | 1290 } |
| 1284 | 1291 |
| 1285 ConfigureQuicGlobals(command_line, group, params, globals_); | 1292 ConfigureQuicGlobals(command_line, group, params, is_quic_allowed_by_policy_, |
| 1293 globals_); | |
| 1286 } | 1294 } |
| 1287 | 1295 |
| 1288 // static | 1296 // static |
| 1289 void IOThread::ConfigureQuicGlobals( | 1297 void IOThread::ConfigureQuicGlobals( |
| 1290 const base::CommandLine& command_line, | 1298 const base::CommandLine& command_line, |
| 1291 base::StringPiece quic_trial_group, | 1299 base::StringPiece quic_trial_group, |
| 1292 const VariationParameters& quic_trial_params, | 1300 const VariationParameters& quic_trial_params, |
| 1301 bool quic_allowed_by_policy, | |
| 1293 IOThread::Globals* globals) { | 1302 IOThread::Globals* globals) { |
| 1294 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1303 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group, |
| 1304 quic_allowed_by_policy); | |
| 1295 globals->enable_quic.set(enable_quic); | 1305 globals->enable_quic.set(enable_quic); |
| 1296 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(command_line, | 1306 bool enable_quic_for_proxies = ShouldEnableQuicForProxies( |
| 1297 quic_trial_group); | 1307 command_line, quic_trial_group, quic_allowed_by_policy); |
| 1298 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); | 1308 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); |
| 1299 if (enable_quic) { | 1309 if (enable_quic) { |
| 1300 globals->quic_always_require_handshake_confirmation.set( | 1310 globals->quic_always_require_handshake_confirmation.set( |
| 1301 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); | 1311 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); |
| 1302 globals->quic_disable_connection_pooling.set( | 1312 globals->quic_disable_connection_pooling.set( |
| 1303 ShouldQuicDisableConnectionPooling(quic_trial_params)); | 1313 ShouldQuicDisableConnectionPooling(quic_trial_params)); |
| 1304 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); | 1314 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); |
| 1305 if (receive_buffer_size != 0) { | 1315 if (receive_buffer_size != 0) { |
| 1306 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); | 1316 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); |
| 1307 } | 1317 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1368 net::HostPortPair quic_origin = | 1378 net::HostPortPair quic_origin = |
| 1369 net::HostPortPair::FromString( | 1379 net::HostPortPair::FromString( |
| 1370 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); | 1380 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); |
| 1371 if (!quic_origin.IsEmpty()) { | 1381 if (!quic_origin.IsEmpty()) { |
| 1372 globals->origin_to_force_quic_on.set(quic_origin); | 1382 globals->origin_to_force_quic_on.set(quic_origin); |
| 1373 } | 1383 } |
| 1374 } | 1384 } |
| 1375 } | 1385 } |
| 1376 | 1386 |
| 1377 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, | 1387 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, |
| 1378 base::StringPiece quic_trial_group) { | 1388 base::StringPiece quic_trial_group, |
| 1379 if (command_line.HasSwitch(switches::kDisableQuic)) | 1389 bool quic_allowed_by_policy) { |
| 1390 if (command_line.HasSwitch(switches::kDisableQuic) || !quic_allowed_by_policy) | |
| 1380 return false; | 1391 return false; |
| 1381 | 1392 |
| 1382 if (command_line.HasSwitch(switches::kEnableQuic)) | 1393 if (command_line.HasSwitch(switches::kEnableQuic)) |
| 1383 return true; | 1394 return true; |
| 1384 | 1395 |
| 1385 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || | 1396 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || |
| 1386 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); | 1397 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); |
| 1387 } | 1398 } |
| 1388 | 1399 |
| 1389 // static | 1400 // static |
| 1390 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, | 1401 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, |
| 1391 base::StringPiece quic_trial_group) { | 1402 base::StringPiece quic_trial_group, |
| 1392 return ShouldEnableQuic(command_line, quic_trial_group) || | 1403 bool quic_allowed_by_policy) { |
| 1404 return ShouldEnableQuic( | |
| 1405 command_line, quic_trial_group, quic_allowed_by_policy) || | |
| 1393 ShouldEnableQuicForDataReductionProxy(); | 1406 ShouldEnableQuicForDataReductionProxy(); |
| 1394 } | 1407 } |
| 1395 | 1408 |
| 1396 // static | 1409 // static |
| 1397 bool IOThread::ShouldEnableQuicForDataReductionProxy() { | 1410 bool IOThread::ShouldEnableQuicForDataReductionProxy() { |
| 1398 const base::CommandLine& command_line = | 1411 const base::CommandLine& command_line = |
| 1399 *base::CommandLine::ForCurrentProcess(); | 1412 *base::CommandLine::ForCurrentProcess(); |
| 1400 | 1413 |
| 1401 if (command_line.HasSwitch(switches::kDisableQuic)) | 1414 if (command_line.HasSwitch(switches::kDisableQuic)) |
| 1402 return false; | 1415 return false; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1601 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1614 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1602 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1615 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1603 net::QuicVersion version = supported_versions[i]; | 1616 net::QuicVersion version = supported_versions[i]; |
| 1604 if (net::QuicVersionToString(version) == quic_version) { | 1617 if (net::QuicVersionToString(version) == quic_version) { |
| 1605 return version; | 1618 return version; |
| 1606 } | 1619 } |
| 1607 } | 1620 } |
| 1608 | 1621 |
| 1609 return net::QUIC_VERSION_UNSUPPORTED; | 1622 return net::QUIC_VERSION_UNSUPPORTED; |
| 1610 } | 1623 } |
| OLD | NEW |