diff options
author | bnc <bnc@chromium.org> | 2015-10-28 18:05:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-29 01:06:53 +0000 |
commit | 65b99310386c94bbafa0962cd4bf44ddbca864a9 (patch) | |
tree | 91dbec666d80b483f32cadf087e0a3f6bf3624c0 | |
parent | 2f1533a6dca1fa0a0be4f550363f4df64df0e29b (diff) | |
download | chromium_src-65b99310386c94bbafa0962cd4bf44ddbca864a9.zip chromium_src-65b99310386c94bbafa0962cd4bf44ddbca864a9.tar.gz chromium_src-65b99310386c94bbafa0962cd4bf44ddbca864a9.tar.bz2 |
Implement field trial for NPN.
Implement field trial for Next Protocol Negotiation to allow for controlled
deprecation. Default (in absense of field trial) is enabled.
BUG=526713
Review URL: https://codereview.chromium.org/1429683003
Cr-Commit-Position: refs/heads/master@{#356716}
-rw-r--r-- | chrome/browser/io_thread.cc | 21 | ||||
-rw-r--r-- | chrome/browser/io_thread.h | 6 | ||||
-rw-r--r-- | chrome/browser/io_thread_unittest.cc | 25 | ||||
-rw-r--r-- | net/http/http_network_session.cc | 3 | ||||
-rw-r--r-- | net/http/http_network_session.h | 3 |
5 files changed, 57 insertions, 1 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 14f405c..e13d23c 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -155,6 +155,11 @@ const char kSpdyFieldTrialParametrizedPrefix[] = "Parametrized"; // determined by the operating system. const char kNetworkQualityEstimatorFieldTrialName[] = "NetworkQualityEstimator"; +// Field trial for NPN. +const char kNpnTrialName[] = "NPN"; +const char kNpnTrialEnabledGroupNamePrefix[] = "Enable"; +const char kNpnTrialDisabledGroupNamePrefix[] = "Disable"; + #if defined(OS_MACOSX) && !defined(OS_IOS) void ObserveKeychainEvents() { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -884,6 +889,9 @@ void IOThread::InitializeNetworkOptions(const base::CommandLine& command_line) { ConfigureTCPFastOpen(command_line); + ConfigureNPNGlobals(base::FieldTrialList::FindFullName(kNpnTrialName), + globals_); + // TODO(rch): Make the client socket factory a per-network session // instance, constructed from a NetworkSession::Params, to allow us // to move this option to IOThread::Globals & @@ -902,6 +910,7 @@ void IOThread::ConfigureTCPFastOpen(const base::CommandLine& command_line) { net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_if_supported); } +// static void IOThread::ConfigureSpdyGlobals( const base::CommandLine& command_line, base::StringPiece spdy_trial_group, @@ -964,6 +973,16 @@ void IOThread::ConfigureSpdyGlobals( globals->next_protos.push_back(net::kProtoHTTP11); } +// static +void IOThread::ConfigureNPNGlobals(base::StringPiece npn_trial_group, + IOThread::Globals* globals) { + if (npn_trial_group.starts_with(kNpnTrialEnabledGroupNamePrefix)) { + globals->enable_npn.set(true); + } else if (npn_trial_group.starts_with(kNpnTrialDisabledGroupNamePrefix)) { + globals->enable_npn.set(false); + } +} + void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterStringPref(prefs::kAuthSchemes, "basic,digest,ntlm,negotiate"); @@ -1052,6 +1071,8 @@ void IOThread::InitializeNetworkSessionParamsFromGlobals( globals.alternative_service_probability_threshold.CopyToIfSet( ¶ms->alternative_service_probability_threshold); + globals.enable_npn.CopyToIfSet(¶ms->enable_npn); + globals.enable_quic.CopyToIfSet(¶ms->enable_quic); globals.enable_quic_for_proxies.CopyToIfSet(¶ms->enable_quic_for_proxies); globals.quic_always_require_handshake_confirmation.CopyToIfSet( diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h index 33291d6..0b3a688 100644 --- a/chrome/browser/io_thread.h +++ b/chrome/browser/io_thread.h @@ -188,6 +188,8 @@ class IOThread : public content::BrowserThreadDelegate { Optional<bool> use_alternative_services; Optional<double> alternative_service_probability_threshold; + Optional<bool> enable_npn; + Optional<bool> enable_quic; Optional<bool> enable_quic_for_proxies; Optional<bool> enable_quic_port_selection; @@ -290,6 +292,10 @@ class IOThread : public content::BrowserThreadDelegate { const VariationParameters& quic_trial_params, Globals* globals); + // Configures NPN in |globals| based on the field trial group. + static void ConfigureNPNGlobals(base::StringPiece npn_trial_group, + Globals* globals); + // Global state must be initialized on the IO thread, then this // method must be invoked on the UI thread. void InitSystemRequestContext(); diff --git a/chrome/browser/io_thread_unittest.cc b/chrome/browser/io_thread_unittest.cc index 4430306..26bf872 100644 --- a/chrome/browser/io_thread_unittest.cc +++ b/chrome/browser/io_thread_unittest.cc @@ -40,6 +40,11 @@ class IOThreadPeer { spdy_trial_params, globals); } + static void ConfigureNPNGlobals(base::StringPiece npn_trial_group, + IOThread::Globals* globals) { + IOThread::ConfigureNPNGlobals(npn_trial_group, globals); + } + static void InitializeNetworkSessionParamsFromGlobals( const IOThread::Globals& globals, net::HttpNetworkSession::Params* params) { @@ -68,6 +73,10 @@ class IOThreadTest : public testing::Test { field_trial_params_, &globals_); } + void ConfigureNPNGlobals() { + IOThreadPeer::ConfigureNPNGlobals(field_trial_group_, &globals_); + } + void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) { IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params); } @@ -137,6 +146,22 @@ TEST_F(IOThreadTest, SpdyCommandLineUseSpdyOff) { EXPECT_EQ(0u, globals_.next_protos.size()); } +TEST_F(IOThreadTest, NPNFieldTrialEnabled) { + field_trial_group_ = "Enable-experiment"; + ConfigureNPNGlobals(); + net::HttpNetworkSession::Params params; + InitializeNetworkSessionParams(¶ms); + EXPECT_TRUE(params.enable_npn); +} + +TEST_F(IOThreadTest, NPNFieldTrialDisabled) { + field_trial_group_ = "Disable-holdback"; + ConfigureNPNGlobals(); + net::HttpNetworkSession::Params params; + InitializeNetworkSessionParams(¶ms); + EXPECT_FALSE(params.enable_npn); +} + TEST_F(IOThreadTest, DisableQuicByDefault) { ConfigureQuicGlobals(); net::HttpNetworkSession::Params params; diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index 736d5a9..0d58756 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -93,6 +93,7 @@ HttpNetworkSession::Params::Params() time_func(&base::TimeTicks::Now), use_alternative_services(false), alternative_service_probability_threshold(1), + enable_npn(true), enable_quic(false), enable_quic_for_proxies(false), enable_quic_port_selection(true), @@ -330,7 +331,7 @@ void HttpNetworkSession::GetAlpnProtos(NextProtoVector* alpn_protos) const { } void HttpNetworkSession::GetNpnProtos(NextProtoVector* npn_protos) const { - if (HttpStreamFactory::spdy_enabled()) { + if (HttpStreamFactory::spdy_enabled() && params_.enable_npn) { *npn_protos = next_protos_; DisableHTTP2(npn_protos); } else { diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 0075154..20ee21e 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -111,6 +111,9 @@ class NET_EXPORT HttpNetworkSession // than this value. double alternative_service_probability_threshold; + // Enables NPN support. Note that ALPN is always enabled. + bool enable_npn; + // Enables QUIC support. bool enable_quic; // Enables QUIC for proxies. |