From 5cc3f0a27b1c73102bfeee73d6fe24e3400de633 Mon Sep 17 00:00:00 2001 From: tbansal Date: Mon, 21 Sep 2015 16:38:49 -0700 Subject: [PATCH] Use QUIC for DataReductionProxy if user belongs to field trial group that starts with "Enabled". Currently, QUIC is used if the field trial group is exactly "Enabled". This change allows us to have multiple Enabled groups (e.g., "Enabled", "Enabled2" etc.). BUG=533703 Review URL: https://codereview.chromium.org/1354283002 Cr-Commit-Position: refs/heads/master@{#350061} --- chrome/browser/io_thread_unittest.cc | 50 +++++++++++++++++----- .../data_reduction_proxy_settings_unittest.cc | 46 ++++++++++++++------ .../core/common/data_reduction_proxy_params.cc | 2 +- 3 files changed, 74 insertions(+), 24 deletions(-) diff --git a/chrome/browser/io_thread_unittest.cc b/chrome/browser/io_thread_unittest.cc index ea83be907248..f2ce96c50d76 100644 --- a/chrome/browser/io_thread_unittest.cc +++ b/chrome/browser/io_thread_unittest.cc @@ -177,17 +177,45 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { } TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { - base::FieldTrialList field_trial_list(new base::MockEntropyProvider()); - base::FieldTrialList::CreateFieldTrial( - data_reduction_proxy::params::GetQuicFieldTrialName(), "Enabled"); - - ConfigureQuicGlobals(); - net::HttpNetworkSession::Params params; - InitializeNetworkSessionParams(¶ms); - EXPECT_FALSE(params.enable_quic); - EXPECT_TRUE(params.enable_quic_for_proxies); - EXPECT_TRUE(IOThread::ShouldEnableQuicForDataReductionProxy()); - EXPECT_EQ(1024 * 1024, params.quic_socket_receive_buffer_size); + const struct { + std::string field_trial_group_name; + bool expect_enable_quic; + } tests[] = { + { + std::string(), false, + }, + { + "NotEnabled", false, + }, + { + "Control", false, + }, + { + "Disabled", false, + }, + { + "EnabledControl", true, + }, + { + "Enabled", true, + }, + }; + + for (size_t i = 0; i < arraysize(tests); ++i) { + base::FieldTrialList field_trial_list(new base::MockEntropyProvider()); + base::FieldTrialList::CreateFieldTrial( + data_reduction_proxy::params::GetQuicFieldTrialName(), + tests[i].field_trial_group_name); + + ConfigureQuicGlobals(); + net::HttpNetworkSession::Params params; + InitializeNetworkSessionParams(¶ms); + EXPECT_FALSE(params.enable_quic) << i; + EXPECT_EQ(tests[i].expect_enable_quic, params.enable_quic_for_proxies) << i; + EXPECT_EQ(tests[i].expect_enable_quic, + IOThread::ShouldEnableQuicForDataReductionProxy()) + << i; + } } TEST_F(IOThreadTest, EnableQuicFromCommandLine) { diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc index a9c9322baeb9..2c1b10dec262 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc @@ -665,8 +665,31 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) { } TEST_F(DataReductionProxySettingsTest, CheckQUICFieldTrials) { - for (int i = 0; i < 2; ++i) { - bool enable_quic = i == 0; + const struct { + bool enable_quic; + std::string field_trial_group_name; + } tests[] = { + { + false, std::string(), + }, + { + false, "NotEnabled", + }, + { + false, "Control", + }, + { + false, "Disabled", + }, + { + true, "EnabledControl", + }, + { + true, "Enabled", + }, + }; + + for (size_t i = 0; i < arraysize(tests); ++i) { // No call to |AddProxyToCommandLine()| was made, so the proxy feature // should be unavailable. // Clear the command line. Setting flags can force the proxy to be allowed. @@ -682,23 +705,22 @@ TEST_F(DataReductionProxySettingsTest, CheckQUICFieldTrials) { test_context_->CreateDataReductionProxyService(settings_.get())); base::FieldTrialList field_trial_list(new base::MockEntropyProvider()); - if (enable_quic) { - base::FieldTrialList::CreateFieldTrial(params::GetQuicFieldTrialName(), - "Enabled"); - } else { - base::FieldTrialList::CreateFieldTrial(params::GetQuicFieldTrialName(), - "Disabled"); - } - test_context_->config()->EnableQuic(enable_quic); + + base::FieldTrialList::CreateFieldTrial(params::GetQuicFieldTrialName(), + tests[i].field_trial_group_name); + EXPECT_EQ( + tests[i].field_trial_group_name, + base::FieldTrialList::FindFullName(params::GetQuicFieldTrialName())); + test_context_->config()->EnableQuic(tests[i].enable_quic); settings_->SetCallbackToRegisterSyntheticFieldTrial( base::Bind(&DataReductionProxySettingsTestBase:: - SyntheticFieldTrialRegistrationCallback, + SyntheticFieldTrialRegistrationCallback, base::Unretained(this))); net::ProxyServer origin = test_context_->config()->test_params()->proxies_for_http().front(); - EXPECT_EQ(enable_quic, origin.is_quic()) << i; + EXPECT_EQ(tests[i].enable_quic, origin.is_quic()) << i; } } diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc index f88dd58b24c6..b4c22651c660 100644 --- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc +++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc @@ -121,7 +121,7 @@ bool WarnIfNoDataReductionProxy() { } bool IsIncludedInQuicFieldTrial() { - return FieldTrialList::FindFullName(kQuicFieldTrial) == kEnabled; + return FieldTrialList::FindFullName(kQuicFieldTrial).find(kEnabled) == 0; } std::string GetQuicFieldTrialName() { -- 2.11.4.GIT