| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 } else if (option == kDisablePing) { | 859 } else if (option == kDisablePing) { |
| 860 globals_->enable_spdy_ping_based_connection_checking.set(false); | 860 globals_->enable_spdy_ping_based_connection_checking.set(false); |
| 861 } else if (option == kExclude) { | 861 } else if (option == kExclude) { |
| 862 globals_->forced_spdy_exclusions.insert( | 862 globals_->forced_spdy_exclusions.insert( |
| 863 net::HostPortPair::FromURL(GURL(value))); | 863 net::HostPortPair::FromURL(GURL(value))); |
| 864 } else if (option == kDisableCompression) { | 864 } else if (option == kDisableCompression) { |
| 865 globals_->enable_spdy_compression.set(false); | 865 globals_->enable_spdy_compression.set(false); |
| 866 } else if (option == kDisableAltProtocols) { | 866 } else if (option == kDisableAltProtocols) { |
| 867 globals_->use_alternate_protocols.set(false); | 867 globals_->use_alternate_protocols.set(false); |
| 868 } else if (option == kForceAltProtocols) { | 868 } else if (option == kForceAltProtocols) { |
| 869 net::PortAlternateProtocolPair pair; | 869 net::AlternateProtocolInfo pair(443, net::NPN_SPDY_3, 1); |
| 870 pair.port = 443; | |
| 871 pair.protocol = net::NPN_SPDY_3; | |
| 872 net::HttpServerPropertiesImpl::ForceAlternateProtocol(pair); | 870 net::HttpServerPropertiesImpl::ForceAlternateProtocol(pair); |
| 873 } else if (option == kSingleDomain) { | 871 } else if (option == kSingleDomain) { |
| 874 DVLOG(1) << "FORCING SINGLE DOMAIN"; | 872 DVLOG(1) << "FORCING SINGLE DOMAIN"; |
| 875 globals_->force_spdy_single_domain.set(true); | 873 globals_->force_spdy_single_domain.set(true); |
| 876 } else if (option == kInitialMaxConcurrentStreams) { | 874 } else if (option == kInitialMaxConcurrentStreams) { |
| 877 int streams; | 875 int streams; |
| 878 if (base::StringToInt(value, &streams)) | 876 if (base::StringToInt(value, &streams)) |
| 879 globals_->initial_max_spdy_concurrent_streams.set(streams); | 877 globals_->initial_max_spdy_concurrent_streams.set(streams); |
| 880 } else if (option.empty() && it == spdy_options.begin()) { | 878 } else if (option.empty() && it == spdy_options.begin()) { |
| 881 continue; | 879 continue; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 ¶ms->enable_spdy_ping_based_connection_checking); | 982 ¶ms->enable_spdy_ping_based_connection_checking); |
| 985 globals.spdy_default_protocol.CopyToIfSet( | 983 globals.spdy_default_protocol.CopyToIfSet( |
| 986 ¶ms->spdy_default_protocol); | 984 ¶ms->spdy_default_protocol); |
| 987 params->next_protos = globals.next_protos; | 985 params->next_protos = globals.next_protos; |
| 988 globals.trusted_spdy_proxy.CopyToIfSet(¶ms->trusted_spdy_proxy); | 986 globals.trusted_spdy_proxy.CopyToIfSet(¶ms->trusted_spdy_proxy); |
| 989 globals.force_spdy_over_ssl.CopyToIfSet(¶ms->force_spdy_over_ssl); | 987 globals.force_spdy_over_ssl.CopyToIfSet(¶ms->force_spdy_over_ssl); |
| 990 globals.force_spdy_always.CopyToIfSet(¶ms->force_spdy_always); | 988 globals.force_spdy_always.CopyToIfSet(¶ms->force_spdy_always); |
| 991 params->forced_spdy_exclusions = globals.forced_spdy_exclusions; | 989 params->forced_spdy_exclusions = globals.forced_spdy_exclusions; |
| 992 globals.use_alternate_protocols.CopyToIfSet( | 990 globals.use_alternate_protocols.CopyToIfSet( |
| 993 ¶ms->use_alternate_protocols); | 991 ¶ms->use_alternate_protocols); |
| 992 globals.alternate_protocol_probability_threshold.CopyToIfSet( |
| 993 ¶ms->alternate_protocol_probability_threshold); |
| 994 globals.enable_websocket_over_spdy.CopyToIfSet( | 994 globals.enable_websocket_over_spdy.CopyToIfSet( |
| 995 ¶ms->enable_websocket_over_spdy); | 995 ¶ms->enable_websocket_over_spdy); |
| 996 | 996 |
| 997 globals.enable_quic.CopyToIfSet(¶ms->enable_quic); | 997 globals.enable_quic.CopyToIfSet(¶ms->enable_quic); |
| 998 globals.enable_quic_pacing.CopyToIfSet( | 998 globals.enable_quic_pacing.CopyToIfSet( |
| 999 ¶ms->enable_quic_pacing); | 999 ¶ms->enable_quic_pacing); |
| 1000 globals.enable_quic_time_based_loss_detection.CopyToIfSet( | 1000 globals.enable_quic_time_based_loss_detection.CopyToIfSet( |
| 1001 ¶ms->enable_quic_time_based_loss_detection); | 1001 ¶ms->enable_quic_time_based_loss_detection); |
| 1002 globals.enable_quic_port_selection.CopyToIfSet( | 1002 globals.enable_quic_port_selection.CopyToIfSet( |
| 1003 ¶ms->enable_quic_port_selection); | 1003 ¶ms->enable_quic_port_selection); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 quic_user_agent_id.append(version_info.ProductNameAndVersionForUserAgent()); | 1135 quic_user_agent_id.append(version_info.ProductNameAndVersionForUserAgent()); |
| 1136 globals->quic_user_agent_id.set(quic_user_agent_id); | 1136 globals->quic_user_agent_id.set(quic_user_agent_id); |
| 1137 | 1137 |
| 1138 net::QuicVersion version = GetQuicVersion(command_line, quic_trial_params); | 1138 net::QuicVersion version = GetQuicVersion(command_line, quic_trial_params); |
| 1139 if (version != net::QUIC_VERSION_UNSUPPORTED) { | 1139 if (version != net::QUIC_VERSION_UNSUPPORTED) { |
| 1140 net::QuicVersionVector supported_versions; | 1140 net::QuicVersionVector supported_versions; |
| 1141 supported_versions.push_back(version); | 1141 supported_versions.push_back(version); |
| 1142 globals->quic_supported_versions.set(supported_versions); | 1142 globals->quic_supported_versions.set(supported_versions); |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 double threshold = |
| 1146 GetAlternateProtocolProbabilityThreshold(command_line, quic_trial_params); |
| 1147 if (threshold >=0 & threshold <= 1) { |
| 1148 globals->alternate_protocol_probability_threshold.set(threshold); |
| 1149 globals->http_server_properties->SetAlternateProtocolProbabilityThreshold( |
| 1150 threshold); |
| 1151 } |
| 1152 |
| 1145 if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) { | 1153 if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) { |
| 1146 net::HostPortPair quic_origin = | 1154 net::HostPortPair quic_origin = |
| 1147 net::HostPortPair::FromString( | 1155 net::HostPortPair::FromString( |
| 1148 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); | 1156 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); |
| 1149 if (!quic_origin.IsEmpty()) { | 1157 if (!quic_origin.IsEmpty()) { |
| 1150 globals->origin_to_force_quic_on.set(quic_origin); | 1158 globals->origin_to_force_quic_on.set(quic_origin); |
| 1151 } | 1159 } |
| 1152 } | 1160 } |
| 1153 } | 1161 } |
| 1154 | 1162 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 } | 1210 } |
| 1203 | 1211 |
| 1204 VariationParameters::const_iterator it = | 1212 VariationParameters::const_iterator it = |
| 1205 quic_trial_params.find("congestion_options"); | 1213 quic_trial_params.find("congestion_options"); |
| 1206 if (it == quic_trial_params.end()) | 1214 if (it == quic_trial_params.end()) |
| 1207 return net::QuicTagVector(); | 1215 return net::QuicTagVector(); |
| 1208 | 1216 |
| 1209 return ParseQuicConnectionOptions(it->second); | 1217 return ParseQuicConnectionOptions(it->second); |
| 1210 } | 1218 } |
| 1211 | 1219 |
| 1220 // static |
| 1212 net::QuicTagVector IOThread::ParseQuicConnectionOptions( | 1221 net::QuicTagVector IOThread::ParseQuicConnectionOptions( |
| 1213 const std::string& connection_options) { | 1222 const std::string& connection_options) { |
| 1214 net::QuicTagVector options; | 1223 net::QuicTagVector options; |
| 1215 std::vector<std::string> tokens; | 1224 std::vector<std::string> tokens; |
| 1216 base::SplitString(connection_options, ',', &tokens); | 1225 base::SplitString(connection_options, ',', &tokens); |
| 1217 // Tokens are expected to be no more than 4 characters long, but we | 1226 // Tokens are expected to be no more than 4 characters long, but we |
| 1218 // handle overflow gracefully. | 1227 // handle overflow gracefully. |
| 1219 for (std::vector<std::string>::iterator token = tokens.begin(); | 1228 for (std::vector<std::string>::iterator token = tokens.begin(); |
| 1220 token != tokens.end(); ++token) { | 1229 token != tokens.end(); ++token) { |
| 1221 uint32 option = 0; | 1230 uint32 option = 0; |
| 1222 for (size_t i = token->length() ; i > 0; --i) { | 1231 for (size_t i = token->length() ; i > 0; --i) { |
| 1223 option <<= 8; | 1232 option <<= 8; |
| 1224 option |= static_cast<unsigned char>((*token)[i - 1]); | 1233 option |= static_cast<unsigned char>((*token)[i - 1]); |
| 1225 } | 1234 } |
| 1226 options.push_back(static_cast<net::QuicTag>(option)); | 1235 options.push_back(static_cast<net::QuicTag>(option)); |
| 1227 } | 1236 } |
| 1228 return options; | 1237 return options; |
| 1229 } | 1238 } |
| 1230 | 1239 |
| 1240 // static |
| 1241 double IOThread::GetAlternateProtocolProbabilityThreshold( |
| 1242 const base::CommandLine& command_line, |
| 1243 const VariationParameters& quic_trial_params) { |
| 1244 double value; |
| 1245 if (command_line.HasSwitch( |
| 1246 switches::kAlternateProtocolProbabilityThreshold)) { |
| 1247 if (base::StringToDouble( |
| 1248 command_line.GetSwitchValueASCII( |
| 1249 switches::kAlternateProtocolProbabilityThreshold), |
| 1250 &value)) { |
| 1251 return value; |
| 1252 } |
| 1253 } |
| 1254 if (base::StringToDouble( |
| 1255 GetVariationParam(quic_trial_params, |
| 1256 "alternate_protocol_probability_threshold"), |
| 1257 &value)) { |
| 1258 return value; |
| 1259 } |
| 1260 return -1; |
| 1261 } |
| 1262 |
| 1263 // static |
| 1231 bool IOThread::ShouldEnableQuicTimeBasedLossDetection( | 1264 bool IOThread::ShouldEnableQuicTimeBasedLossDetection( |
| 1232 const CommandLine& command_line, | 1265 const CommandLine& command_line, |
| 1233 base::StringPiece quic_trial_group, | 1266 base::StringPiece quic_trial_group, |
| 1234 const VariationParameters& quic_trial_params) { | 1267 const VariationParameters& quic_trial_params) { |
| 1235 if (command_line.HasSwitch(switches::kEnableQuicTimeBasedLossDetection)) | 1268 if (command_line.HasSwitch(switches::kEnableQuicTimeBasedLossDetection)) |
| 1236 return true; | 1269 return true; |
| 1237 | 1270 |
| 1238 if (command_line.HasSwitch(switches::kDisableQuicTimeBasedLossDetection)) | 1271 if (command_line.HasSwitch(switches::kDisableQuicTimeBasedLossDetection)) |
| 1239 return false; | 1272 return false; |
| 1240 | 1273 |
| 1241 if (LowerCaseEqualsASCII( | 1274 if (LowerCaseEqualsASCII( |
| 1242 GetVariationParam(quic_trial_params, "enable_time_based_loss_detection"), | 1275 GetVariationParam(quic_trial_params, "enable_time_based_loss_detection"), |
| 1243 "true")) | 1276 "true")) |
| 1244 return true; | 1277 return true; |
| 1245 | 1278 |
| 1246 return quic_trial_group.ends_with( | 1279 return quic_trial_group.ends_with( |
| 1247 kQuicFieldTrialTimeBasedLossDetectionSuffix); | 1280 kQuicFieldTrialTimeBasedLossDetectionSuffix); |
| 1248 } | 1281 } |
| 1249 | 1282 |
| 1283 // static |
| 1250 size_t IOThread::GetQuicMaxPacketLength( | 1284 size_t IOThread::GetQuicMaxPacketLength( |
| 1251 const CommandLine& command_line, | 1285 const CommandLine& command_line, |
| 1252 base::StringPiece quic_trial_group, | 1286 base::StringPiece quic_trial_group, |
| 1253 const VariationParameters& quic_trial_params) { | 1287 const VariationParameters& quic_trial_params) { |
| 1254 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { | 1288 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { |
| 1255 unsigned value; | 1289 unsigned value; |
| 1256 if (!base::StringToUint( | 1290 if (!base::StringToUint( |
| 1257 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), | 1291 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), |
| 1258 &value)) { | 1292 &value)) { |
| 1259 return 0; | 1293 return 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1281 if (!length_str.ends_with(kQuicFieldTrialPacketLengthSuffix)) { | 1315 if (!length_str.ends_with(kQuicFieldTrialPacketLengthSuffix)) { |
| 1282 return 0; | 1316 return 0; |
| 1283 } | 1317 } |
| 1284 length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix)); | 1318 length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix)); |
| 1285 if (!base::StringToUint(length_str, &value)) { | 1319 if (!base::StringToUint(length_str, &value)) { |
| 1286 return 0; | 1320 return 0; |
| 1287 } | 1321 } |
| 1288 return value; | 1322 return value; |
| 1289 } | 1323 } |
| 1290 | 1324 |
| 1325 // static |
| 1291 net::QuicVersion IOThread::GetQuicVersion( | 1326 net::QuicVersion IOThread::GetQuicVersion( |
| 1292 const CommandLine& command_line, | 1327 const CommandLine& command_line, |
| 1293 const VariationParameters& quic_trial_params) { | 1328 const VariationParameters& quic_trial_params) { |
| 1294 if (command_line.HasSwitch(switches::kQuicVersion)) { | 1329 if (command_line.HasSwitch(switches::kQuicVersion)) { |
| 1295 return ParseQuicVersion( | 1330 return ParseQuicVersion( |
| 1296 command_line.GetSwitchValueASCII(switches::kQuicVersion)); | 1331 command_line.GetSwitchValueASCII(switches::kQuicVersion)); |
| 1297 } | 1332 } |
| 1298 | 1333 |
| 1299 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version")); | 1334 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version")); |
| 1300 } | 1335 } |
| 1301 | 1336 |
| 1337 // static |
| 1302 net::QuicVersion IOThread::ParseQuicVersion(const std::string& quic_version) { | 1338 net::QuicVersion IOThread::ParseQuicVersion(const std::string& quic_version) { |
| 1303 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1339 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1304 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1340 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1305 net::QuicVersion version = supported_versions[i]; | 1341 net::QuicVersion version = supported_versions[i]; |
| 1306 if (net::QuicVersionToString(version) == quic_version) { | 1342 if (net::QuicVersionToString(version) == quic_version) { |
| 1307 return version; | 1343 return version; |
| 1308 } | 1344 } |
| 1309 } | 1345 } |
| 1310 | 1346 |
| 1311 return net::QUIC_VERSION_UNSUPPORTED; | 1347 return net::QUIC_VERSION_UNSUPPORTED; |
| 1312 } | 1348 } |
| OLD | NEW |