From 3231b619a191e753e8b64c2061a1d5e2c99aa8b7 Mon Sep 17 00:00:00 2001 From: "rtenneti@chromium.org" Date: Fri, 23 Mar 2012 05:57:54 +0000 Subject: SPDY - Added enabling of SPDY/3 and SPDY flow control to about:flags. Added command line switches --enable-spdy3 to enable SPDY/3 and --enable-spdy-flow-control to enable flow control (SPDY/2.1). Added Field Trials for SPDY/2.1 and SPDY/3. The FieldTrials are enabled when SPDY/3 and flow control command line options are not chosen. Removed --use-spdy=v3 and --use-spdy=flow-control options. BUG=118440,119205 R=willchan TEST=Netowrk unit tests and browser tests. Enable SPDY/3 in about:flags and see in chrome://net-internals that SPDY/2, SPDY/2.1 and SPDY/3 are displayed as the protocols supported. Enable SPDY FLow Control in about:flags and see in chrome://net-internals that SPDY/2 and SPDY/2.1 are displayed as the protocols supported. Review URL: http://codereview.chromium.org/9766021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128420 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 12 ++++++++++++ chrome/browser/about_flags.cc | 14 ++++++++++++++ chrome/browser/chrome_browser_main.cc | 29 +++++++++++++++++++++++++++++ chrome/common/chrome_switches.cc | 6 ++++++ chrome/common/chrome_switches.h | 2 ++ net/http/http_network_layer.cc | 20 -------------------- net/http/http_stream_factory.cc | 19 +++++++++++++++++++ net/http/http_stream_factory.h | 10 ++++++++++ 8 files changed, 92 insertions(+), 20 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 147ae68..57488c0 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5125,6 +5125,18 @@ Keep your key file in a safe place. You will need it to create new versions of y Enable experimental pipelining of HTTP requests. + + Enable Flow Control and SPDY/2.1 + + + Enable experimental SPDY/2.1 for flow control. + + + Enable SPDY/3 + + + Enable experimental SPDY/3. + Built-in Asynchronous DNS diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index d82ddd8..38f7727 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -441,6 +441,20 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining) }, { + "enable-spdy3", + IDS_FLAGS_ENABLE_SPDY3_NAME, + IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION, + kOsAll, + SINGLE_VALUE_TYPE(switches::kEnableSpdy3) + }, + { + "enable-spdy-flow-control", + IDS_FLAGS_ENABLE_SPDY_FLOW_CONTROL_NAME, + IDS_FLAGS_ENABLE_SPDY_FLOW_CONTROL_DESCRIPTION, + kOsAll, + SINGLE_VALUE_TYPE(switches::kEnableSpdyFlowControl) + }, + { "enable-async-dns", IDS_FLAGS_ENABLE_ASYNC_DNS_NAME, IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION, diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index a7c3cac..70b629a 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -806,6 +806,35 @@ void ChromeBrowserMainParts::SpdyFieldTrial() { if (value > 0) net::SpdySession::set_max_concurrent_streams(value); } + + if (parsed_command_line().HasSwitch(switches::kEnableSpdy3)) { + net::HttpStreamFactory::EnableSPDY3(); + } else if (parsed_command_line().HasSwitch( + switches::kEnableSpdyFlowControl)) { + net::HttpStreamFactory::EnableFlowControl(); + } else { + const base::FieldTrial::Probability kSpdyDivisor = 100; + base::FieldTrial::Probability flow_control_probability = 5; + base::FieldTrial::Probability spdy3_probability = 0; + + // After October 30, 2012 builds, it will always be in default group + // (disable_spdy_protocol_test). + scoped_refptr trial( + new base::FieldTrial( + "SpdyProtocolTest", kSpdyDivisor, "disable_spdy_protocol_test", + 2012, 10, 30)); + + int spdy3_grp = trial->AppendGroup("spdy3", spdy3_probability); + int flow_control_grp = trial->AppendGroup( + "flow_control", flow_control_probability); + + int trial_grp = trial->group(); + if (trial_grp == spdy3_grp) { + net::HttpStreamFactory::EnableSPDY3(); + } else if (trial_grp == flow_control_grp) { + net::HttpStreamFactory::EnableFlowControl(); + } + } } // If --socket-reuse-policy is not specified, run an A/B test for choosing the diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 239da7d..d493a98 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -581,6 +581,12 @@ const char kEnableProfiling[] = "enable-profiling"; // supported server-side for searches on google.com. const char kEnableSdch[] = "enable-sdch"; +// Enable SPDY/3. This is a temporary testing flag. +const char kEnableSpdy3[] = "enable-spdy3"; + +// Enable SPDY's FlowControl (SPDY/2.1). This is a temporary testing flag. +const char kEnableSpdyFlowControl[] = "enable-spdy-flow-control"; + // Enables experimental suggestions pane in New Tab page. const char kEnableSuggestionsTabPage[] = "enable-suggestions-ntp"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index f54ec8d..051efe6 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -163,6 +163,8 @@ extern const char kEnablePnacl[]; extern const char kEnableProfiling[]; extern const char kEnableResourceContentSettings[]; extern const char kEnableSdch[]; +extern const char kEnableSpdy3[]; +extern const char kEnableSpdyFlowControl[]; extern const char kEnableSuggestionsTabPage[]; extern const char kEnableSyncTabs[]; extern const char kDisableSyncTabs[]; diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index f8da78d..0ae03d2 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -46,16 +46,9 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) { static const char kExclude[] = "exclude"; // Hosts to exclude static const char kDisableCompression[] = "no-compress"; static const char kDisableAltProtocols[] = "no-alt-protocols"; - static const char kEnableVersionThree[] = "v3"; static const char kForceAltProtocols[] = "force-alt-protocols"; static const char kSingleDomain[] = "single-domain"; - // If flow-control is enabled, received WINDOW_UPDATE and SETTINGS - // messages are processed and outstanding window size is actually obeyed - // when sending data frames, and WINDOW_UPDATE messages are generated - // when data is consumed. - static const char kEnableFlowControl[] = "flow-control"; - // We want an A/B experiment between SPDY enabled and SPDY disabled, // but only for pages where SPDY *could have been* negotiated. To do // this, we use NPN, but prevent it from negotiating SPDY. If the @@ -103,13 +96,6 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) { next_protos.push_back("http/1.1"); next_protos.push_back("spdy/2"); HttpStreamFactory::SetNextProtos(next_protos); - } else if (option == kEnableVersionThree) { - std::vector next_protos; - next_protos.push_back("http/1.1"); - next_protos.push_back("spdy/2"); - next_protos.push_back("spdy/2.1"); - next_protos.push_back("spdy/3"); - HttpStreamFactory::SetNextProtos(next_protos); } else if (option == kEnableNpnHttpOnly) { // Avoid alternate protocol in this case. Otherwise, browser will try SSL // and then fallback to http. This introduces extra load. @@ -121,12 +107,6 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) { } else if (option == kDisableAltProtocols) { use_alt_protocols = false; HttpStreamFactory::set_use_alternate_protocols(false); - } else if (option == kEnableFlowControl) { - std::vector next_protos; - next_protos.push_back("http/1.1"); - next_protos.push_back("spdy/2"); - next_protos.push_back("spdy/2.1"); - HttpStreamFactory::SetNextProtos(next_protos); } else if (option == kForceAltProtocols) { PortAlternateProtocolPair pair; pair.port = 443; diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc index dda9951..dee1874 100644 --- a/net/http/http_stream_factory.cc +++ b/net/http/http_stream_factory.cc @@ -149,6 +149,25 @@ bool HttpStreamFactory::HasSpdyExclusion(const HostPortPair& endpoint) { } // static +void HttpStreamFactory::EnableFlowControl() { + std::vector next_protos; + next_protos.push_back("http/1.1"); + next_protos.push_back("spdy/2"); + next_protos.push_back("spdy/2.1"); + SetNextProtos(next_protos); +} + +// static +void HttpStreamFactory::EnableSPDY3() { + std::vector next_protos; + next_protos.push_back("http/1.1"); + next_protos.push_back("spdy/2"); + next_protos.push_back("spdy/2.1"); + next_protos.push_back("spdy/3"); + SetNextProtos(next_protos); +} + +// static void HttpStreamFactory::SetNextProtos(const std::vector& value) { if (!next_protos_) next_protos_ = new std::vector; diff --git a/net/http/http_stream_factory.h b/net/http/http_stream_factory.h index 8c726bb..ff32589 100644 --- a/net/http/http_stream_factory.h +++ b/net/http/http_stream_factory.h @@ -230,6 +230,16 @@ class NET_EXPORT HttpStreamFactory { // Check if a HostPortPair is excluded from using spdy. static bool HasSpdyExclusion(const HostPortPair& endpoint); + // Sets http/1.1, spdy/2, spdy/2.1 and spdy/3 as the protocols supported. + static void EnableSPDY3(); + + // Sets http/1.1, spdy/2 and spdy/2.1 as the protocols supported. + // If flow-control is enabled, received WINDOW_UPDATE and SETTINGS messages + // are processed and outstanding window size is actually obeyed when sending + // data frames, and WINDOW_UPDATE messages are generated when data is + // consumed. + static void EnableFlowControl(); + // Sets the protocols supported by NPN (next protocol negotiation) during the // SSL handshake as well as by HTTP Alternate-Protocol. static void SetNextProtos(const std::vector& value); -- cgit v1.1