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