Commit ba1a94a0 authored by bengr@chromium.org's avatar bengr@chromium.org

Added data reduction proxy holdback experiment

When this field trial is enabled and the data reduction proxy is
enabled, all UI elements will indicate that the proxy is enabled,
but the proxy will not be used.

BUG=357793, 394541

Review URL: https://codereview.chromium.org/388663002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283905 0039d316-1c4b-4281-b951-d872f2087c98
parent 99ea16bb
......@@ -195,7 +195,7 @@ void DataReductionProxySettingsAndroid::SetProxyConfigs(
LogProxyState(enabled, restricted, at_startup);
if (enabled) {
if (enabled && !params()->holdback()) {
if (alternative_enabled) {
configurator()->Enable(restricted,
!params()->fallback_allowed(),
......
......@@ -53,6 +53,8 @@ KeyedService* DataReductionProxySettingsFactoryAndroid::BuildServiceInstanceFor(
flags |= DataReductionProxyParams::kAlternativeAllowed;
if (DataReductionProxyParams::IsIncludedInPromoFieldTrial())
flags |= DataReductionProxyParams::kPromoAllowed;
if (DataReductionProxyParams::IsIncludedInHoldbackFieldTrial())
flags |= DataReductionProxyParams::kHoldback;
DataReductionProxySettingsAndroid* settings =
new DataReductionProxySettingsAndroid(
......
......@@ -26,7 +26,11 @@ const char kDataReductionProxyDev[] = "http://foo-dev.com:80";
template <class C>
void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings(
bool allowed, bool fallback_allowed, bool alt_allowed, bool promo_allowed) {
bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool promo_allowed,
bool holdback) {
int flags = 0;
if (allowed)
flags |= DataReductionProxyParams::kAllowed;
......@@ -36,6 +40,8 @@ void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings(
flags |= DataReductionProxyParams::kAlternativeAllowed;
if (promo_allowed)
flags |= DataReductionProxyParams::kPromoAllowed;
if (holdback)
flags |= DataReductionProxyParams::kHoldback;
MockDataReductionProxySettings<C>* settings =
new MockDataReductionProxySettings<C>(flags);
EXPECT_CALL(*settings, GetOriginalProfilePrefs())
......@@ -81,7 +87,8 @@ data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings<
DataReductionProxySettingsAndroid>(bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool promo_allowed);
bool promo_allowed,
bool holdback);
template void
data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult<
......@@ -125,7 +132,7 @@ TEST_F(DataReductionProxySettingsAndroidTest,
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
data_reduction_proxy::switches::kDataReductionProxyDev,
kDataReductionProxyDev);
ResetSettings(true, true, false, true);
ResetSettings(true, true, false, true, false);
ScopedJavaLocalRef<jstring> result =
Settings()->GetDataReductionProxyOrigin(env_, NULL);
ASSERT_TRUE(result.obj());
......
......@@ -52,11 +52,17 @@ bool DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() {
"DataCompressionProxyCriticalBypass") == kEnabled;
}
bool DataReductionProxyParams::IsIncludedInHoldbackFieldTrial() {
return FieldTrialList::FindFullName(
"DataCompressionProxyHoldback") == kEnabled;
}
DataReductionProxyParams::DataReductionProxyParams(int flags)
: allowed_((flags & kAllowed) == kAllowed),
fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback),
configured_on_command_line_(false) {
bool result = Init(allowed_, fallback_allowed_, alt_allowed_);
DCHECK(result);
......@@ -92,6 +98,7 @@ DataReductionProxyParams::DataReductionProxyParams(int flags,
fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback),
configured_on_command_line_(false) {
if (should_call_init) {
bool result = Init(allowed_, fallback_allowed_, alt_allowed_);
......
......@@ -24,10 +24,15 @@ namespace data_reduction_proxy {
// the necessary DNS names to configure use of the data reduction proxy.
class DataReductionProxyParams {
public:
// Flags used during construction that specify if the data reduction proxy
// is allowed to be used, if the fallback proxy is allowed to be used, if
// an alternative set of proxies is allowed to be used, if the promotion is
// allowed to be shown, and if this instance is part of a holdback experiment.
static const unsigned int kAllowed = (1 << 0);
static const unsigned int kFallbackAllowed = (1 << 1);
static const unsigned int kAlternativeAllowed = (1 << 2);
static const unsigned int kPromoAllowed = (1 << 3);
static const unsigned int kHoldback = (1 << 4);
typedef std::vector<GURL> DataReductionProxyList;
......@@ -51,6 +56,13 @@ class DataReductionProxyParams {
// proxy if the request resource type is on the critical path (e.g. HTML).
static bool IsIncludedInCriticalPathBypassFieldTrial();
// Returns true if this client is part of a field trial that runs a holdback
// experiment. A holdback experiment is one in which a fraction of browser
// instances will not be configured to use the data reduction proxy even if
// users have enabled it to be used. The UI will not indicate that a holdback
// is in effect.
static bool IsIncludedInHoldbackFieldTrial();
// Constructs configuration parameters. If |kAllowed|, then the standard
// data reduction proxy configuration is allowed to be used. If
// |kfallbackAllowed| a fallback proxy can be used if the primary proxy is
......@@ -151,6 +163,12 @@ class DataReductionProxyParams {
return promo_allowed_;
}
// Returns true if the data reduction proxy should not actually use the
// proxy if enabled.
bool holdback() const {
return holdback_;
}
// Given |allowed_|, |fallback_allowed_|, and |alt_allowed_|, returns the
// list of data reduction proxies that may be used.
DataReductionProxyList GetAllowedProxies() const;
......@@ -198,6 +216,7 @@ class DataReductionProxyParams {
const bool fallback_allowed_;
bool alt_allowed_;
const bool promo_allowed_;
bool holdback_;
bool configured_on_command_line_;
......
......@@ -127,7 +127,6 @@ void DataReductionProxySettings::InitDataReductionProxySettings(
url_request_context_getter_ = url_request_context_getter;
InitPrefMembers();
RecordDataReductionInit();
// Disable the proxy if it is not allowed to be used.
if (!params_->allowed())
return;
......@@ -376,7 +375,6 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy(
prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true);
ResetDataReductionStatistics();
}
// Configure use of the data reduction proxy if it is enabled.
enabled_by_user_= IsDataReductionProxyEnabled();
SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_,
......@@ -399,7 +397,7 @@ void DataReductionProxySettings::SetProxyConfigs(bool enabled,
LogProxyState(enabled, restricted, at_startup);
// The alternative is only configured if the standard configuration is
// is enabled.
if (enabled) {
if (enabled & !params_->holdback()) {
if (alternative_enabled) {
configurator_->Enable(restricted,
!params_->fallback_allowed(),
......
......@@ -263,6 +263,8 @@ class DataReductionProxySettings
CheckInitMetricsWhenNotAllowed);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestSetProxyConfigs);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestSetProxyConfigsHoldback);
// NetworkChangeNotifier::IPAddressObserver:
virtual void OnIPAddressChanged() OVERRIDE;
......
......@@ -93,7 +93,7 @@ void DataReductionProxySettingsTestBase::SetUp() {
registry->RegisterBooleanPref(prefs::kDataReductionProxyWasEnabledBefore,
false);
//AddProxyToCommandLine();
ResetSettings(true, true, false, true);
ResetSettings(true, true, false, true, false);
ListPrefUpdate original_update(&pref_service_,
prefs::kDailyHttpOriginalContentLength);
......@@ -120,7 +120,8 @@ template <class C>
void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool promo_allowed) {
bool promo_allowed,
bool holdback) {
int flags = 0;
if (allowed)
flags |= DataReductionProxyParams::kAllowed;
......@@ -130,6 +131,8 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
flags |= DataReductionProxyParams::kAlternativeAllowed;
if (promo_allowed)
flags |= DataReductionProxyParams::kPromoAllowed;
if (holdback)
flags |= DataReductionProxyParams::kHoldback;
MockDataReductionProxySettings<C>* settings =
new MockDataReductionProxySettings<C>(flags);
EXPECT_CALL(*settings, GetOriginalProfilePrefs())
......@@ -148,7 +151,11 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
// Explicitly generate required instantiations.
template void
DataReductionProxySettingsTestBase::ResetSettings<DataReductionProxySettings>(
bool allowed, bool fallback_allowed, bool alt_allowed, bool promo_allowed);
bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool promo_allowed,
bool holdback);
template <class C>
void DataReductionProxySettingsTestBase::SetProbeResult(
......
......@@ -116,11 +116,13 @@ class DataReductionProxySettingsTestBase : public testing::Test {
template <class C> void ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool promo_allowed);
bool promo_allowed,
bool holdback);
virtual void ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool promo_allowed) = 0;
bool promo_allowed,
bool holdback) = 0;
template <class C> void SetProbeResult(
const std::string& test_url,
......@@ -173,9 +175,10 @@ class ConcreteDataReductionProxySettingsTest
virtual void ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool promo_allowed) OVERRIDE {
bool promo_allowed,
bool holdback) OVERRIDE {
return DataReductionProxySettingsTestBase::ResetSettings<C>(
allowed, fallback_allowed, alt_allowed, promo_allowed);
allowed, fallback_allowed, alt_allowed, promo_allowed, holdback);
}
virtual void SetProbeResult(const std::string& test_url,
......
......@@ -44,7 +44,7 @@ TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) {
TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyDevOrigin) {
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kDataReductionProxyDev, expected_params_->DefaultDevOrigin());
ResetSettings(true, true, false, true);
ResetSettings(true, true, false, true, false);
std::string result =
settings_->params()->origin().spec();
EXPECT_EQ(GURL(expected_params_->DefaultDevOrigin()), GURL(result));
......@@ -83,7 +83,7 @@ TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigs) {
drp_params.DefaultAltFallbackOrigin());
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kDataReductionSSLProxy, drp_params.DefaultSSLOrigin());
ResetSettings(true, true, true, true);
ResetSettings(true, true, true, true, false);
TestDataReductionProxyConfig* config =
static_cast<TestDataReductionProxyConfig*>(
settings_->configurator());
......@@ -122,6 +122,20 @@ TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigs) {
EXPECT_EQ("", config->ssl_origin_);
}
TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigsHoldback) {
ResetSettings(true, true, true, true, true);
TestDataReductionProxyConfig* config =
static_cast<TestDataReductionProxyConfig*>(
settings_->configurator());
// Holdback.
settings_->SetProxyConfigs(true, true, false, false);
EXPECT_FALSE(config->enabled_);
EXPECT_EQ("", config->origin_);
EXPECT_EQ("", config->fallback_origin_);
EXPECT_EQ("", config->ssl_origin_);
}
TEST_F(DataReductionProxySettingsTest, TestIsProxyEnabledOrManaged) {
settings_->InitPrefMembers();
base::MessageLoopForUI loop;
......@@ -396,7 +410,7 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
// Clear the command line. Setting flags can force the proxy to be allowed.
CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
ResetSettings(false, false, false, false);
ResetSettings(false, false, false, false, false);
MockSettings* settings = static_cast<MockSettings*>(settings_.get());
EXPECT_FALSE(settings->params()->allowed());
EXPECT_CALL(*settings, RecordStartupState(PROXY_NOT_AVAILABLE));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment