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

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

Issue 1124583007: Added QuicAllowed policy. Added unit and browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: Created 5 years, 7 months 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 | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_unittest.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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 PrefService* local_state, 538 PrefService* local_state,
539 policy::PolicyService* policy_service, 539 policy::PolicyService* policy_service,
540 ChromeNetLog* net_log, 540 ChromeNetLog* net_log,
541 extensions::EventRouterForwarder* extension_event_router_forwarder) 541 extensions::EventRouterForwarder* extension_event_router_forwarder)
542 : net_log_(net_log), 542 : net_log_(net_log),
543 #if defined(ENABLE_EXTENSIONS) 543 #if defined(ENABLE_EXTENSIONS)
544 extension_event_router_forwarder_(extension_event_router_forwarder), 544 extension_event_router_forwarder_(extension_event_router_forwarder),
545 #endif 545 #endif
546 globals_(NULL), 546 globals_(NULL),
547 is_spdy_disabled_by_policy_(false), 547 is_spdy_disabled_by_policy_(false),
548 is_quic_allowed_by_policy_(true),
548 creation_time_(base::TimeTicks::Now()), 549 creation_time_(base::TimeTicks::Now()),
549 weak_factory_(this) { 550 weak_factory_(this) {
550 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); 551 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes);
551 negotiate_disable_cname_lookup_ = local_state->GetBoolean( 552 negotiate_disable_cname_lookup_ = local_state->GetBoolean(
552 prefs::kDisableAuthNegotiateCnameLookup); 553 prefs::kDisableAuthNegotiateCnameLookup);
553 negotiate_enable_port_ = local_state->GetBoolean( 554 negotiate_enable_port_ = local_state->GetBoolean(
554 prefs::kEnableAuthNegotiatePort); 555 prefs::kEnableAuthNegotiatePort);
555 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); 556 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist);
556 auth_delegate_whitelist_ = local_state->GetString( 557 auth_delegate_whitelist_ = local_state->GetString(
557 prefs::kAuthNegotiateDelegateWhitelist); 558 prefs::kAuthNegotiateDelegateWhitelist);
(...skipping 27 matching lines...) Expand all
585 586
586 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, 587 quick_check_enabled_.Init(prefs::kQuickCheckEnabled,
587 local_state); 588 local_state);
588 quick_check_enabled_.MoveToThread( 589 quick_check_enabled_.MoveToThread(
589 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 590 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
590 591
591 #if defined(ENABLE_CONFIGURATION_POLICY) 592 #if defined(ENABLE_CONFIGURATION_POLICY)
592 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( 593 is_spdy_disabled_by_policy_ = policy_service->GetPolicies(
593 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( 594 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get(
594 policy::key::kDisableSpdy) != NULL; 595 policy::key::kDisableSpdy) != NULL;
596
597 const base::Value* value = policy_service->GetPolicies(
598 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME,
599 std::string())).GetValue(policy::key::kQuicAllowed);
600 if (value)
601 value->GetAsBoolean(&is_quic_allowed_by_policy_);
595 #endif // ENABLE_CONFIGURATION_POLICY 602 #endif // ENABLE_CONFIGURATION_POLICY
596 603
597 BrowserThread::SetDelegate(BrowserThread::IO, this); 604 BrowserThread::SetDelegate(BrowserThread::IO, this);
598 } 605 }
599 606
600 IOThread::~IOThread() { 607 IOThread::~IOThread() {
601 // This isn't needed for production code, but in tests, IOThread may 608 // This isn't needed for production code, but in tests, IOThread may
602 // be multiply constructed. 609 // be multiply constructed.
603 BrowserThread::SetDelegate(BrowserThread::IO, NULL); 610 BrowserThread::SetDelegate(BrowserThread::IO, NULL);
604 611
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 // Always fetch the field trial group to ensure it is reported correctly. 1310 // Always fetch the field trial group to ensure it is reported correctly.
1304 // The command line flags will be associated with a group that is reported 1311 // The command line flags will be associated with a group that is reported
1305 // so long as trial is actually queried. 1312 // so long as trial is actually queried.
1306 std::string group = 1313 std::string group =
1307 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 1314 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
1308 VariationParameters params; 1315 VariationParameters params;
1309 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) { 1316 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) {
1310 params.clear(); 1317 params.clear();
1311 } 1318 }
1312 1319
1313 ConfigureQuicGlobals(command_line, group, params, globals_); 1320 ConfigureQuicGlobals(command_line, group, params, is_quic_allowed_by_policy_,
1321 globals_);
1314 } 1322 }
1315 1323
1316 // static 1324 // static
1317 void IOThread::ConfigureQuicGlobals( 1325 void IOThread::ConfigureQuicGlobals(
1318 const base::CommandLine& command_line, 1326 const base::CommandLine& command_line,
1319 base::StringPiece quic_trial_group, 1327 base::StringPiece quic_trial_group,
1320 const VariationParameters& quic_trial_params, 1328 const VariationParameters& quic_trial_params,
1329 bool quic_allowed_by_policy,
1321 IOThread::Globals* globals) { 1330 IOThread::Globals* globals) {
1322 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); 1331 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group,
1332 quic_allowed_by_policy);
1323 globals->enable_quic.set(enable_quic); 1333 globals->enable_quic.set(enable_quic);
1324 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(command_line, 1334 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(
1325 quic_trial_group); 1335 command_line, quic_trial_group, quic_allowed_by_policy);
1326 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); 1336 globals->enable_quic_for_proxies.set(enable_quic_for_proxies);
1327 if (enable_quic) { 1337 if (enable_quic) {
1328 globals->quic_always_require_handshake_confirmation.set( 1338 globals->quic_always_require_handshake_confirmation.set(
1329 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); 1339 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params));
1330 globals->quic_disable_connection_pooling.set( 1340 globals->quic_disable_connection_pooling.set(
1331 ShouldQuicDisableConnectionPooling(quic_trial_params)); 1341 ShouldQuicDisableConnectionPooling(quic_trial_params));
1332 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); 1342 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params);
1333 if (receive_buffer_size != 0) { 1343 if (receive_buffer_size != 0) {
1334 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); 1344 globals->quic_socket_receive_buffer_size.set(receive_buffer_size);
1335 } 1345 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 net::HostPortPair quic_origin = 1406 net::HostPortPair quic_origin =
1397 net::HostPortPair::FromString( 1407 net::HostPortPair::FromString(
1398 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); 1408 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn));
1399 if (!quic_origin.IsEmpty()) { 1409 if (!quic_origin.IsEmpty()) {
1400 globals->origin_to_force_quic_on.set(quic_origin); 1410 globals->origin_to_force_quic_on.set(quic_origin);
1401 } 1411 }
1402 } 1412 }
1403 } 1413 }
1404 1414
1405 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, 1415 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line,
1406 base::StringPiece quic_trial_group) { 1416 base::StringPiece quic_trial_group,
1407 if (command_line.HasSwitch(switches::kDisableQuic)) 1417 bool quic_allowed_by_policy) {
1418 if (command_line.HasSwitch(switches::kDisableQuic) || !quic_allowed_by_policy)
1408 return false; 1419 return false;
1409 1420
1410 if (command_line.HasSwitch(switches::kEnableQuic)) 1421 if (command_line.HasSwitch(switches::kEnableQuic))
1411 return true; 1422 return true;
1412 1423
1413 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || 1424 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) ||
1414 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); 1425 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName);
1415 } 1426 }
1416 1427
1417 // static 1428 // static
1418 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, 1429 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line,
1419 base::StringPiece quic_trial_group) { 1430 base::StringPiece quic_trial_group,
1420 return ShouldEnableQuic(command_line, quic_trial_group) || 1431 bool quic_allowed_by_policy) {
1432 return ShouldEnableQuic(
1433 command_line, quic_trial_group, quic_allowed_by_policy) ||
1421 ShouldEnableQuicForDataReductionProxy(); 1434 ShouldEnableQuicForDataReductionProxy();
1422 } 1435 }
1423 1436
1424 // static 1437 // static
1425 bool IOThread::ShouldEnableQuicForDataReductionProxy() { 1438 bool IOThread::ShouldEnableQuicForDataReductionProxy() {
1426 const base::CommandLine& command_line = 1439 const base::CommandLine& command_line =
1427 *base::CommandLine::ForCurrentProcess(); 1440 *base::CommandLine::ForCurrentProcess();
1428 1441
1429 if (command_line.HasSwitch(switches::kDisableQuic)) 1442 if (command_line.HasSwitch(switches::kDisableQuic))
1430 return false; 1443 return false;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1642 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1630 for (size_t i = 0; i < supported_versions.size(); ++i) { 1643 for (size_t i = 0; i < supported_versions.size(); ++i) {
1631 net::QuicVersion version = supported_versions[i]; 1644 net::QuicVersion version = supported_versions[i];
1632 if (net::QuicVersionToString(version) == quic_version) { 1645 if (net::QuicVersionToString(version) == quic_version) {
1633 return version; 1646 return version;
1634 } 1647 }
1635 } 1648 }
1636 1649
1637 return net::QUIC_VERSION_UNSUPPORTED; 1650 return net::QUIC_VERSION_UNSUPPORTED;
1638 } 1651 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698