| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Quit task, so base::Bind() calls are not refcounted. | 117 // Quit task, so base::Bind() calls are not refcounted. |
| 118 | 118 |
| 119 namespace { | 119 namespace { |
| 120 | 120 |
| 121 const char kTCPFastOpenFieldTrialName[] = "TCPFastOpen"; | 121 const char kTCPFastOpenFieldTrialName[] = "TCPFastOpen"; |
| 122 const char kTCPFastOpenHttpsEnabledGroupName[] = "HttpsEnabled"; | 122 const char kTCPFastOpenHttpsEnabledGroupName[] = "HttpsEnabled"; |
| 123 | 123 |
| 124 const char kQuicFieldTrialName[] = "QUIC"; | 124 const char kQuicFieldTrialName[] = "QUIC"; |
| 125 const char kQuicFieldTrialEnabledGroupName[] = "Enabled"; | 125 const char kQuicFieldTrialEnabledGroupName[] = "Enabled"; |
| 126 const char kQuicFieldTrialHttpsEnabledGroupName[] = "HttpsEnabled"; | 126 const char kQuicFieldTrialHttpsEnabledGroupName[] = "HttpsEnabled"; |
| 127 const char kQuicFieldTrialPacketLengthSuffix[] = "BytePackets"; | |
| 128 const char kQuicFieldTrialPacingSuffix[] = "WithPacing"; | |
| 129 | 127 |
| 130 // The SPDY trial composes two different trial plus control groups: | 128 // The SPDY trial composes two different trial plus control groups: |
| 131 // * A "holdback" group with SPDY disabled, and corresponding control | 129 // * A "holdback" group with SPDY disabled, and corresponding control |
| 132 // (SPDY/3.1). The primary purpose of the holdback group is to encourage site | 130 // (SPDY/3.1). The primary purpose of the holdback group is to encourage site |
| 133 // operators to do feature detection rather than UA-sniffing. As such, this | 131 // operators to do feature detection rather than UA-sniffing. As such, this |
| 134 // trial runs continuously. | 132 // trial runs continuously. |
| 135 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and | 133 // * A SPDY/4 experiment, for SPDY/4 (aka HTTP/2) vs SPDY/3.1 comparisons and |
| 136 // eventual SPDY/4 deployment. | 134 // eventual SPDY/4 deployment. |
| 137 const char kSpdyFieldTrialName[] = "SPDY"; | 135 const char kSpdyFieldTrialName[] = "SPDY"; |
| 138 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; | 136 const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled"; |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 bool IOThread::ShouldEnableQuicPacing( | 1277 bool IOThread::ShouldEnableQuicPacing( |
| 1280 const CommandLine& command_line, | 1278 const CommandLine& command_line, |
| 1281 base::StringPiece quic_trial_group, | 1279 base::StringPiece quic_trial_group, |
| 1282 const VariationParameters& quic_trial_params) { | 1280 const VariationParameters& quic_trial_params) { |
| 1283 if (command_line.HasSwitch(switches::kEnableQuicPacing)) | 1281 if (command_line.HasSwitch(switches::kEnableQuicPacing)) |
| 1284 return true; | 1282 return true; |
| 1285 | 1283 |
| 1286 if (command_line.HasSwitch(switches::kDisableQuicPacing)) | 1284 if (command_line.HasSwitch(switches::kDisableQuicPacing)) |
| 1287 return false; | 1285 return false; |
| 1288 | 1286 |
| 1289 if (LowerCaseEqualsASCII( | 1287 return LowerCaseEqualsASCII( |
| 1290 GetVariationParam(quic_trial_params, "enable_pacing"), | 1288 GetVariationParam(quic_trial_params, "enable_pacing"), |
| 1291 "true")) | 1289 "true"); |
| 1292 return true; | |
| 1293 | |
| 1294 return quic_trial_group.ends_with(kQuicFieldTrialPacingSuffix); | |
| 1295 } | 1290 } |
| 1296 | 1291 |
| 1297 net::QuicTagVector IOThread::GetQuicConnectionOptions( | 1292 net::QuicTagVector IOThread::GetQuicConnectionOptions( |
| 1298 const CommandLine& command_line, | 1293 const CommandLine& command_line, |
| 1299 const VariationParameters& quic_trial_params) { | 1294 const VariationParameters& quic_trial_params) { |
| 1300 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { | 1295 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { |
| 1301 return net::QuicUtils::ParseQuicConnectionOptions( | 1296 return net::QuicUtils::ParseQuicConnectionOptions( |
| 1302 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions)); | 1297 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions)); |
| 1303 } | 1298 } |
| 1304 | 1299 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 } | 1378 } |
| 1384 return value; | 1379 return value; |
| 1385 } | 1380 } |
| 1386 | 1381 |
| 1387 unsigned value; | 1382 unsigned value; |
| 1388 if (base::StringToUint(GetVariationParam(quic_trial_params, | 1383 if (base::StringToUint(GetVariationParam(quic_trial_params, |
| 1389 "max_packet_length"), | 1384 "max_packet_length"), |
| 1390 &value)) { | 1385 &value)) { |
| 1391 return value; | 1386 return value; |
| 1392 } | 1387 } |
| 1393 | 1388 return 0; |
| 1394 // Format of the packet length group names is: | |
| 1395 // (Https)?Enabled<length>BytePackets. | |
| 1396 base::StringPiece length_str(quic_trial_group); | |
| 1397 if (length_str.starts_with(kQuicFieldTrialEnabledGroupName)) { | |
| 1398 length_str.remove_prefix(strlen(kQuicFieldTrialEnabledGroupName)); | |
| 1399 } else if (length_str.starts_with(kQuicFieldTrialHttpsEnabledGroupName)) { | |
| 1400 length_str.remove_prefix(strlen(kQuicFieldTrialHttpsEnabledGroupName)); | |
| 1401 } else { | |
| 1402 return 0; | |
| 1403 } | |
| 1404 if (!length_str.ends_with(kQuicFieldTrialPacketLengthSuffix)) { | |
| 1405 return 0; | |
| 1406 } | |
| 1407 length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix)); | |
| 1408 if (!base::StringToUint(length_str, &value)) { | |
| 1409 return 0; | |
| 1410 } | |
| 1411 return value; | |
| 1412 } | 1389 } |
| 1413 | 1390 |
| 1414 // static | 1391 // static |
| 1415 net::QuicVersion IOThread::GetQuicVersion( | 1392 net::QuicVersion IOThread::GetQuicVersion( |
| 1416 const CommandLine& command_line, | 1393 const CommandLine& command_line, |
| 1417 const VariationParameters& quic_trial_params) { | 1394 const VariationParameters& quic_trial_params) { |
| 1418 if (command_line.HasSwitch(switches::kQuicVersion)) { | 1395 if (command_line.HasSwitch(switches::kQuicVersion)) { |
| 1419 return ParseQuicVersion( | 1396 return ParseQuicVersion( |
| 1420 command_line.GetSwitchValueASCII(switches::kQuicVersion)); | 1397 command_line.GetSwitchValueASCII(switches::kQuicVersion)); |
| 1421 } | 1398 } |
| 1422 | 1399 |
| 1423 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version")); | 1400 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version")); |
| 1424 } | 1401 } |
| 1425 | 1402 |
| 1426 // static | 1403 // static |
| 1427 net::QuicVersion IOThread::ParseQuicVersion(const std::string& quic_version) { | 1404 net::QuicVersion IOThread::ParseQuicVersion(const std::string& quic_version) { |
| 1428 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1405 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1429 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1406 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1430 net::QuicVersion version = supported_versions[i]; | 1407 net::QuicVersion version = supported_versions[i]; |
| 1431 if (net::QuicVersionToString(version) == quic_version) { | 1408 if (net::QuicVersionToString(version) == quic_version) { |
| 1432 return version; | 1409 return version; |
| 1433 } | 1410 } |
| 1434 } | 1411 } |
| 1435 | 1412 |
| 1436 return net::QUIC_VERSION_UNSUPPORTED; | 1413 return net::QUIC_VERSION_UNSUPPORTED; |
| 1437 } | 1414 } |
| OLD | NEW |