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( ...@@ -195,7 +195,7 @@ void DataReductionProxySettingsAndroid::SetProxyConfigs(
LogProxyState(enabled, restricted, at_startup); LogProxyState(enabled, restricted, at_startup);
if (enabled) { if (enabled && !params()->holdback()) {
if (alternative_enabled) { if (alternative_enabled) {
configurator()->Enable(restricted, configurator()->Enable(restricted,
!params()->fallback_allowed(), !params()->fallback_allowed(),
......
...@@ -53,6 +53,8 @@ KeyedService* DataReductionProxySettingsFactoryAndroid::BuildServiceInstanceFor( ...@@ -53,6 +53,8 @@ KeyedService* DataReductionProxySettingsFactoryAndroid::BuildServiceInstanceFor(
flags |= DataReductionProxyParams::kAlternativeAllowed; flags |= DataReductionProxyParams::kAlternativeAllowed;
if (DataReductionProxyParams::IsIncludedInPromoFieldTrial()) if (DataReductionProxyParams::IsIncludedInPromoFieldTrial())
flags |= DataReductionProxyParams::kPromoAllowed; flags |= DataReductionProxyParams::kPromoAllowed;
if (DataReductionProxyParams::IsIncludedInHoldbackFieldTrial())
flags |= DataReductionProxyParams::kHoldback;
DataReductionProxySettingsAndroid* settings = DataReductionProxySettingsAndroid* settings =
new DataReductionProxySettingsAndroid( new DataReductionProxySettingsAndroid(
......
...@@ -26,7 +26,11 @@ const char kDataReductionProxyDev[] = "http://foo-dev.com:80"; ...@@ -26,7 +26,11 @@ const char kDataReductionProxyDev[] = "http://foo-dev.com:80";
template <class C> template <class C>
void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings( 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; int flags = 0;
if (allowed) if (allowed)
flags |= DataReductionProxyParams::kAllowed; flags |= DataReductionProxyParams::kAllowed;
...@@ -36,6 +40,8 @@ void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings( ...@@ -36,6 +40,8 @@ void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings(
flags |= DataReductionProxyParams::kAlternativeAllowed; flags |= DataReductionProxyParams::kAlternativeAllowed;
if (promo_allowed) if (promo_allowed)
flags |= DataReductionProxyParams::kPromoAllowed; flags |= DataReductionProxyParams::kPromoAllowed;
if (holdback)
flags |= DataReductionProxyParams::kHoldback;
MockDataReductionProxySettings<C>* settings = MockDataReductionProxySettings<C>* settings =
new MockDataReductionProxySettings<C>(flags); new MockDataReductionProxySettings<C>(flags);
EXPECT_CALL(*settings, GetOriginalProfilePrefs()) EXPECT_CALL(*settings, GetOriginalProfilePrefs())
...@@ -81,7 +87,8 @@ data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings< ...@@ -81,7 +87,8 @@ data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings<
DataReductionProxySettingsAndroid>(bool allowed, DataReductionProxySettingsAndroid>(bool allowed,
bool fallback_allowed, bool fallback_allowed,
bool alt_allowed, bool alt_allowed,
bool promo_allowed); bool promo_allowed,
bool holdback);
template void template void
data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult< data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult<
...@@ -125,7 +132,7 @@ TEST_F(DataReductionProxySettingsAndroidTest, ...@@ -125,7 +132,7 @@ TEST_F(DataReductionProxySettingsAndroidTest,
CommandLine::ForCurrentProcess()->AppendSwitchASCII( CommandLine::ForCurrentProcess()->AppendSwitchASCII(
data_reduction_proxy::switches::kDataReductionProxyDev, data_reduction_proxy::switches::kDataReductionProxyDev,
kDataReductionProxyDev); kDataReductionProxyDev);
ResetSettings(true, true, false, true); ResetSettings(true, true, false, true, false);
ScopedJavaLocalRef<jstring> result = ScopedJavaLocalRef<jstring> result =
Settings()->GetDataReductionProxyOrigin(env_, NULL); Settings()->GetDataReductionProxyOrigin(env_, NULL);
ASSERT_TRUE(result.obj()); ASSERT_TRUE(result.obj());
......
...@@ -52,11 +52,17 @@ bool DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() { ...@@ -52,11 +52,17 @@ bool DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() {
"DataCompressionProxyCriticalBypass") == kEnabled; "DataCompressionProxyCriticalBypass") == kEnabled;
} }
bool DataReductionProxyParams::IsIncludedInHoldbackFieldTrial() {
return FieldTrialList::FindFullName(
"DataCompressionProxyHoldback") == kEnabled;
}
DataReductionProxyParams::DataReductionProxyParams(int flags) DataReductionProxyParams::DataReductionProxyParams(int flags)
: allowed_((flags & kAllowed) == kAllowed), : allowed_((flags & kAllowed) == kAllowed),
fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed), fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed), alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed), promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback),
configured_on_command_line_(false) { configured_on_command_line_(false) {
bool result = Init(allowed_, fallback_allowed_, alt_allowed_); bool result = Init(allowed_, fallback_allowed_, alt_allowed_);
DCHECK(result); DCHECK(result);
...@@ -92,6 +98,7 @@ DataReductionProxyParams::DataReductionProxyParams(int flags, ...@@ -92,6 +98,7 @@ DataReductionProxyParams::DataReductionProxyParams(int flags,
fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed), fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed), alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed), promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback),
configured_on_command_line_(false) { configured_on_command_line_(false) {
if (should_call_init) { if (should_call_init) {
bool result = Init(allowed_, fallback_allowed_, alt_allowed_); bool result = Init(allowed_, fallback_allowed_, alt_allowed_);
......
...@@ -24,10 +24,15 @@ namespace data_reduction_proxy { ...@@ -24,10 +24,15 @@ namespace data_reduction_proxy {
// the necessary DNS names to configure use of the data reduction proxy. // the necessary DNS names to configure use of the data reduction proxy.
class DataReductionProxyParams { class DataReductionProxyParams {
public: 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 kAllowed = (1 << 0);
static const unsigned int kFallbackAllowed = (1 << 1); static const unsigned int kFallbackAllowed = (1 << 1);
static const unsigned int kAlternativeAllowed = (1 << 2); static const unsigned int kAlternativeAllowed = (1 << 2);
static const unsigned int kPromoAllowed = (1 << 3); static const unsigned int kPromoAllowed = (1 << 3);
static const unsigned int kHoldback = (1 << 4);
typedef std::vector<GURL> DataReductionProxyList; typedef std::vector<GURL> DataReductionProxyList;
...@@ -51,6 +56,13 @@ class DataReductionProxyParams { ...@@ -51,6 +56,13 @@ class DataReductionProxyParams {
// proxy if the request resource type is on the critical path (e.g. HTML). // proxy if the request resource type is on the critical path (e.g. HTML).
static bool IsIncludedInCriticalPathBypassFieldTrial(); 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 // Constructs configuration parameters. If |kAllowed|, then the standard
// data reduction proxy configuration is allowed to be used. If // data reduction proxy configuration is allowed to be used. If
// |kfallbackAllowed| a fallback proxy can be used if the primary proxy is // |kfallbackAllowed| a fallback proxy can be used if the primary proxy is
...@@ -151,6 +163,12 @@ class DataReductionProxyParams { ...@@ -151,6 +163,12 @@ class DataReductionProxyParams {
return promo_allowed_; 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 // Given |allowed_|, |fallback_allowed_|, and |alt_allowed_|, returns the
// list of data reduction proxies that may be used. // list of data reduction proxies that may be used.
DataReductionProxyList GetAllowedProxies() const; DataReductionProxyList GetAllowedProxies() const;
...@@ -198,6 +216,7 @@ class DataReductionProxyParams { ...@@ -198,6 +216,7 @@ class DataReductionProxyParams {
const bool fallback_allowed_; const bool fallback_allowed_;
bool alt_allowed_; bool alt_allowed_;
const bool promo_allowed_; const bool promo_allowed_;
bool holdback_;
bool configured_on_command_line_; bool configured_on_command_line_;
......
...@@ -127,7 +127,6 @@ void DataReductionProxySettings::InitDataReductionProxySettings( ...@@ -127,7 +127,6 @@ void DataReductionProxySettings::InitDataReductionProxySettings(
url_request_context_getter_ = url_request_context_getter; url_request_context_getter_ = url_request_context_getter;
InitPrefMembers(); InitPrefMembers();
RecordDataReductionInit(); RecordDataReductionInit();
// Disable the proxy if it is not allowed to be used. // Disable the proxy if it is not allowed to be used.
if (!params_->allowed()) if (!params_->allowed())
return; return;
...@@ -376,7 +375,6 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy( ...@@ -376,7 +375,6 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy(
prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true); prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true);
ResetDataReductionStatistics(); ResetDataReductionStatistics();
} }
// Configure use of the data reduction proxy if it is enabled. // Configure use of the data reduction proxy if it is enabled.
enabled_by_user_= IsDataReductionProxyEnabled(); enabled_by_user_= IsDataReductionProxyEnabled();
SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_, SetProxyConfigs(enabled_by_user_ && !disabled_on_vpn_,
...@@ -399,7 +397,7 @@ void DataReductionProxySettings::SetProxyConfigs(bool enabled, ...@@ -399,7 +397,7 @@ void DataReductionProxySettings::SetProxyConfigs(bool enabled,
LogProxyState(enabled, restricted, at_startup); LogProxyState(enabled, restricted, at_startup);
// The alternative is only configured if the standard configuration is // The alternative is only configured if the standard configuration is
// is enabled. // is enabled.
if (enabled) { if (enabled & !params_->holdback()) {
if (alternative_enabled) { if (alternative_enabled) {
configurator_->Enable(restricted, configurator_->Enable(restricted,
!params_->fallback_allowed(), !params_->fallback_allowed(),
......
...@@ -263,6 +263,8 @@ class DataReductionProxySettings ...@@ -263,6 +263,8 @@ class DataReductionProxySettings
CheckInitMetricsWhenNotAllowed); CheckInitMetricsWhenNotAllowed);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestSetProxyConfigs); TestSetProxyConfigs);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestSetProxyConfigsHoldback);
// NetworkChangeNotifier::IPAddressObserver: // NetworkChangeNotifier::IPAddressObserver:
virtual void OnIPAddressChanged() OVERRIDE; virtual void OnIPAddressChanged() OVERRIDE;
......
...@@ -93,7 +93,7 @@ void DataReductionProxySettingsTestBase::SetUp() { ...@@ -93,7 +93,7 @@ void DataReductionProxySettingsTestBase::SetUp() {
registry->RegisterBooleanPref(prefs::kDataReductionProxyWasEnabledBefore, registry->RegisterBooleanPref(prefs::kDataReductionProxyWasEnabledBefore,
false); false);
//AddProxyToCommandLine(); //AddProxyToCommandLine();
ResetSettings(true, true, false, true); ResetSettings(true, true, false, true, false);
ListPrefUpdate original_update(&pref_service_, ListPrefUpdate original_update(&pref_service_,
prefs::kDailyHttpOriginalContentLength); prefs::kDailyHttpOriginalContentLength);
...@@ -120,7 +120,8 @@ template <class C> ...@@ -120,7 +120,8 @@ template <class C>
void DataReductionProxySettingsTestBase::ResetSettings(bool allowed, void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
bool fallback_allowed, bool fallback_allowed,
bool alt_allowed, bool alt_allowed,
bool promo_allowed) { bool promo_allowed,
bool holdback) {
int flags = 0; int flags = 0;
if (allowed) if (allowed)
flags |= DataReductionProxyParams::kAllowed; flags |= DataReductionProxyParams::kAllowed;
...@@ -130,6 +131,8 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed, ...@@ -130,6 +131,8 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
flags |= DataReductionProxyParams::kAlternativeAllowed; flags |= DataReductionProxyParams::kAlternativeAllowed;
if (promo_allowed) if (promo_allowed)
flags |= DataReductionProxyParams::kPromoAllowed; flags |= DataReductionProxyParams::kPromoAllowed;
if (holdback)
flags |= DataReductionProxyParams::kHoldback;
MockDataReductionProxySettings<C>* settings = MockDataReductionProxySettings<C>* settings =
new MockDataReductionProxySettings<C>(flags); new MockDataReductionProxySettings<C>(flags);
EXPECT_CALL(*settings, GetOriginalProfilePrefs()) EXPECT_CALL(*settings, GetOriginalProfilePrefs())
...@@ -148,7 +151,11 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed, ...@@ -148,7 +151,11 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
// Explicitly generate required instantiations. // Explicitly generate required instantiations.
template void template void
DataReductionProxySettingsTestBase::ResetSettings<DataReductionProxySettings>( 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> template <class C>
void DataReductionProxySettingsTestBase::SetProbeResult( void DataReductionProxySettingsTestBase::SetProbeResult(
......
...@@ -116,11 +116,13 @@ class DataReductionProxySettingsTestBase : public testing::Test { ...@@ -116,11 +116,13 @@ class DataReductionProxySettingsTestBase : public testing::Test {
template <class C> void ResetSettings(bool allowed, template <class C> void ResetSettings(bool allowed,
bool fallback_allowed, bool fallback_allowed,
bool alt_allowed, bool alt_allowed,
bool promo_allowed); bool promo_allowed,
bool holdback);
virtual void ResetSettings(bool allowed, virtual void ResetSettings(bool allowed,
bool fallback_allowed, bool fallback_allowed,
bool alt_allowed, bool alt_allowed,
bool promo_allowed) = 0; bool promo_allowed,
bool holdback) = 0;
template <class C> void SetProbeResult( template <class C> void SetProbeResult(
const std::string& test_url, const std::string& test_url,
...@@ -173,9 +175,10 @@ class ConcreteDataReductionProxySettingsTest ...@@ -173,9 +175,10 @@ class ConcreteDataReductionProxySettingsTest
virtual void ResetSettings(bool allowed, virtual void ResetSettings(bool allowed,
bool fallback_allowed, bool fallback_allowed,
bool alt_allowed, bool alt_allowed,
bool promo_allowed) OVERRIDE { bool promo_allowed,
bool holdback) OVERRIDE {
return DataReductionProxySettingsTestBase::ResetSettings<C>( 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, virtual void SetProbeResult(const std::string& test_url,
......
...@@ -44,7 +44,7 @@ TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) { ...@@ -44,7 +44,7 @@ TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) {
TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyDevOrigin) { TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyDevOrigin) {
CommandLine::ForCurrentProcess()->AppendSwitchASCII( CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kDataReductionProxyDev, expected_params_->DefaultDevOrigin()); switches::kDataReductionProxyDev, expected_params_->DefaultDevOrigin());
ResetSettings(true, true, false, true); ResetSettings(true, true, false, true, false);
std::string result = std::string result =
settings_->params()->origin().spec(); settings_->params()->origin().spec();
EXPECT_EQ(GURL(expected_params_->DefaultDevOrigin()), GURL(result)); EXPECT_EQ(GURL(expected_params_->DefaultDevOrigin()), GURL(result));
...@@ -83,7 +83,7 @@ TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigs) { ...@@ -83,7 +83,7 @@ TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigs) {
drp_params.DefaultAltFallbackOrigin()); drp_params.DefaultAltFallbackOrigin());
CommandLine::ForCurrentProcess()->AppendSwitchASCII( CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kDataReductionSSLProxy, drp_params.DefaultSSLOrigin()); switches::kDataReductionSSLProxy, drp_params.DefaultSSLOrigin());
ResetSettings(true, true, true, true); ResetSettings(true, true, true, true, false);
TestDataReductionProxyConfig* config = TestDataReductionProxyConfig* config =
static_cast<TestDataReductionProxyConfig*>( static_cast<TestDataReductionProxyConfig*>(
settings_->configurator()); settings_->configurator());
...@@ -122,6 +122,20 @@ TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigs) { ...@@ -122,6 +122,20 @@ TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigs) {
EXPECT_EQ("", config->ssl_origin_); 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) { TEST_F(DataReductionProxySettingsTest, TestIsProxyEnabledOrManaged) {
settings_->InitPrefMembers(); settings_->InitPrefMembers();
base::MessageLoopForUI loop; base::MessageLoopForUI loop;
...@@ -396,7 +410,7 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) { ...@@ -396,7 +410,7 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
// Clear the command line. Setting flags can force the proxy to be allowed. // Clear the command line. Setting flags can force the proxy to be allowed.
CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL); CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
ResetSettings(false, false, false, false); ResetSettings(false, false, false, false, false);
MockSettings* settings = static_cast<MockSettings*>(settings_.get()); MockSettings* settings = static_cast<MockSettings*>(settings_.get());
EXPECT_FALSE(settings->params()->allowed()); EXPECT_FALSE(settings->params()->allowed());
EXPECT_CALL(*settings, RecordStartupState(PROXY_NOT_AVAILABLE)); 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