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

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

Issue 346043002: Add support for setting QUIC connection options via field trial config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better Windows fix Created 6 years, 6 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/io_thread_unittest.cc » ('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 25 matching lines...) Expand all
36 #include "chrome/browser/net/dns_probe_service.h" 36 #include "chrome/browser/net/dns_probe_service.h"
37 #include "chrome/browser/net/pref_proxy_config_tracker.h" 37 #include "chrome/browser/net/pref_proxy_config_tracker.h"
38 #include "chrome/browser/net/proxy_service_factory.h" 38 #include "chrome/browser/net/proxy_service_factory.h"
39 #include "chrome/common/chrome_content_client.h" 39 #include "chrome/common/chrome_content_client.h"
40 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/chrome_version_info.h" 41 #include "chrome/common/chrome_version_info.h"
42 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
43 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" 43 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h"
44 #include "components/data_reduction_proxy/browser/http_auth_handler_data_reducti on_proxy.h" 44 #include "components/data_reduction_proxy/browser/http_auth_handler_data_reducti on_proxy.h"
45 #include "components/policy/core/common/policy_service.h" 45 #include "components/policy/core/common/policy_service.h"
46 #include "components/variations/variations_associated_data.h"
46 #include "content/public/browser/browser_thread.h" 47 #include "content/public/browser/browser_thread.h"
47 #include "content/public/browser/cookie_store_factory.h" 48 #include "content/public/browser/cookie_store_factory.h"
48 #include "net/base/host_mapping_rules.h" 49 #include "net/base/host_mapping_rules.h"
49 #include "net/base/net_util.h" 50 #include "net/base/net_util.h"
50 #include "net/cert/cert_verifier.h" 51 #include "net/cert/cert_verifier.h"
51 #include "net/cert/cert_verify_proc.h" 52 #include "net/cert/cert_verify_proc.h"
52 #include "net/cert/ct_known_logs.h" 53 #include "net/cert/ct_known_logs.h"
53 #include "net/cert/ct_verifier.h" 54 #include "net/cert/ct_verifier.h"
54 #include "net/cert/multi_threaded_cert_verifier.h" 55 #include "net/cert/multi_threaded_cert_verifier.h"
55 #include "net/cookies/cookie_store.h" 56 #include "net/cookies/cookie_store.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 int GetSwitchValueAsInt(const CommandLine& command_line, 280 int GetSwitchValueAsInt(const CommandLine& command_line,
280 const std::string& switch_name) { 281 const std::string& switch_name) {
281 int value; 282 int value;
282 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), 283 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name),
283 &value)) { 284 &value)) {
284 return 0; 285 return 0;
285 } 286 }
286 return value; 287 return value;
287 } 288 }
288 289
290 // Returns the value associated with |key| in |params| or "" if the
291 // key is not present in the map.
292 const std::string& GetVariationParam(
293 const std::map<std::string, std::string>& params,
294 const std::string& key) {
295 std::map<std::string, std::string>::const_iterator it = params.find(key);
296 if (it == params.end())
297 return base::EmptyString();
298
299 return it->second;
300 }
301
289 } // namespace 302 } // namespace
290 303
291 class IOThread::LoggingNetworkChangeObserver 304 class IOThread::LoggingNetworkChangeObserver
292 : public net::NetworkChangeNotifier::IPAddressObserver, 305 : public net::NetworkChangeNotifier::IPAddressObserver,
293 public net::NetworkChangeNotifier::ConnectionTypeObserver, 306 public net::NetworkChangeNotifier::ConnectionTypeObserver,
294 public net::NetworkChangeNotifier::NetworkChangeObserver { 307 public net::NetworkChangeNotifier::NetworkChangeObserver {
295 public: 308 public:
296 // |net_log| must remain valid throughout our lifetime. 309 // |net_log| must remain valid throughout our lifetime.
297 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) 310 explicit LoggingNetworkChangeObserver(net::NetLog* net_log)
298 : net_log_(net_log) { 311 : net_log_(net_log) {
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 void IOThread::ClearHostCache() { 940 void IOThread::ClearHostCache() {
928 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 941 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
929 942
930 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); 943 net::HostCache* host_cache = globals_->host_resolver->GetHostCache();
931 if (host_cache) 944 if (host_cache)
932 host_cache->clear(); 945 host_cache->clear();
933 } 946 }
934 947
935 void IOThread::InitializeNetworkSessionParams( 948 void IOThread::InitializeNetworkSessionParams(
936 net::HttpNetworkSession::Params* params) { 949 net::HttpNetworkSession::Params* params) {
937 params->host_resolver = globals_->host_resolver.get(); 950 InitializeNetworkSessionParamsFromGlobals(*globals_, params);
938 params->cert_verifier = globals_->cert_verifier.get(); 951 }
952
953 // static
954 void IOThread::InitializeNetworkSessionParamsFromGlobals(
955 const IOThread::Globals& globals,
956 net::HttpNetworkSession::Params* params) {
957 params->host_resolver = globals.host_resolver.get();
958 params->cert_verifier = globals.cert_verifier.get();
939 params->server_bound_cert_service = 959 params->server_bound_cert_service =
940 globals_->system_server_bound_cert_service.get(); 960 globals.system_server_bound_cert_service.get();
941 params->transport_security_state = globals_->transport_security_state.get(); 961 params->transport_security_state = globals.transport_security_state.get();
942 params->ssl_config_service = globals_->ssl_config_service.get(); 962 params->ssl_config_service = globals.ssl_config_service.get();
943 params->http_auth_handler_factory = globals_->http_auth_handler_factory.get(); 963 params->http_auth_handler_factory = globals.http_auth_handler_factory.get();
944 params->http_server_properties = 964 params->http_server_properties =
945 globals_->http_server_properties->GetWeakPtr(); 965 globals.http_server_properties->GetWeakPtr();
946 params->network_delegate = globals_->system_network_delegate.get(); 966 params->network_delegate = globals.system_network_delegate.get();
947 params->host_mapping_rules = globals_->host_mapping_rules.get(); 967 params->host_mapping_rules = globals.host_mapping_rules.get();
948 params->ignore_certificate_errors = globals_->ignore_certificate_errors; 968 params->ignore_certificate_errors = globals.ignore_certificate_errors;
949 params->testing_fixed_http_port = globals_->testing_fixed_http_port; 969 params->testing_fixed_http_port = globals.testing_fixed_http_port;
950 params->testing_fixed_https_port = globals_->testing_fixed_https_port; 970 params->testing_fixed_https_port = globals.testing_fixed_https_port;
951 971
952 globals_->initial_max_spdy_concurrent_streams.CopyToIfSet( 972 globals.initial_max_spdy_concurrent_streams.CopyToIfSet(
953 &params->spdy_initial_max_concurrent_streams); 973 &params->spdy_initial_max_concurrent_streams);
954 globals_->force_spdy_single_domain.CopyToIfSet( 974 globals.force_spdy_single_domain.CopyToIfSet(
955 &params->force_spdy_single_domain); 975 &params->force_spdy_single_domain);
956 globals_->enable_spdy_compression.CopyToIfSet( 976 globals.enable_spdy_compression.CopyToIfSet(
957 &params->enable_spdy_compression); 977 &params->enable_spdy_compression);
958 globals_->enable_spdy_ping_based_connection_checking.CopyToIfSet( 978 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet(
959 &params->enable_spdy_ping_based_connection_checking); 979 &params->enable_spdy_ping_based_connection_checking);
960 globals_->spdy_default_protocol.CopyToIfSet( 980 globals.spdy_default_protocol.CopyToIfSet(
961 &params->spdy_default_protocol); 981 &params->spdy_default_protocol);
962 params->next_protos = globals_->next_protos; 982 params->next_protos = globals.next_protos;
963 globals_->trusted_spdy_proxy.CopyToIfSet(&params->trusted_spdy_proxy); 983 globals.trusted_spdy_proxy.CopyToIfSet(&params->trusted_spdy_proxy);
964 globals_->force_spdy_over_ssl.CopyToIfSet(&params->force_spdy_over_ssl); 984 globals.force_spdy_over_ssl.CopyToIfSet(&params->force_spdy_over_ssl);
965 globals_->force_spdy_always.CopyToIfSet(&params->force_spdy_always); 985 globals.force_spdy_always.CopyToIfSet(&params->force_spdy_always);
966 globals_->forced_spdy_exclusions = params->forced_spdy_exclusions; 986 params->forced_spdy_exclusions = globals.forced_spdy_exclusions;
967 globals_->use_alternate_protocols.CopyToIfSet( 987 globals.use_alternate_protocols.CopyToIfSet(
968 &params->use_alternate_protocols); 988 &params->use_alternate_protocols);
969 globals_->enable_websocket_over_spdy.CopyToIfSet( 989 globals.enable_websocket_over_spdy.CopyToIfSet(
970 &params->enable_websocket_over_spdy); 990 &params->enable_websocket_over_spdy);
971 991
972 globals_->enable_quic.CopyToIfSet(&params->enable_quic); 992 globals.enable_quic.CopyToIfSet(&params->enable_quic);
973 globals_->enable_quic_pacing.CopyToIfSet( 993 globals.enable_quic_pacing.CopyToIfSet(
974 &params->enable_quic_pacing); 994 &params->enable_quic_pacing);
975 globals_->enable_quic_time_based_loss_detection.CopyToIfSet( 995 globals.enable_quic_time_based_loss_detection.CopyToIfSet(
976 &params->enable_quic_time_based_loss_detection); 996 &params->enable_quic_time_based_loss_detection);
977 globals_->enable_quic_persist_server_info.CopyToIfSet( 997 globals.enable_quic_port_selection.CopyToIfSet(
978 &params->enable_quic_persist_server_info);
979 globals_->enable_quic_port_selection.CopyToIfSet(
980 &params->enable_quic_port_selection); 998 &params->enable_quic_port_selection);
981 globals_->quic_max_packet_length.CopyToIfSet(&params->quic_max_packet_length); 999 globals.quic_max_packet_length.CopyToIfSet(&params->quic_max_packet_length);
982 globals_->quic_user_agent_id.CopyToIfSet(&params->quic_user_agent_id); 1000 globals.quic_user_agent_id.CopyToIfSet(&params->quic_user_agent_id);
983 globals_->quic_supported_versions.CopyToIfSet( 1001 globals.quic_supported_versions.CopyToIfSet(
984 &params->quic_supported_versions); 1002 &params->quic_supported_versions);
985 globals_->origin_to_force_quic_on.CopyToIfSet( 1003 params->quic_connection_options = globals.quic_connection_options;
1004
1005 globals.origin_to_force_quic_on.CopyToIfSet(
986 &params->origin_to_force_quic_on); 1006 &params->origin_to_force_quic_on);
987 params->enable_user_alternate_protocol_ports = 1007 params->enable_user_alternate_protocol_ports =
988 globals_->enable_user_alternate_protocol_ports; 1008 globals.enable_user_alternate_protocol_ports;
989 } 1009 }
990 1010
991 base::TimeTicks IOThread::creation_time() const { 1011 base::TimeTicks IOThread::creation_time() const {
992 return creation_time_; 1012 return creation_time_;
993 } 1013 }
994 1014
995 net::SSLConfigService* IOThread::GetSSLConfigService() { 1015 net::SSLConfigService* IOThread::GetSSLConfigService() {
996 return ssl_config_service_manager_->Get(); 1016 return ssl_config_service_manager_->Get();
997 } 1017 }
998 1018
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } 1074 }
1055 1075
1056 void IOThread::UpdateDnsClientEnabled() { 1076 void IOThread::UpdateDnsClientEnabled() {
1057 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); 1077 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_);
1058 } 1078 }
1059 1079
1060 void IOThread::ConfigureQuic(const CommandLine& command_line) { 1080 void IOThread::ConfigureQuic(const CommandLine& command_line) {
1061 // Always fetch the field trial group to ensure it is reported correctly. 1081 // Always fetch the field trial group to ensure it is reported correctly.
1062 // The command line flags will be associated with a group that is reported 1082 // The command line flags will be associated with a group that is reported
1063 // so long as trial is actually queried. 1083 // so long as trial is actually queried.
1064 std::string quic_trial_group = 1084 std::string group =
1065 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 1085 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
1086 VariationParameters params;
1087 if (!chrome_variations::GetVariationParams(kQuicFieldTrialName, &params)) {
1088 params.clear();
1089 }
1066 1090
1091 ConfigureQuicGlobals(command_line, group, params, globals_);
1092 }
1093
1094 // static
1095 void IOThread::ConfigureQuicGlobals(
1096 const base::CommandLine& command_line,
1097 base::StringPiece quic_trial_group,
1098 const VariationParameters& quic_trial_params,
1099 IOThread::Globals* globals) {
1067 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); 1100 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group);
1068 globals_->enable_quic.set(enable_quic); 1101 globals->enable_quic.set(enable_quic);
1069 if (enable_quic) { 1102 if (enable_quic) {
1070 globals_->enable_quic_pacing.set( 1103 globals->enable_quic_pacing.set(
1071 ShouldEnableQuicPacing(command_line, quic_trial_group)); 1104 ShouldEnableQuicPacing(command_line, quic_trial_group,
1072 globals_->enable_quic_time_based_loss_detection.set( 1105 quic_trial_params));
1073 ShouldEnableQuicTimeBasedLossDetection(command_line, quic_trial_group)); 1106 globals->enable_quic_time_based_loss_detection.set(
1074 globals_->enable_quic_persist_server_info.set( 1107 ShouldEnableQuicTimeBasedLossDetection(command_line, quic_trial_group,
1075 ShouldEnableQuicPersistServerInfo(command_line)); 1108 quic_trial_params));
1076 globals_->enable_quic_port_selection.set( 1109 globals->enable_quic_port_selection.set(
1077 ShouldEnableQuicPortSelection(command_line)); 1110 ShouldEnableQuicPortSelection(command_line));
1111 globals->quic_connection_options =
1112 GetQuicConnectionOptions(command_line, quic_trial_params);
1078 } 1113 }
1079 1114
1080 size_t max_packet_length = GetQuicMaxPacketLength(command_line, 1115 size_t max_packet_length = GetQuicMaxPacketLength(command_line,
1081 quic_trial_group); 1116 quic_trial_group,
1117 quic_trial_params);
1082 if (max_packet_length != 0) { 1118 if (max_packet_length != 0) {
1083 globals_->quic_max_packet_length.set(max_packet_length); 1119 globals->quic_max_packet_length.set(max_packet_length);
1084 } 1120 }
1085 1121
1086 std::string quic_user_agent_id = 1122 std::string quic_user_agent_id =
1087 chrome::VersionInfo::GetVersionStringModifier(); 1123 chrome::VersionInfo::GetVersionStringModifier();
1088 quic_user_agent_id.append(1, ' '); 1124 quic_user_agent_id.append(1, ' ');
1089 chrome::VersionInfo version_info; 1125 chrome::VersionInfo version_info;
1090 quic_user_agent_id.append(version_info.ProductNameAndVersionForUserAgent()); 1126 quic_user_agent_id.append(version_info.ProductNameAndVersionForUserAgent());
1091 globals_->quic_user_agent_id.set(quic_user_agent_id); 1127 globals->quic_user_agent_id.set(quic_user_agent_id);
1092 1128
1093 net::QuicVersion version = GetQuicVersion(command_line); 1129 net::QuicVersion version = GetQuicVersion(command_line, quic_trial_params);
1094 if (version != net::QUIC_VERSION_UNSUPPORTED) { 1130 if (version != net::QUIC_VERSION_UNSUPPORTED) {
1095 net::QuicVersionVector supported_versions; 1131 net::QuicVersionVector supported_versions;
1096 supported_versions.push_back(version); 1132 supported_versions.push_back(version);
1097 globals_->quic_supported_versions.set(supported_versions); 1133 globals->quic_supported_versions.set(supported_versions);
1098 } 1134 }
1099 1135
1100 if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) { 1136 if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) {
1101 net::HostPortPair quic_origin = 1137 net::HostPortPair quic_origin =
1102 net::HostPortPair::FromString( 1138 net::HostPortPair::FromString(
1103 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); 1139 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn));
1104 if (!quic_origin.IsEmpty()) { 1140 if (!quic_origin.IsEmpty()) {
1105 globals_->origin_to_force_quic_on.set(quic_origin); 1141 globals->origin_to_force_quic_on.set(quic_origin);
1106 } 1142 }
1107 } 1143 }
1108 } 1144 }
1109 1145
1110 bool IOThread::ShouldEnableQuic(const CommandLine& command_line, 1146 bool IOThread::ShouldEnableQuic(const CommandLine& command_line,
1111 base::StringPiece quic_trial_group) { 1147 base::StringPiece quic_trial_group) {
1112 if (command_line.HasSwitch(switches::kDisableQuic)) 1148 if (command_line.HasSwitch(switches::kDisableQuic))
1113 return false; 1149 return false;
1114 1150
1115 if (command_line.HasSwitch(switches::kEnableQuic)) 1151 if (command_line.HasSwitch(switches::kEnableQuic))
1116 return true; 1152 return true;
1117 1153
1118 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || 1154 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) ||
1119 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); 1155 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName);
1120 } 1156 }
1121 1157
1122 bool IOThread::ShouldEnableQuicPortSelection( 1158 bool IOThread::ShouldEnableQuicPortSelection(
1123 const CommandLine& command_line) { 1159 const CommandLine& command_line) {
1124 if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) 1160 if (command_line.HasSwitch(switches::kDisableQuicPortSelection))
1125 return false; 1161 return false;
1126 1162
1127 if (command_line.HasSwitch(switches::kEnableQuicPortSelection)) 1163 if (command_line.HasSwitch(switches::kEnableQuicPortSelection))
1128 return true; 1164 return true;
1129 1165
1130 return false; // Default to disabling port selection on all channels. 1166 return false; // Default to disabling port selection on all channels.
1131 } 1167 }
1132 1168
1133 bool IOThread::ShouldEnableQuicPacing(const CommandLine& command_line, 1169 bool IOThread::ShouldEnableQuicPacing(
1134 base::StringPiece quic_trial_group) { 1170 const CommandLine& command_line,
1171 base::StringPiece quic_trial_group,
1172 const VariationParameters& quic_trial_params) {
1135 if (command_line.HasSwitch(switches::kEnableQuicPacing)) 1173 if (command_line.HasSwitch(switches::kEnableQuicPacing))
1136 return true; 1174 return true;
1137 1175
1138 if (command_line.HasSwitch(switches::kDisableQuicPacing)) 1176 if (command_line.HasSwitch(switches::kDisableQuicPacing))
1139 return false; 1177 return false;
1140 1178
1179 if (LowerCaseEqualsASCII(
1180 GetVariationParam(quic_trial_params, "enable_pacing"),
1181 "true"))
1182 return true;
1183
1141 return quic_trial_group.ends_with(kQuicFieldTrialPacingSuffix); 1184 return quic_trial_group.ends_with(kQuicFieldTrialPacingSuffix);
1142 } 1185 }
1143 1186
1187 net::QuicTagVector IOThread::GetQuicConnectionOptions(
1188 const CommandLine& command_line,
1189 const VariationParameters& quic_trial_params) {
1190 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) {
1191 return ParseQuicConnectionOptions(
1192 command_line.GetSwitchValueASCII(switches::kQuicConnectionOptions));
1193 }
1194
1195 VariationParameters::const_iterator it =
1196 quic_trial_params.find("congestion_options");
1197 if (it == quic_trial_params.end())
1198 return net::QuicTagVector();
1199
1200 return ParseQuicConnectionOptions(it->second);
1201 }
1202
1203 net::QuicTagVector IOThread::ParseQuicConnectionOptions(
1204 const std::string& connection_options) {
1205 net::QuicTagVector options;
1206 std::vector<std::string> tokens;
1207 base::SplitString(connection_options, ',', &tokens);
1208 // Tokens are expected to be no more than 4 characters long, but we
1209 // handle overflow gracefully.
1210 for (std::vector<std::string>::iterator token = tokens.begin();
1211 token != tokens.end(); ++token) {
1212 uint32 option = 0;
1213 for (size_t i = token->length() ; i > 0; --i) {
1214 option <<= 8;
1215 option |= static_cast<unsigned char>((*token)[i - 1]);
1216 }
1217 options.push_back(static_cast<net::QuicTag>(option));
1218 }
1219 return options;
1220 }
1221
1144 bool IOThread::ShouldEnableQuicTimeBasedLossDetection( 1222 bool IOThread::ShouldEnableQuicTimeBasedLossDetection(
1145 const CommandLine& command_line, 1223 const CommandLine& command_line,
1146 base::StringPiece quic_trial_group) { 1224 base::StringPiece quic_trial_group,
1225 const VariationParameters& quic_trial_params) {
1147 if (command_line.HasSwitch(switches::kEnableQuicTimeBasedLossDetection)) 1226 if (command_line.HasSwitch(switches::kEnableQuicTimeBasedLossDetection))
1148 return true; 1227 return true;
1149 1228
1150 if (command_line.HasSwitch(switches::kDisableQuicTimeBasedLossDetection)) 1229 if (command_line.HasSwitch(switches::kDisableQuicTimeBasedLossDetection))
1151 return false; 1230 return false;
1152 1231
1232 if (LowerCaseEqualsASCII(
1233 GetVariationParam(quic_trial_params, "enable_time_based_loss_detection"),
1234 "true"))
1235 return true;
1236
1153 return quic_trial_group.ends_with( 1237 return quic_trial_group.ends_with(
1154 kQuicFieldTrialTimeBasedLossDetectionSuffix); 1238 kQuicFieldTrialTimeBasedLossDetectionSuffix);
1155 } 1239 }
1156 1240
1157 // TODO(rtenneti): Delete this method after the merge. 1241 size_t IOThread::GetQuicMaxPacketLength(
1158 bool IOThread::ShouldEnableQuicPersistServerInfo( 1242 const CommandLine& command_line,
1159 const CommandLine& command_line) { 1243 base::StringPiece quic_trial_group,
1160 return true; 1244 const VariationParameters& quic_trial_params) {
1161 }
1162
1163 size_t IOThread::GetQuicMaxPacketLength(const CommandLine& command_line,
1164 base::StringPiece quic_trial_group) {
1165 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { 1245 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) {
1166 unsigned value; 1246 unsigned value;
1167 if (!base::StringToUint( 1247 if (!base::StringToUint(
1168 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), 1248 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength),
1169 &value)) { 1249 &value)) {
1170 return 0; 1250 return 0;
1171 } 1251 }
1172 return value; 1252 return value;
1173 } 1253 }
1174 1254
1255 unsigned value;
1256 if (base::StringToUint(GetVariationParam(quic_trial_params,
1257 "max_packet_length"),
1258 &value)) {
1259 return value;
1260 }
1261
1175 // Format of the packet length group names is: 1262 // Format of the packet length group names is:
1176 // (Https)?Enabled<length>BytePackets. 1263 // (Https)?Enabled<length>BytePackets.
1177 base::StringPiece length_str(quic_trial_group); 1264 base::StringPiece length_str(quic_trial_group);
1178 if (length_str.starts_with(kQuicFieldTrialEnabledGroupName)) { 1265 if (length_str.starts_with(kQuicFieldTrialEnabledGroupName)) {
1179 length_str.remove_prefix(strlen(kQuicFieldTrialEnabledGroupName)); 1266 length_str.remove_prefix(strlen(kQuicFieldTrialEnabledGroupName));
1180 } else if (length_str.starts_with(kQuicFieldTrialHttpsEnabledGroupName)) { 1267 } else if (length_str.starts_with(kQuicFieldTrialHttpsEnabledGroupName)) {
1181 length_str.remove_prefix(strlen(kQuicFieldTrialHttpsEnabledGroupName)); 1268 length_str.remove_prefix(strlen(kQuicFieldTrialHttpsEnabledGroupName));
1182 } else { 1269 } else {
1183 return 0; 1270 return 0;
1184 } 1271 }
1185 if (!length_str.ends_with(kQuicFieldTrialPacketLengthSuffix)) { 1272 if (!length_str.ends_with(kQuicFieldTrialPacketLengthSuffix)) {
1186 return 0; 1273 return 0;
1187 } 1274 }
1188 length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix)); 1275 length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix));
1189 unsigned value;
1190 if (!base::StringToUint(length_str, &value)) { 1276 if (!base::StringToUint(length_str, &value)) {
1191 return 0; 1277 return 0;
1192 } 1278 }
1193 return value; 1279 return value;
1194 } 1280 }
1195 1281
1196 net::QuicVersion IOThread::GetQuicVersion(const CommandLine& command_line) { 1282 net::QuicVersion IOThread::GetQuicVersion(
1197 if (!command_line.HasSwitch(switches::kQuicVersion)) { 1283 const CommandLine& command_line,
1198 return net::QUIC_VERSION_UNSUPPORTED; 1284 const VariationParameters& quic_trial_params) {
1285 if (command_line.HasSwitch(switches::kQuicVersion)) {
1286 return ParseQuicVersion(
1287 command_line.GetSwitchValueASCII(switches::kQuicVersion));
1199 } 1288 }
1289
1290 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version"));
1291 }
1292
1293 net::QuicVersion IOThread::ParseQuicVersion(const std::string& quic_version) {
1200 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1294 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1201 std::string version_flag =
1202 command_line.GetSwitchValueASCII(switches::kQuicVersion);
1203 for (size_t i = 0; i < supported_versions.size(); ++i) { 1295 for (size_t i = 0; i < supported_versions.size(); ++i) {
1204 net::QuicVersion version = supported_versions[i]; 1296 net::QuicVersion version = supported_versions[i];
1205 if (net::QuicVersionToString(version) == version_flag) { 1297 if (net::QuicVersionToString(version) == quic_version) {
1206 return version; 1298 return version;
1207 } 1299 }
1208 } 1300 }
1301
1209 return net::QUIC_VERSION_UNSUPPORTED; 1302 return net::QUIC_VERSION_UNSUPPORTED;
1210 } 1303 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698