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

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

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

Powered by Google App Engine
This is Rietveld 408576698