0

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}
This commit is contained in:
tbansal
2015-09-21 16:38:49 -07:00
committed by Commit bot
parent bb1cc5e4d6
commit 5cc3f0a27b
3 changed files with 73 additions and 23 deletions
chrome/browser
components/data_reduction_proxy/core

@ -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");
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,
},
};
ConfigureQuicGlobals();
net::HttpNetworkSession::Params params;
InitializeNetworkSessionParams(&params);
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);
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(&params);
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) {

@ -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;
}
}

@ -121,7 +121,7 @@ bool WarnIfNoDataReductionProxy() {
}
bool IsIncludedInQuicFieldTrial() {
return FieldTrialList::FindFullName(kQuicFieldTrial) == kEnabled;
return FieldTrialList::FindFullName(kQuicFieldTrial).find(kEnabled) == 0;
}
std::string GetQuicFieldTrialName() {