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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 PrefService* local_state, | 451 PrefService* local_state, |
452 policy::PolicyService* policy_service, | 452 policy::PolicyService* policy_service, |
453 ChromeNetLog* net_log, | 453 ChromeNetLog* net_log, |
454 extensions::EventRouterForwarder* extension_event_router_forwarder) | 454 extensions::EventRouterForwarder* extension_event_router_forwarder) |
455 : net_log_(net_log), | 455 : net_log_(net_log), |
456 #if defined(ENABLE_EXTENSIONS) | 456 #if defined(ENABLE_EXTENSIONS) |
457 extension_event_router_forwarder_(extension_event_router_forwarder), | 457 extension_event_router_forwarder_(extension_event_router_forwarder), |
458 #endif | 458 #endif |
459 globals_(NULL), | 459 globals_(NULL), |
460 is_spdy_disabled_by_policy_(false), | 460 is_spdy_disabled_by_policy_(false), |
461 is_quic_allowed_by_policy_(true), | |
461 creation_time_(base::TimeTicks::Now()), | 462 creation_time_(base::TimeTicks::Now()), |
462 weak_factory_(this) { | 463 weak_factory_(this) { |
463 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 464 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
464 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 465 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
465 prefs::kDisableAuthNegotiateCnameLookup); | 466 prefs::kDisableAuthNegotiateCnameLookup); |
466 negotiate_enable_port_ = local_state->GetBoolean( | 467 negotiate_enable_port_ = local_state->GetBoolean( |
467 prefs::kEnableAuthNegotiatePort); | 468 prefs::kEnableAuthNegotiatePort); |
468 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 469 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
469 auth_delegate_whitelist_ = local_state->GetString( | 470 auth_delegate_whitelist_ = local_state->GetString( |
470 prefs::kAuthNegotiateDelegateWhitelist); | 471 prefs::kAuthNegotiateDelegateWhitelist); |
(...skipping 27 matching lines...) Expand all Loading... | |
498 | 499 |
499 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 500 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
500 local_state); | 501 local_state); |
501 quick_check_enabled_.MoveToThread( | 502 quick_check_enabled_.MoveToThread( |
502 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 503 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
503 | 504 |
504 #if defined(ENABLE_CONFIGURATION_POLICY) | 505 #if defined(ENABLE_CONFIGURATION_POLICY) |
505 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 506 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
506 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 507 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
507 policy::key::kDisableSpdy) != NULL; | 508 policy::key::kDisableSpdy) != NULL; |
509 | |
510 const base::Value* value = policy_service->GetPolicies( | |
511 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | |
512 std::string())).GetValue(policy::key::kQuicAllowed); | |
513 if (value) | |
514 value->GetAsBoolean(&is_quic_allowed_by_policy_); | |
508 #endif // ENABLE_CONFIGURATION_POLICY | 515 #endif // ENABLE_CONFIGURATION_POLICY |
509 | 516 |
510 BrowserThread::SetDelegate(BrowserThread::IO, this); | 517 BrowserThread::SetDelegate(BrowserThread::IO, this); |
511 } | 518 } |
512 | 519 |
513 IOThread::~IOThread() { | 520 IOThread::~IOThread() { |
514 // This isn't needed for production code, but in tests, IOThread may | 521 // This isn't needed for production code, but in tests, IOThread may |
515 // be multiply constructed. | 522 // be multiply constructed. |
516 BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 523 BrowserThread::SetDelegate(BrowserThread::IO, NULL); |
517 | 524 |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1148 // Always fetch the field trial group to ensure it is reported correctly. | 1155 // Always fetch the field trial group to ensure it is reported correctly. |
1149 // The command line flags will be associated with a group that is reported | 1156 // The command line flags will be associated with a group that is reported |
1150 // so long as trial is actually queried. | 1157 // so long as trial is actually queried. |
1151 std::string group = | 1158 std::string group = |
1152 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1159 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
1153 VariationParameters params; | 1160 VariationParameters params; |
1154 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1161 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
1155 params.clear(); | 1162 params.clear(); |
1156 } | 1163 } |
1157 | 1164 |
1158 ConfigureQuicGlobals(command_line, group, params, globals_); | 1165 ConfigureQuicGlobals(command_line, group, params, is_quic_allowed_by_policy_, |
1166 globals_); | |
1159 } | 1167 } |
1160 | 1168 |
1161 // static | 1169 // static |
1162 void IOThread::ConfigureQuicGlobals( | 1170 void IOThread::ConfigureQuicGlobals( |
1163 const base::CommandLine& command_line, | 1171 const base::CommandLine& command_line, |
1164 base::StringPiece quic_trial_group, | 1172 base::StringPiece quic_trial_group, |
1165 const VariationParameters& quic_trial_params, | 1173 const VariationParameters& quic_trial_params, |
1174 bool quic_allowed_by_policy, | |
1166 IOThread::Globals* globals) { | 1175 IOThread::Globals* globals) { |
1167 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1176 bool enable_quic = ShouldEnableQuic(command_line, |
1177 quic_trial_group, quic_allowed_by_policy); | |
1168 globals->enable_quic.set(enable_quic); | 1178 globals->enable_quic.set(enable_quic); |
1169 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(command_line, | 1179 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(command_line, |
1170 quic_trial_group); | 1180 quic_trial_group, quic_allowed_by_policy); |
1171 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); | 1181 globals->enable_quic_for_proxies.set(enable_quic_for_proxies); |
1172 if (enable_quic) { | 1182 if (enable_quic) { |
1173 globals->quic_always_require_handshake_confirmation.set( | 1183 globals->quic_always_require_handshake_confirmation.set( |
1174 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); | 1184 ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); |
1175 globals->quic_disable_connection_pooling.set( | 1185 globals->quic_disable_connection_pooling.set( |
1176 ShouldQuicDisableConnectionPooling(quic_trial_params)); | 1186 ShouldQuicDisableConnectionPooling(quic_trial_params)); |
1177 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); | 1187 int receive_buffer_size = GetQuicSocketReceiveBufferSize(quic_trial_params); |
1178 if (receive_buffer_size != 0) { | 1188 if (receive_buffer_size != 0) { |
1179 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); | 1189 globals->quic_socket_receive_buffer_size.set(receive_buffer_size); |
1180 } | 1190 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1232 net::HostPortPair quic_origin = | 1242 net::HostPortPair quic_origin = |
1233 net::HostPortPair::FromString( | 1243 net::HostPortPair::FromString( |
1234 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); | 1244 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); |
1235 if (!quic_origin.IsEmpty()) { | 1245 if (!quic_origin.IsEmpty()) { |
1236 globals->origin_to_force_quic_on.set(quic_origin); | 1246 globals->origin_to_force_quic_on.set(quic_origin); |
1237 } | 1247 } |
1238 } | 1248 } |
1239 } | 1249 } |
1240 | 1250 |
1241 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, | 1251 bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, |
1242 base::StringPiece quic_trial_group) { | 1252 base::StringPiece quic_trial_group, |
1243 if (command_line.HasSwitch(switches::kDisableQuic)) | 1253 bool quic_allowed_by_policy) { |
1254 if (command_line.HasSwitch(switches::kDisableQuic) || !quic_allowed_by_policy) | |
1244 return false; | 1255 return false; |
1245 | 1256 |
1246 if (command_line.HasSwitch(switches::kEnableQuic)) | 1257 if (command_line.HasSwitch(switches::kEnableQuic)) |
1247 return true; | 1258 return true; |
1248 | 1259 |
1249 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || | 1260 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || |
1250 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); | 1261 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); |
1251 } | 1262 } |
1252 | 1263 |
1253 // static | 1264 // static |
1254 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, | 1265 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, |
1255 base::StringPiece quic_trial_group) { | 1266 base::StringPiece quic_trial_group, |
1256 return ShouldEnableQuic(command_line, quic_trial_group) || | 1267 bool quic_allowed_by_policy) { |
1257 ShouldEnableQuicForDataReductionProxy(); | 1268 return ShouldEnableQuic(command_line, quic_trial_group, |
1269 quic_allowed_by_policy) || ShouldEnableQuicForDataReductionProxy(); | |
Andrew T Wilson (Slow)
2015/03/13 14:00:51
I don't think this is the right indent per https:/
peletskyi
2015/03/18 15:42:30
Done.
| |
1258 } | 1270 } |
1259 | 1271 |
1260 // static | 1272 // static |
1261 bool IOThread::ShouldEnableQuicForDataReductionProxy() { | 1273 bool IOThread::ShouldEnableQuicForDataReductionProxy() { |
1262 const base::CommandLine& command_line = | 1274 const base::CommandLine& command_line = |
1263 *base::CommandLine::ForCurrentProcess(); | 1275 *base::CommandLine::ForCurrentProcess(); |
1264 | 1276 |
1265 if (command_line.HasSwitch(switches::kDisableQuic)) | 1277 if (command_line.HasSwitch(switches::kDisableQuic)) |
1266 return false; | 1278 return false; |
1267 | 1279 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1441 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1453 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1442 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1454 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1443 net::QuicVersion version = supported_versions[i]; | 1455 net::QuicVersion version = supported_versions[i]; |
1444 if (net::QuicVersionToString(version) == quic_version) { | 1456 if (net::QuicVersionToString(version) == quic_version) { |
1445 return version; | 1457 return version; |
1446 } | 1458 } |
1447 } | 1459 } |
1448 | 1460 |
1449 return net::QUIC_VERSION_UNSUPPORTED; | 1461 return net::QUIC_VERSION_UNSUPPORTED; |
1450 } | 1462 } |
OLD | NEW |