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

Unified Diff: chrome/browser/io_thread.cc

Issue 1020363003: Independently enable SPDY versions from field trial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add spdy_enabled toggle and TODO. Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/io_thread.cc
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index ed2f0d670fb2f6e31dd1a7e48ab5c8932fb18b66..5f8941abc2e4a208bc27084a9db31f4a20f38c96 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -136,6 +136,7 @@ const char kSpdyFieldTrialName[] = "SPDY";
const char kSpdyFieldTrialHoldbackGroupNamePrefix[] = "SpdyDisabled";
const char kSpdyFieldTrialSpdy31GroupNamePrefix[] = "Spdy31Enabled";
const char kSpdyFieldTrialSpdy4GroupNamePrefix[] = "Spdy4Enabled";
+const char kSpdyFieldTrialParametrizedPrefix[] = "Parametrized";
// Field trial for Cache-Control: stale-while-revalidate directive.
const char kStaleWhileRevalidateFieldTrialName[] = "StaleWhileRevalidate";
@@ -319,6 +320,100 @@ bool IsCertificateTransparencyRequiredForEV(
return group_name == "RequirementEnforced";
}
+// Parse kUseSpdy command line flag options, which may contain the following:
+//
+// "off" : Disables SPDY support entirely.
+// "ssl" : Forces SPDY for all HTTPS requests.
+// "no-ssl" : Forces SPDY for all HTTP requests.
+// "no-ping" : Disables SPDY ping connection testing.
+// "exclude=<host>" : Disables SPDY support for the host <host>.
+// "no-compress" : Disables SPDY header compression.
+// "no-alt-protocols : Disables alternate protocol support.
+// "force-alt-protocols : Forces an alternate protocol of SPDY/3
+// on port 443.
+// "single-domain" : Forces all spdy traffic to a single domain.
+// "init-max-streams=<limit>" : Specifies the maximum number of concurrent
+// streams for a SPDY session, unless the
+// specifies a different value via SETTINGS.
+void ConfigureSpdyGlobalsFromUseSpdyArgument(const std::string& mode,
+ IOThread::Globals* globals) {
+ static const char kOff[] = "off";
+ static const char kSSL[] = "ssl";
+ static const char kDisableSSL[] = "no-ssl";
+ static const char kDisablePing[] = "no-ping";
+ static const char kExclude[] = "exclude"; // Hosts to exclude
+ static const char kDisableCompression[] = "no-compress";
+ static const char kDisableAltProtocols[] = "no-alt-protocols";
+ static const char kForceAltProtocols[] = "force-alt-protocols";
+ static const char kSingleDomain[] = "single-domain";
+
+ static const char kInitialMaxConcurrentStreams[] = "init-max-streams";
+
+ std::vector<std::string> spdy_options;
+ base::SplitString(mode, ',', &spdy_options);
+
+ for (const std::string& element : spdy_options) {
+ std::vector<std::string> name_value;
+ base::SplitString(element, '=', &name_value);
+ const std::string& option =
+ name_value.size() > 0 ? name_value[0] : std::string();
+ const std::string value =
+ name_value.size() > 1 ? name_value[1] : std::string();
+
+ if (option == kOff) {
+ net::HttpStreamFactory::set_spdy_enabled(false);
+ continue;
+ }
+ if (option == kDisableSSL) {
+ globals->spdy_default_protocol.set(net::kProtoSPDY31);
+ globals->force_spdy_over_ssl.set(false);
+ globals->force_spdy_always.set(true);
+ continue;
+ }
+ if (option == kSSL) {
+ globals->spdy_default_protocol.set(net::kProtoSPDY31);
+ globals->force_spdy_over_ssl.set(true);
+ globals->force_spdy_always.set(true);
+ continue;
+ }
+ if (option == kDisablePing) {
+ globals->enable_spdy_ping_based_connection_checking.set(false);
+ continue;
+ }
+ if (option == kExclude) {
+ globals->forced_spdy_exclusions.insert(
+ net::HostPortPair::FromURL(GURL(value)));
+ continue;
+ }
+ if (option == kDisableCompression) {
+ globals->enable_spdy_compression.set(false);
+ continue;
+ }
+ if (option == kDisableAltProtocols) {
+ globals->use_alternate_protocols.set(false);
+ continue;
+ }
+ if (option == kForceAltProtocols) {
+ net::AlternateProtocolInfo pair(443, net::NPN_SPDY_3, 1);
+ net::HttpServerPropertiesImpl::ForceAlternateProtocol(pair);
+ continue;
+ }
+ if (option == kSingleDomain) {
+ DVLOG(1) << "FORCING SINGLE DOMAIN";
+ globals->force_spdy_single_domain.set(true);
+ continue;
+ }
+ if (option == kInitialMaxConcurrentStreams) {
+ int streams;
+ if (base::StringToInt(value, &streams)) {
+ globals->initial_max_spdy_concurrent_streams.set(streams);
+ continue;
+ }
+ }
+ LOG(DFATAL) << "Unrecognized spdy option: " << option;
+ }
+}
+
} // namespace
class IOThread::LoggingNetworkChangeObserver
@@ -865,28 +960,12 @@ void IOThread::InitializeNetworkOptions(const base::CommandLine& command_line) {
if (trial)
trial->Disable();
} else {
- if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) {
- globals_->trusted_spdy_proxy.set(
- command_line.GetSwitchValueASCII(switches::kTrustedSpdyProxy));
- }
- if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests))
- net::URLFetcher::SetIgnoreCertificateRequests(true);
-
- if (command_line.HasSwitch(switches::kUseSpdy)) {
- std::string spdy_mode =
- command_line.GetSwitchValueASCII(switches::kUseSpdy);
- EnableSpdy(spdy_mode);
- } else if (command_line.HasSwitch(switches::kEnableSpdy4)) {
- globals_->next_protos = net::NextProtosSpdy4Http2();
- globals_->use_alternate_protocols.set(true);
- } else if (command_line.HasSwitch(switches::kEnableNpnHttpOnly)) {
- globals_->next_protos = net::NextProtosHttpOnly();
- globals_->use_alternate_protocols.set(false);
- } else {
- // No SPDY command-line flags have been specified. Examine trial groups.
- ConfigureSpdyFromTrial(
- base::FieldTrialList::FindFullName(kSpdyFieldTrialName), globals_);
+ std::string group = base::FieldTrialList::FindFullName(kSpdyFieldTrialName);
+ VariationParameters params;
+ if (!variations::GetVariationParams(kSpdyFieldTrialName, &params)) {
+ params.clear();
}
+ ConfigureSpdyGlobals(command_line, group, params, globals_);
}
ConfigureTCPFastOpen(command_line);
@@ -930,87 +1009,92 @@ void IOThread::ConfigureSdch() {
}
}
-void IOThread::ConfigureSpdyFromTrial(base::StringPiece spdy_trial_group,
- Globals* globals) {
- if (spdy_trial_group.starts_with(kSpdyFieldTrialHoldbackGroupNamePrefix)) {
- // TODO(jgraettinger): Use net::NextProtosHttpOnly() instead?
- net::HttpStreamFactory::set_spdy_enabled(false);
- } else if (spdy_trial_group.starts_with(
- kSpdyFieldTrialSpdy31GroupNamePrefix)) {
- globals->next_protos = net::NextProtosSpdy31();
- globals->use_alternate_protocols.set(true);
- } else if (spdy_trial_group.starts_with(
- kSpdyFieldTrialSpdy4GroupNamePrefix)) {
- globals->next_protos = net::NextProtosSpdy4Http2();
- globals->use_alternate_protocols.set(true);
- } else {
- // By default, enable HTTP/2.
- globals->next_protos = net::NextProtosSpdy4Http2();
- globals->use_alternate_protocols.set(true);
+// static
+void IOThread::ConfigureSpdyGlobals(
+ const base::CommandLine& command_line,
+ base::StringPiece spdy_trial_group,
+ const VariationParameters& spdy_trial_params,
+ IOThread::Globals* globals) {
+ if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) {
+ globals->trusted_spdy_proxy.set(
+ command_line.GetSwitchValueASCII(switches::kTrustedSpdyProxy));
}
-}
-
-void IOThread::EnableSpdy(const std::string& mode) {
- static const char kOff[] = "off";
- static const char kSSL[] = "ssl";
- static const char kDisableSSL[] = "no-ssl";
- static const char kDisablePing[] = "no-ping";
- static const char kExclude[] = "exclude"; // Hosts to exclude
- static const char kDisableCompression[] = "no-compress";
- static const char kDisableAltProtocols[] = "no-alt-protocols";
- static const char kForceAltProtocols[] = "force-alt-protocols";
- static const char kSingleDomain[] = "single-domain";
+ if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests))
+ net::URLFetcher::SetIgnoreCertificateRequests(true);
- static const char kInitialMaxConcurrentStreams[] = "init-max-streams";
+ if (command_line.HasSwitch(switches::kUseSpdy)) {
+ std::string spdy_mode =
+ command_line.GetSwitchValueASCII(switches::kUseSpdy);
+ ConfigureSpdyGlobalsFromUseSpdyArgument(spdy_mode, globals);
+ return;
+ }
- std::vector<std::string> spdy_options;
- base::SplitString(mode, ',', &spdy_options);
+ globals->next_protos.clear();
+ globals->next_protos.push_back(net::kProtoHTTP11);
+ bool enable_quic = false;
+ globals->enable_quic.CopyToIfSet(&enable_quic);
+ if (enable_quic) {
+ globals->next_protos.push_back(net::kProtoQUIC1SPDY3);
+ }
- for (std::vector<std::string>::iterator it = spdy_options.begin();
- it != spdy_options.end(); ++it) {
- const std::string& element = *it;
- std::vector<std::string> name_value;
- base::SplitString(element, '=', &name_value);
- const std::string& option =
- name_value.size() > 0 ? name_value[0] : std::string();
- const std::string value =
- name_value.size() > 1 ? name_value[1] : std::string();
+ if (command_line.HasSwitch(switches::kEnableSpdy4)) {
+ globals->next_protos.push_back(net::kProtoSPDY31);
+ globals->next_protos.push_back(net::kProtoSPDY4_14);
+ globals->next_protos.push_back(net::kProtoSPDY4);
+ globals->use_alternate_protocols.set(true);
+ return;
+ }
+ if (command_line.HasSwitch(switches::kEnableNpnHttpOnly)) {
+ globals->use_alternate_protocols.set(false);
+ return;
+ }
- if (option == kOff) {
- net::HttpStreamFactory::set_spdy_enabled(false);
- } else if (option == kDisableSSL) {
- globals_->spdy_default_protocol.set(net::kProtoSPDY31);
- globals_->force_spdy_over_ssl.set(false);
- globals_->force_spdy_always.set(true);
- } else if (option == kSSL) {
- globals_->spdy_default_protocol.set(net::kProtoSPDY31);
- globals_->force_spdy_over_ssl.set(true);
- globals_->force_spdy_always.set(true);
- } else if (option == kDisablePing) {
- globals_->enable_spdy_ping_based_connection_checking.set(false);
- } else if (option == kExclude) {
- globals_->forced_spdy_exclusions.insert(
- net::HostPortPair::FromURL(GURL(value)));
- } else if (option == kDisableCompression) {
- globals_->enable_spdy_compression.set(false);
- } else if (option == kDisableAltProtocols) {
- globals_->use_alternate_protocols.set(false);
- } else if (option == kForceAltProtocols) {
- net::AlternateProtocolInfo pair(443, net::NPN_SPDY_3, 1);
- net::HttpServerPropertiesImpl::ForceAlternateProtocol(pair);
- } else if (option == kSingleDomain) {
- DVLOG(1) << "FORCING SINGLE DOMAIN";
- globals_->force_spdy_single_domain.set(true);
- } else if (option == kInitialMaxConcurrentStreams) {
- int streams;
- if (base::StringToInt(value, &streams))
- globals_->initial_max_spdy_concurrent_streams.set(streams);
- } else if (option.empty() && it == spdy_options.begin()) {
- continue;
- } else {
- LOG(DFATAL) << "Unrecognized spdy option: " << option;
+ // No SPDY command-line flags have been specified. Examine trial groups.
+ if (spdy_trial_group.starts_with(kSpdyFieldTrialHoldbackGroupNamePrefix)) {
+ net::HttpStreamFactory::set_spdy_enabled(false);
+ return;
+ }
+ if (spdy_trial_group.starts_with(kSpdyFieldTrialSpdy31GroupNamePrefix)) {
+ globals->next_protos.push_back(net::kProtoSPDY31);
+ globals->use_alternate_protocols.set(true);
+ return;
+ }
+ if (spdy_trial_group.starts_with(kSpdyFieldTrialSpdy4GroupNamePrefix)) {
+ globals->next_protos.push_back(net::kProtoSPDY31);
+ globals->next_protos.push_back(net::kProtoSPDY4_14);
+ globals->next_protos.push_back(net::kProtoSPDY4);
+ globals->use_alternate_protocols.set(true);
+ return;
+ }
+ if (spdy_trial_group.starts_with(kSpdyFieldTrialParametrizedPrefix)) {
+ bool spdy_enabled = false;
+ if (LowerCaseEqualsASCII(
+ GetVariationParam(spdy_trial_params, "enable_spdy31"), "true")) {
+ globals->next_protos.push_back(net::kProtoSPDY31);
+ spdy_enabled = true;
+ }
+ if (LowerCaseEqualsASCII(
+ GetVariationParam(spdy_trial_params, "enable_http2_14"), "true")) {
+ globals->next_protos.push_back(net::kProtoSPDY4_14);
+ spdy_enabled = true;
+ }
+ if (LowerCaseEqualsASCII(
+ GetVariationParam(spdy_trial_params, "enable_http2"), "true")) {
+ globals->next_protos.push_back(net::kProtoSPDY4);
+ spdy_enabled = true;
}
+ // TODO(bnc): HttpStreamFactory::spdy_enabled_ is redundant with
+ // globals->next_protos, can it be eliminated?
+ net::HttpStreamFactory::set_spdy_enabled(spdy_enabled);
+ globals->use_alternate_protocols.set(true);
+ return;
}
+
+ // By default, enable HTTP/2.
+ globals->next_protos.push_back(net::kProtoSPDY31);
+ globals->next_protos.push_back(net::kProtoSPDY4_14);
+ globals->next_protos.push_back(net::kProtoSPDY4);
+ globals->use_alternate_protocols.set(true);
}
// static
« 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