Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 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 Loading... | |
| 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) { | |
| 295 std::map<std::string, std::string>::const_iterator it = params.find(key); | |
| 296 if (it == params.end()) | |
| 297 return ""; | |
| 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 Loading... | |
| 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 ¶ms->spdy_initial_max_concurrent_streams); | 973 ¶ms->spdy_initial_max_concurrent_streams); |
| 955 globals_->force_spdy_single_domain.CopyToIfSet( | 974 globals.force_spdy_single_domain.CopyToIfSet( |
| 956 ¶ms->force_spdy_single_domain); | 975 ¶ms->force_spdy_single_domain); |
| 957 globals_->enable_spdy_compression.CopyToIfSet( | 976 globals.enable_spdy_compression.CopyToIfSet( |
| 958 ¶ms->enable_spdy_compression); | 977 ¶ms->enable_spdy_compression); |
| 959 globals_->enable_spdy_ping_based_connection_checking.CopyToIfSet( | 978 globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( |
| 960 ¶ms->enable_spdy_ping_based_connection_checking); | 979 ¶ms->enable_spdy_ping_based_connection_checking); |
| 961 globals_->spdy_default_protocol.CopyToIfSet( | 980 globals.spdy_default_protocol.CopyToIfSet( |
| 962 ¶ms->spdy_default_protocol); | 981 ¶ms->spdy_default_protocol); |
| 963 params->next_protos = globals_->next_protos; | 982 params->next_protos = globals.next_protos; |
| 964 globals_->trusted_spdy_proxy.CopyToIfSet(¶ms->trusted_spdy_proxy); | 983 globals.trusted_spdy_proxy.CopyToIfSet(¶ms->trusted_spdy_proxy); |
| 965 globals_->force_spdy_over_ssl.CopyToIfSet(¶ms->force_spdy_over_ssl); | 984 globals.force_spdy_over_ssl.CopyToIfSet(¶ms->force_spdy_over_ssl); |
| 966 globals_->force_spdy_always.CopyToIfSet(¶ms->force_spdy_always); | 985 globals.force_spdy_always.CopyToIfSet(¶ms->force_spdy_always); |
| 967 globals_->forced_spdy_exclusions = params->forced_spdy_exclusions; | 986 params->forced_spdy_exclusions = globals.forced_spdy_exclusions; |
|
jar (doing other things)
2014/06/20 23:25:12
Nice bug fix. +1 for the power of const?
This mi
Ryan Hamilton
2014/06/21 02:45:23
Yeah, const rocks :>
jar (doing other things)
2014/06/22 18:48:34
Comment in this CL (top level) is fine.
thanks!
Ryan Hamilton
2014/06/22 19:48:57
Done. Good idea.
| |
| 968 globals_->use_alternate_protocols.CopyToIfSet( | 987 globals.use_alternate_protocols.CopyToIfSet( |
| 969 ¶ms->use_alternate_protocols); | 988 ¶ms->use_alternate_protocols); |
| 970 globals_->enable_websocket_over_spdy.CopyToIfSet( | 989 globals.enable_websocket_over_spdy.CopyToIfSet( |
| 971 ¶ms->enable_websocket_over_spdy); | 990 ¶ms->enable_websocket_over_spdy); |
| 972 | 991 |
| 973 globals_->enable_quic.CopyToIfSet(¶ms->enable_quic); | 992 globals.enable_quic.CopyToIfSet(¶ms->enable_quic); |
| 974 globals_->enable_quic_pacing.CopyToIfSet( | 993 globals.enable_quic_pacing.CopyToIfSet( |
| 975 ¶ms->enable_quic_pacing); | 994 ¶ms->enable_quic_pacing); |
| 976 globals_->enable_quic_time_based_loss_detection.CopyToIfSet( | 995 globals.enable_quic_time_based_loss_detection.CopyToIfSet( |
| 977 ¶ms->enable_quic_time_based_loss_detection); | 996 ¶ms->enable_quic_time_based_loss_detection); |
| 978 globals_->enable_quic_persist_server_info.CopyToIfSet( | 997 globals.enable_quic_port_selection.CopyToIfSet( |
| 979 ¶ms->enable_quic_persist_server_info); | |
| 980 globals_->enable_quic_port_selection.CopyToIfSet( | |
| 981 ¶ms->enable_quic_port_selection); | 998 ¶ms->enable_quic_port_selection); |
| 982 globals_->quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); | 999 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); |
| 983 globals_->quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); | 1000 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); |
| 984 globals_->quic_supported_versions.CopyToIfSet( | 1001 globals.quic_supported_versions.CopyToIfSet( |
| 985 ¶ms->quic_supported_versions); | 1002 ¶ms->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 ¶ms->origin_to_force_quic_on); | 1006 ¶ms->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 Loading... | |
| 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 std::map<std::string, std::string> params; | |
| 1087 if (!chrome_variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | |
| 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 std::map<std::string, std::string>& 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 std::map<std::string, std::string>& 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 |
| 1142 return quic_trial_group.ends_with(kQuicFieldTrialPacingSuffix); | 1179 if (quic_trial_group.ends_with(kQuicFieldTrialPacingSuffix)) |
|
jar (doing other things)
2014/06/20 23:25:12
I don't think you're consistent about whether "old
Ryan Hamilton
2014/06/21 02:45:23
Good point. Done.
| |
| 1180 return true; | |
| 1181 | |
| 1182 return LowerCaseEqualsASCII( | |
| 1183 GetVariationParam(quic_trial_params, "enable_pacing"), | |
| 1184 "true"); | |
| 1185 } | |
| 1186 | |
| 1187 net::QuicTagVector IOThread::GetQuicConnectionOptions( | |
| 1188 const CommandLine& command_line, | |
| 1189 const std::map<std::string, std::string>& quic_trial_params) { | |
| 1190 net::QuicTagVector options; | |
| 1191 | |
| 1192 std::map<std::string, std::string>::const_iterator it = | |
| 1193 quic_trial_params.find("congestion_options"); | |
| 1194 if (it == quic_trial_params.end()) | |
| 1195 return options; | |
| 1196 | |
| 1197 std::vector<std::string> tokens; | |
| 1198 base::SplitString(it->second, ',', &tokens); | |
| 1199 for (std::vector<std::string>::iterator token = tokens.begin(); | |
|
jar (doing other things)
2014/06/20 23:25:12
nit: Add comment that tokens are expected to be no
Ryan Hamilton
2014/06/21 02:45:23
Done.
| |
| 1200 token != tokens.end(); ++token) { | |
| 1201 uint32 option = 0; | |
| 1202 for (size_t i = token->length() ; i > 0; --i) { | |
| 1203 option <<= 8; | |
| 1204 option |= static_cast<unsigned char>((*token)[i - 1]); | |
| 1205 } | |
| 1206 options.push_back(static_cast<net::QuicTag>(option)); | |
| 1207 } | |
| 1208 return options; | |
| 1143 } | 1209 } |
| 1144 | 1210 |
| 1145 bool IOThread::ShouldEnableQuicTimeBasedLossDetection( | 1211 bool IOThread::ShouldEnableQuicTimeBasedLossDetection( |
| 1146 const CommandLine& command_line, | 1212 const CommandLine& command_line, |
| 1147 base::StringPiece quic_trial_group) { | 1213 base::StringPiece quic_trial_group, |
| 1214 const std::map<std::string, std::string>& quic_trial_params) { | |
| 1148 if (command_line.HasSwitch(switches::kEnableQuicTimeBasedLossDetection)) | 1215 if (command_line.HasSwitch(switches::kEnableQuicTimeBasedLossDetection)) |
| 1149 return true; | 1216 return true; |
| 1150 | 1217 |
| 1151 if (command_line.HasSwitch(switches::kDisableQuicTimeBasedLossDetection)) | 1218 if (command_line.HasSwitch(switches::kDisableQuicTimeBasedLossDetection)) |
| 1152 return false; | 1219 return false; |
| 1153 | 1220 |
| 1154 return quic_trial_group.ends_with( | 1221 if (quic_trial_group.ends_with( |
| 1155 kQuicFieldTrialTimeBasedLossDetectionSuffix); | 1222 kQuicFieldTrialTimeBasedLossDetectionSuffix)) |
| 1223 return true; | |
| 1224 | |
| 1225 return LowerCaseEqualsASCII( | |
| 1226 GetVariationParam(quic_trial_params, "enable_time_based_loss_detection"), | |
| 1227 "true"); | |
| 1156 } | 1228 } |
| 1157 | 1229 |
| 1158 // TODO(rtenneti): Delete this method after the merge. | 1230 size_t IOThread::GetQuicMaxPacketLength( |
| 1159 bool IOThread::ShouldEnableQuicPersistServerInfo( | 1231 const CommandLine& command_line, |
| 1160 const CommandLine& command_line) { | 1232 base::StringPiece quic_trial_group, |
| 1161 return true; | 1233 const std::map<std::string, std::string>& 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)) { | 1234 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { |
| 1167 unsigned value; | 1235 unsigned value; |
| 1168 if (!base::StringToUint( | 1236 if (!base::StringToUint( |
| 1169 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), | 1237 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), |
| 1170 &value)) { | 1238 &value)) { |
| 1171 return 0; | 1239 return 0; |
| 1172 } | 1240 } |
| 1173 return value; | 1241 return value; |
| 1174 } | 1242 } |
| 1175 | 1243 |
| 1244 unsigned value; | |
| 1245 if (base::StringToUint(GetVariationParam(quic_trial_params, | |
| 1246 "max_packet_length"), | |
| 1247 &value)) { | |
| 1248 return value; | |
| 1249 } | |
| 1250 | |
| 1176 // Format of the packet length group names is: | 1251 // Format of the packet length group names is: |
| 1177 // (Https)?Enabled<length>BytePackets. | 1252 // (Https)?Enabled<length>BytePackets. |
| 1178 base::StringPiece length_str(quic_trial_group); | 1253 base::StringPiece length_str(quic_trial_group); |
| 1179 if (length_str.starts_with(kQuicFieldTrialEnabledGroupName)) { | 1254 if (length_str.starts_with(kQuicFieldTrialEnabledGroupName)) { |
| 1180 length_str.remove_prefix(strlen(kQuicFieldTrialEnabledGroupName)); | 1255 length_str.remove_prefix(strlen(kQuicFieldTrialEnabledGroupName)); |
| 1181 } else if (length_str.starts_with(kQuicFieldTrialHttpsEnabledGroupName)) { | 1256 } else if (length_str.starts_with(kQuicFieldTrialHttpsEnabledGroupName)) { |
| 1182 length_str.remove_prefix(strlen(kQuicFieldTrialHttpsEnabledGroupName)); | 1257 length_str.remove_prefix(strlen(kQuicFieldTrialHttpsEnabledGroupName)); |
| 1183 } else { | 1258 } else { |
| 1184 return 0; | 1259 return 0; |
| 1185 } | 1260 } |
| 1186 if (!length_str.ends_with(kQuicFieldTrialPacketLengthSuffix)) { | 1261 if (!length_str.ends_with(kQuicFieldTrialPacketLengthSuffix)) { |
| 1187 return 0; | 1262 return 0; |
| 1188 } | 1263 } |
| 1189 length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix)); | 1264 length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix)); |
| 1190 unsigned value; | |
| 1191 if (!base::StringToUint(length_str, &value)) { | 1265 if (!base::StringToUint(length_str, &value)) { |
| 1192 return 0; | 1266 return 0; |
| 1193 } | 1267 } |
| 1194 return value; | 1268 return value; |
| 1195 } | 1269 } |
| 1196 | 1270 |
| 1197 net::QuicVersion IOThread::GetQuicVersion(const CommandLine& command_line) { | 1271 net::QuicVersion IOThread::GetQuicVersion( |
| 1272 const CommandLine& command_line, | |
| 1273 const std::map<std::string, std::string>& quic_trial_params) { | |
| 1198 if (!command_line.HasSwitch(switches::kQuicVersion)) { | 1274 if (!command_line.HasSwitch(switches::kQuicVersion)) { |
|
jar (doing other things)
2014/06/22 18:48:34
This looks questionable (probably shouldn't have b
Ryan Hamilton
2014/06/22 19:48:57
Yeah, that was ... wrong :> As you surmised, it's
| |
| 1199 return net::QUIC_VERSION_UNSUPPORTED; | 1275 return net::QUIC_VERSION_UNSUPPORTED; |
| 1200 } | 1276 } |
| 1201 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1277 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1202 std::string version_flag = | 1278 std::string version_flag = |
| 1203 command_line.GetSwitchValueASCII(switches::kQuicVersion); | 1279 command_line.GetSwitchValueASCII(switches::kQuicVersion); |
| 1204 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1280 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1205 net::QuicVersion version = supported_versions[i]; | 1281 net::QuicVersion version = supported_versions[i]; |
| 1206 if (net::QuicVersionToString(version) == version_flag) { | 1282 if (net::QuicVersionToString(version) == version_flag) { |
| 1207 return version; | 1283 return version; |
| 1208 } | 1284 } |
| 1209 } | 1285 } |
| 1286 | |
| 1287 version_flag = GetVariationParam(quic_trial_params, "quic_version"); | |
| 1288 for (size_t i = 0; i < supported_versions.size(); ++i) { | |
| 1289 net::QuicVersion version = supported_versions[i]; | |
| 1290 if (net::QuicVersionToString(version) == version_flag) { | |
| 1291 return version; | |
| 1292 } | |
| 1293 } | |
| 1210 return net::QUIC_VERSION_UNSUPPORTED; | 1294 return net::QUIC_VERSION_UNSUPPORTED; |
| 1211 } | 1295 } |
| OLD | NEW |