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

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

Powered by Google App Engine
This is Rietveld 408576698