Index: chrome/browser/io_thread.cc |
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc |
index ba8dd0fc1d1954ad22e7fd6bd9500de7a59d6f8b..32d8bb44ee37ccb0e4d26b20d27f16db3d0dea65 100644 |
--- a/chrome/browser/io_thread.cc |
+++ b/chrome/browser/io_thread.cc |
@@ -44,6 +44,7 @@ |
#include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" |
#include "components/data_reduction_proxy/browser/http_auth_handler_data_reduction_proxy.h" |
#include "components/policy/core/common/policy_service.h" |
+#include "components/variations/variations_associated_data.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/cookie_store_factory.h" |
#include "net/base/host_mapping_rules.h" |
@@ -287,6 +288,17 @@ int GetSwitchValueAsInt(const CommandLine& command_line, |
return value; |
} |
+// Returns the value associated with |key| in |params| or "" if the |
+// key is not present in the map. |
+std::string GetVariationParam(const std::map<std::string, std::string>& params, |
+ std::string key) { |
+ std::map<std::string, std::string>::const_iterator it = params.find(key); |
+ if (it == params.end()) |
+ return ""; |
+ |
+ return it->second; |
+} |
+ |
} // namespace |
class IOThread::LoggingNetworkChangeObserver |
@@ -935,58 +947,65 @@ void IOThread::ClearHostCache() { |
void IOThread::InitializeNetworkSessionParams( |
net::HttpNetworkSession::Params* params) { |
- params->host_resolver = globals_->host_resolver.get(); |
- params->cert_verifier = globals_->cert_verifier.get(); |
+ InitializeNetworkSessionParamsFromGlobals(*globals_, params); |
+} |
+ |
+// static |
+void IOThread::InitializeNetworkSessionParamsFromGlobals( |
+ const IOThread::Globals& globals, |
+ net::HttpNetworkSession::Params* params) { |
+ params->host_resolver = globals.host_resolver.get(); |
+ params->cert_verifier = globals.cert_verifier.get(); |
params->server_bound_cert_service = |
- globals_->system_server_bound_cert_service.get(); |
- params->transport_security_state = globals_->transport_security_state.get(); |
- params->ssl_config_service = globals_->ssl_config_service.get(); |
- params->http_auth_handler_factory = globals_->http_auth_handler_factory.get(); |
+ globals.system_server_bound_cert_service.get(); |
+ params->transport_security_state = globals.transport_security_state.get(); |
+ params->ssl_config_service = globals.ssl_config_service.get(); |
+ params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); |
params->http_server_properties = |
- globals_->http_server_properties->GetWeakPtr(); |
- params->network_delegate = globals_->system_network_delegate.get(); |
- params->host_mapping_rules = globals_->host_mapping_rules.get(); |
- params->ignore_certificate_errors = globals_->ignore_certificate_errors; |
- params->testing_fixed_http_port = globals_->testing_fixed_http_port; |
- params->testing_fixed_https_port = globals_->testing_fixed_https_port; |
- |
- globals_->initial_max_spdy_concurrent_streams.CopyToIfSet( |
+ globals.http_server_properties->GetWeakPtr(); |
+ params->network_delegate = globals.system_network_delegate.get(); |
+ params->host_mapping_rules = globals.host_mapping_rules.get(); |
+ params->ignore_certificate_errors = globals.ignore_certificate_errors; |
+ params->testing_fixed_http_port = globals.testing_fixed_http_port; |
+ params->testing_fixed_https_port = globals.testing_fixed_https_port; |
+ |
+ globals.initial_max_spdy_concurrent_streams.CopyToIfSet( |
¶ms->spdy_initial_max_concurrent_streams); |
- globals_->force_spdy_single_domain.CopyToIfSet( |
+ globals.force_spdy_single_domain.CopyToIfSet( |
¶ms->force_spdy_single_domain); |
- globals_->enable_spdy_compression.CopyToIfSet( |
+ globals.enable_spdy_compression.CopyToIfSet( |
¶ms->enable_spdy_compression); |
- globals_->enable_spdy_ping_based_connection_checking.CopyToIfSet( |
+ globals.enable_spdy_ping_based_connection_checking.CopyToIfSet( |
¶ms->enable_spdy_ping_based_connection_checking); |
- globals_->spdy_default_protocol.CopyToIfSet( |
+ globals.spdy_default_protocol.CopyToIfSet( |
¶ms->spdy_default_protocol); |
- params->next_protos = globals_->next_protos; |
- globals_->trusted_spdy_proxy.CopyToIfSet(¶ms->trusted_spdy_proxy); |
- globals_->force_spdy_over_ssl.CopyToIfSet(¶ms->force_spdy_over_ssl); |
- globals_->force_spdy_always.CopyToIfSet(¶ms->force_spdy_always); |
- globals_->forced_spdy_exclusions = params->forced_spdy_exclusions; |
- globals_->use_alternate_protocols.CopyToIfSet( |
+ params->next_protos = globals.next_protos; |
+ globals.trusted_spdy_proxy.CopyToIfSet(¶ms->trusted_spdy_proxy); |
+ globals.force_spdy_over_ssl.CopyToIfSet(¶ms->force_spdy_over_ssl); |
+ globals.force_spdy_always.CopyToIfSet(¶ms->force_spdy_always); |
+ 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.
|
+ globals.use_alternate_protocols.CopyToIfSet( |
¶ms->use_alternate_protocols); |
- globals_->enable_websocket_over_spdy.CopyToIfSet( |
+ globals.enable_websocket_over_spdy.CopyToIfSet( |
¶ms->enable_websocket_over_spdy); |
- globals_->enable_quic.CopyToIfSet(¶ms->enable_quic); |
- globals_->enable_quic_pacing.CopyToIfSet( |
+ globals.enable_quic.CopyToIfSet(¶ms->enable_quic); |
+ globals.enable_quic_pacing.CopyToIfSet( |
¶ms->enable_quic_pacing); |
- globals_->enable_quic_time_based_loss_detection.CopyToIfSet( |
+ globals.enable_quic_time_based_loss_detection.CopyToIfSet( |
¶ms->enable_quic_time_based_loss_detection); |
- globals_->enable_quic_persist_server_info.CopyToIfSet( |
- ¶ms->enable_quic_persist_server_info); |
- globals_->enable_quic_port_selection.CopyToIfSet( |
+ globals.enable_quic_port_selection.CopyToIfSet( |
¶ms->enable_quic_port_selection); |
- globals_->quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); |
- globals_->quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); |
- globals_->quic_supported_versions.CopyToIfSet( |
+ globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); |
+ globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); |
+ globals.quic_supported_versions.CopyToIfSet( |
¶ms->quic_supported_versions); |
- globals_->origin_to_force_quic_on.CopyToIfSet( |
+ params->quic_connection_options = globals.quic_connection_options; |
+ |
+ globals.origin_to_force_quic_on.CopyToIfSet( |
¶ms->origin_to_force_quic_on); |
params->enable_user_alternate_protocol_ports = |
- globals_->enable_user_alternate_protocol_ports; |
+ globals.enable_user_alternate_protocol_ports; |
} |
base::TimeTicks IOThread::creation_time() const { |
@@ -1062,26 +1081,42 @@ void IOThread::ConfigureQuic(const CommandLine& command_line) { |
// Always fetch the field trial group to ensure it is reported correctly. |
// The command line flags will be associated with a group that is reported |
// so long as trial is actually queried. |
- std::string quic_trial_group = |
+ std::string group = |
base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
+ std::map<std::string, std::string> params; |
+ if (!chrome_variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
+ params.clear(); |
+ } |
+ ConfigureQuicGlobals(command_line, group, params, globals_); |
+} |
+ |
+// static |
+void IOThread::ConfigureQuicGlobals( |
+ const base::CommandLine& command_line, |
+ base::StringPiece quic_trial_group, |
+ const std::map<std::string, std::string>& quic_trial_params, |
+ IOThread::Globals* globals) { |
bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); |
- globals_->enable_quic.set(enable_quic); |
+ globals->enable_quic.set(enable_quic); |
if (enable_quic) { |
- globals_->enable_quic_pacing.set( |
- ShouldEnableQuicPacing(command_line, quic_trial_group)); |
- globals_->enable_quic_time_based_loss_detection.set( |
- ShouldEnableQuicTimeBasedLossDetection(command_line, quic_trial_group)); |
- globals_->enable_quic_persist_server_info.set( |
- ShouldEnableQuicPersistServerInfo(command_line)); |
- globals_->enable_quic_port_selection.set( |
+ globals->enable_quic_pacing.set( |
+ ShouldEnableQuicPacing(command_line, quic_trial_group, |
+ quic_trial_params)); |
+ globals->enable_quic_time_based_loss_detection.set( |
+ ShouldEnableQuicTimeBasedLossDetection(command_line, quic_trial_group, |
+ quic_trial_params)); |
+ globals->enable_quic_port_selection.set( |
ShouldEnableQuicPortSelection(command_line)); |
+ globals->quic_connection_options = |
+ GetQuicConnectionOptions(command_line, quic_trial_params); |
} |
size_t max_packet_length = GetQuicMaxPacketLength(command_line, |
- quic_trial_group); |
+ quic_trial_group, |
+ quic_trial_params); |
if (max_packet_length != 0) { |
- globals_->quic_max_packet_length.set(max_packet_length); |
+ globals->quic_max_packet_length.set(max_packet_length); |
} |
std::string quic_user_agent_id = |
@@ -1089,13 +1124,13 @@ void IOThread::ConfigureQuic(const CommandLine& command_line) { |
quic_user_agent_id.append(1, ' '); |
chrome::VersionInfo version_info; |
quic_user_agent_id.append(version_info.ProductNameAndVersionForUserAgent()); |
- globals_->quic_user_agent_id.set(quic_user_agent_id); |
+ globals->quic_user_agent_id.set(quic_user_agent_id); |
- net::QuicVersion version = GetQuicVersion(command_line); |
+ net::QuicVersion version = GetQuicVersion(command_line, quic_trial_params); |
if (version != net::QUIC_VERSION_UNSUPPORTED) { |
net::QuicVersionVector supported_versions; |
supported_versions.push_back(version); |
- globals_->quic_supported_versions.set(supported_versions); |
+ globals->quic_supported_versions.set(supported_versions); |
} |
if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) { |
@@ -1103,7 +1138,7 @@ void IOThread::ConfigureQuic(const CommandLine& command_line) { |
net::HostPortPair::FromString( |
command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn)); |
if (!quic_origin.IsEmpty()) { |
- globals_->origin_to_force_quic_on.set(quic_origin); |
+ globals->origin_to_force_quic_on.set(quic_origin); |
} |
} |
} |
@@ -1131,38 +1166,71 @@ bool IOThread::ShouldEnableQuicPortSelection( |
return false; // Default to disabling port selection on all channels. |
} |
-bool IOThread::ShouldEnableQuicPacing(const CommandLine& command_line, |
- base::StringPiece quic_trial_group) { |
+bool IOThread::ShouldEnableQuicPacing( |
+ const CommandLine& command_line, |
+ base::StringPiece quic_trial_group, |
+ const std::map<std::string, std::string>& quic_trial_params) { |
if (command_line.HasSwitch(switches::kEnableQuicPacing)) |
return true; |
if (command_line.HasSwitch(switches::kDisableQuicPacing)) |
return false; |
- return quic_trial_group.ends_with(kQuicFieldTrialPacingSuffix); |
+ 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.
|
+ return true; |
+ |
+ return LowerCaseEqualsASCII( |
+ GetVariationParam(quic_trial_params, "enable_pacing"), |
+ "true"); |
+} |
+ |
+net::QuicTagVector IOThread::GetQuicConnectionOptions( |
+ const CommandLine& command_line, |
+ const std::map<std::string, std::string>& quic_trial_params) { |
+ net::QuicTagVector options; |
+ |
+ std::map<std::string, std::string>::const_iterator it = |
+ quic_trial_params.find("congestion_options"); |
+ if (it == quic_trial_params.end()) |
+ return options; |
+ |
+ std::vector<std::string> tokens; |
+ base::SplitString(it->second, ',', &tokens); |
+ 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.
|
+ token != tokens.end(); ++token) { |
+ uint32 option = 0; |
+ for (size_t i = token->length() ; i > 0; --i) { |
+ option <<= 8; |
+ option |= static_cast<unsigned char>((*token)[i - 1]); |
+ } |
+ options.push_back(static_cast<net::QuicTag>(option)); |
+ } |
+ return options; |
} |
bool IOThread::ShouldEnableQuicTimeBasedLossDetection( |
const CommandLine& command_line, |
- base::StringPiece quic_trial_group) { |
+ base::StringPiece quic_trial_group, |
+ const std::map<std::string, std::string>& quic_trial_params) { |
if (command_line.HasSwitch(switches::kEnableQuicTimeBasedLossDetection)) |
return true; |
if (command_line.HasSwitch(switches::kDisableQuicTimeBasedLossDetection)) |
return false; |
- return quic_trial_group.ends_with( |
- kQuicFieldTrialTimeBasedLossDetectionSuffix); |
-} |
+ if (quic_trial_group.ends_with( |
+ kQuicFieldTrialTimeBasedLossDetectionSuffix)) |
+ return true; |
-// TODO(rtenneti): Delete this method after the merge. |
-bool IOThread::ShouldEnableQuicPersistServerInfo( |
- const CommandLine& command_line) { |
- return true; |
+ return LowerCaseEqualsASCII( |
+ GetVariationParam(quic_trial_params, "enable_time_based_loss_detection"), |
+ "true"); |
} |
-size_t IOThread::GetQuicMaxPacketLength(const CommandLine& command_line, |
- base::StringPiece quic_trial_group) { |
+size_t IOThread::GetQuicMaxPacketLength( |
+ const CommandLine& command_line, |
+ base::StringPiece quic_trial_group, |
+ const std::map<std::string, std::string>& quic_trial_params) { |
if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { |
unsigned value; |
if (!base::StringToUint( |
@@ -1173,6 +1241,13 @@ size_t IOThread::GetQuicMaxPacketLength(const CommandLine& command_line, |
return value; |
} |
+ unsigned value; |
+ if (base::StringToUint(GetVariationParam(quic_trial_params, |
+ "max_packet_length"), |
+ &value)) { |
+ return value; |
+ } |
+ |
// Format of the packet length group names is: |
// (Https)?Enabled<length>BytePackets. |
base::StringPiece length_str(quic_trial_group); |
@@ -1187,14 +1262,15 @@ size_t IOThread::GetQuicMaxPacketLength(const CommandLine& command_line, |
return 0; |
} |
length_str.remove_suffix(strlen(kQuicFieldTrialPacketLengthSuffix)); |
- unsigned value; |
if (!base::StringToUint(length_str, &value)) { |
return 0; |
} |
return value; |
} |
-net::QuicVersion IOThread::GetQuicVersion(const CommandLine& command_line) { |
+net::QuicVersion IOThread::GetQuicVersion( |
+ const CommandLine& command_line, |
+ const std::map<std::string, std::string>& quic_trial_params) { |
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
|
return net::QUIC_VERSION_UNSUPPORTED; |
} |
@@ -1207,5 +1283,13 @@ net::QuicVersion IOThread::GetQuicVersion(const CommandLine& command_line) { |
return version; |
} |
} |
+ |
+ version_flag = GetVariationParam(quic_trial_params, "quic_version"); |
+ for (size_t i = 0; i < supported_versions.size(); ++i) { |
+ net::QuicVersion version = supported_versions[i]; |
+ if (net::QuicVersionToString(version) == version_flag) { |
+ return version; |
+ } |
+ } |
return net::QUIC_VERSION_UNSUPPORTED; |
} |