Commit 2f9bd09e authored by bengr's avatar bengr Committed by Commit bot

Disable fallback support for alternative data reduction proxy

The alternative configuration of the data reduction proxy will not
include a fallback proxy.

BUG=410437

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

Cr-Commit-Position: refs/heads/master@{#296066}
parent 828a0270
...@@ -93,10 +93,13 @@ DataReductionProxyParams::DataReductionProxyParams(int flags) ...@@ -93,10 +93,13 @@ 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),
alt_fallback_allowed_(
(flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed), promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback), 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_, alt_fallback_allowed_);
DCHECK(result); DCHECK(result);
} }
...@@ -117,6 +120,7 @@ DataReductionProxyParams::DataReductionProxyParams( ...@@ -117,6 +120,7 @@ DataReductionProxyParams::DataReductionProxyParams(
allowed_(other.allowed_), allowed_(other.allowed_),
fallback_allowed_(other.fallback_allowed_), fallback_allowed_(other.fallback_allowed_),
alt_allowed_(other.alt_allowed_), alt_allowed_(other.alt_allowed_),
alt_fallback_allowed_(other.alt_fallback_allowed_),
promo_allowed_(other.promo_allowed_), promo_allowed_(other.promo_allowed_),
holdback_(other.holdback_), holdback_(other.holdback_),
configured_on_command_line_(other.configured_on_command_line_) { configured_on_command_line_(other.configured_on_command_line_) {
...@@ -137,7 +141,7 @@ DataReductionProxyParams::GetAllowedProxies() const { ...@@ -137,7 +141,7 @@ DataReductionProxyParams::GetAllowedProxies() const {
list.push_back(alt_origin_); list.push_back(alt_origin_);
list.push_back(ssl_origin_); list.push_back(ssl_origin_);
} }
if (alt_allowed_ && fallback_allowed_) if (alt_allowed_ && alt_fallback_allowed_)
list.push_back(alt_fallback_origin_); list.push_back(alt_fallback_origin_);
return list; return list;
} }
...@@ -147,17 +151,22 @@ DataReductionProxyParams::DataReductionProxyParams(int flags, ...@@ -147,17 +151,22 @@ 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),
alt_fallback_allowed_(
(flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed), promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback), 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_, alt_fallback_allowed_);
DCHECK(result); DCHECK(result);
} }
} }
bool DataReductionProxyParams::Init( bool DataReductionProxyParams::Init(bool allowed,
bool allowed, bool fallback_allowed, bool alt_allowed) { bool fallback_allowed,
bool alt_allowed,
bool alt_fallback_allowed) {
InitWithoutChecks(); InitWithoutChecks();
// Verify that all necessary params are set. // Verify that all necessary params are set.
if (allowed) { if (allowed) {
...@@ -191,7 +200,7 @@ bool DataReductionProxyParams::Init( ...@@ -191,7 +200,7 @@ bool DataReductionProxyParams::Init(
} }
} }
if (alt_allowed && fallback_allowed) { if (alt_allowed && alt_fallback_allowed) {
if (!alt_fallback_origin_.is_valid()) { if (!alt_fallback_origin_.is_valid()) {
DVLOG(1) << "Invalid alternative fallback origin:" DVLOG(1) << "Invalid alternative fallback origin:"
<< alt_fallback_origin_.spec(); << alt_fallback_origin_.spec();
...@@ -209,6 +218,11 @@ bool DataReductionProxyParams::Init( ...@@ -209,6 +218,11 @@ bool DataReductionProxyParams::Init(
<< "the data reduction proxy is not allowed"; << "the data reduction proxy is not allowed";
return false; return false;
} }
if (alt_fallback_allowed_ && !alt_allowed_) {
DVLOG(1) << "The data reduction proxy alternative fallback cannot be "
<< "allowed if the alternative data reduction proxy is not allowed";
return false;
}
if (promo_allowed_ && !allowed_) { if (promo_allowed_ && !allowed_) {
DVLOG(1) << "The data reduction proxy promo cannot be allowed if the " DVLOG(1) << "The data reduction proxy promo cannot be allowed if the "
<< "data reduction proxy is not allowed"; << "data reduction proxy is not allowed";
...@@ -246,8 +260,7 @@ void DataReductionProxyParams::InitWithoutChecks() { ...@@ -246,8 +260,7 @@ void DataReductionProxyParams::InitWithoutChecks() {
if (configured_on_command_line_) if (configured_on_command_line_)
allowed_ = true; allowed_ = true;
if (!(ssl_origin.empty() && if (!(ssl_origin.empty() &&
alt_origin.empty() && alt_origin.empty()))
alt_fallback_origin.empty()))
alt_allowed_ = true; alt_allowed_ = true;
std::string probe_url = command_line.GetSwitchValueASCII( std::string probe_url = command_line.GetSwitchValueASCII(
...@@ -318,12 +331,12 @@ bool DataReductionProxyParams::IsDataReductionProxy( ...@@ -318,12 +331,12 @@ bool DataReductionProxyParams::IsDataReductionProxy(
if (proxy_info) { if (proxy_info) {
proxy_info->proxy_servers.first = alt_origin(); proxy_info->proxy_servers.first = alt_origin();
proxy_info->is_alternative = true; proxy_info->is_alternative = true;
if (fallback_allowed()) if (alternative_fallback_allowed())
proxy_info->proxy_servers.second = alt_fallback_origin(); proxy_info->proxy_servers.second = alt_fallback_origin();
} }
return true; return true;
} }
if (fallback_allowed() && if (alternative_fallback_allowed() &&
net::HostPortPair::FromURL(alt_fallback_origin()).Equals( net::HostPortPair::FromURL(alt_fallback_origin()).Equals(
host_port_pair)) { host_port_pair)) {
if (proxy_info) { if (proxy_info) {
......
...@@ -51,8 +51,9 @@ class DataReductionProxyParams { ...@@ -51,8 +51,9 @@ class DataReductionProxyParams {
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 kAlternativeFallbackAllowed = (1 << 3);
static const unsigned int kHoldback = (1 << 4); static const unsigned int kPromoAllowed = (1 << 4);
static const unsigned int kHoldback = (1 << 5);
typedef std::vector<GURL> DataReductionProxyList; typedef std::vector<GURL> DataReductionProxyList;
...@@ -216,6 +217,12 @@ class DataReductionProxyParams { ...@@ -216,6 +217,12 @@ class DataReductionProxyParams {
return alt_allowed_; return alt_allowed_;
} }
// Returns true if the alternative fallback data reduction proxy
// configuration may be used.
bool alternative_fallback_allowed() const {
return alt_fallback_allowed_;
}
// Returns true if the data reduction proxy promo may be shown. // Returns true if the data reduction proxy promo may be shown.
// This is idependent of whether the data reduction proxy is allowed. // This is idependent of whether the data reduction proxy is allowed.
// TODO(bengr): maybe tie to whether proxy is allowed. // TODO(bengr): maybe tie to whether proxy is allowed.
...@@ -248,7 +255,10 @@ class DataReductionProxyParams { ...@@ -248,7 +255,10 @@ class DataReductionProxyParams {
// Initialize the values of the proxies, and probe URL, from command // Initialize the values of the proxies, and probe URL, from command
// line flags and preprocessor constants, and check that there are // line flags and preprocessor constants, and check that there are
// corresponding definitions for the allowed configurations. // corresponding definitions for the allowed configurations.
bool Init(bool allowed, bool fallback_allowed, bool alt_allowed); bool Init(bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool alt_fallback_allowed);
// Initialize the values of the proxies, and probe URL from command // Initialize the values of the proxies, and probe URL from command
// line flags and preprocessor constants. // line flags and preprocessor constants.
...@@ -290,6 +300,7 @@ class DataReductionProxyParams { ...@@ -290,6 +300,7 @@ class DataReductionProxyParams {
bool allowed_; bool allowed_;
bool fallback_allowed_; bool fallback_allowed_;
bool alt_allowed_; bool alt_allowed_;
bool alt_fallback_allowed_;
bool promo_allowed_; bool promo_allowed_;
bool holdback_; bool holdback_;
......
...@@ -28,9 +28,11 @@ TestDataReductionProxyParams::TestDataReductionProxyParams( ...@@ -28,9 +28,11 @@ TestDataReductionProxyParams::TestDataReductionProxyParams(
int flags, unsigned int has_definitions) int flags, unsigned int has_definitions)
: DataReductionProxyParams(flags, false), : DataReductionProxyParams(flags, false),
has_definitions_(has_definitions) { has_definitions_(has_definitions) {
init_result_ = Init(flags & DataReductionProxyParams::kAllowed, init_result_ = Init(
flags & DataReductionProxyParams::kFallbackAllowed, flags & DataReductionProxyParams::kAllowed,
flags & DataReductionProxyParams::kAlternativeAllowed); flags & DataReductionProxyParams::kFallbackAllowed,
flags & DataReductionProxyParams::kAlternativeAllowed,
flags & DataReductionProxyParams::kAlternativeFallbackAllowed);
} }
bool TestDataReductionProxyParams::init_result() const { bool TestDataReductionProxyParams::init_result() const {
......
...@@ -119,6 +119,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -119,6 +119,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
bool allowed; bool allowed;
bool fallback_allowed; bool fallback_allowed;
bool alternative_allowed; bool alternative_allowed;
bool alternative_fallback_allowed;
bool promo_allowed; bool promo_allowed;
unsigned int missing_definitions; unsigned int missing_definitions;
bool expected_result; bool expected_result;
...@@ -127,6 +128,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -127,6 +128,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_NOTHING, TestDataReductionProxyParams::HAS_NOTHING,
true true
...@@ -135,6 +137,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -135,6 +137,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_DEV_ORIGIN | TestDataReductionProxyParams::HAS_DEV_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN,
...@@ -144,6 +147,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -144,6 +147,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_ORIGIN, TestDataReductionProxyParams::HAS_ORIGIN,
true true
...@@ -152,45 +156,65 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -152,45 +156,65 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_ORIGIN | TestDataReductionProxyParams::HAS_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_ORIGIN | TestDataReductionProxyParams::HAS_DEV_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN,
false false
}, },
{ true, {
true,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN | TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN,
false false
}, },
{ true, {
true, true,
true, true,
true, true,
false,
true,
TestDataReductionProxyParams::HAS_SSL_ORIGIN, TestDataReductionProxyParams::HAS_SSL_ORIGIN,
false false
}, },
{ true, {
true, true,
true, true,
true, true,
false,
true,
TestDataReductionProxyParams::HAS_ALT_ORIGIN, TestDataReductionProxyParams::HAS_ALT_ORIGIN,
false false
}, },
{ true, {
true,
true,
true,
false,
true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
true
},
{
true,
true,
true, true,
true, true,
true, true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
false false
}, },
{ true, {
true, true,
true, true,
true, true,
false,
true,
TestDataReductionProxyParams::HAS_PROBE_URL, TestDataReductionProxyParams::HAS_PROBE_URL,
false false
}, },
...@@ -198,6 +222,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -198,6 +222,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_NOTHING, TestDataReductionProxyParams::HAS_NOTHING,
true true
...@@ -206,6 +231,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -206,6 +231,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_ORIGIN | TestDataReductionProxyParams::HAS_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_ORIGIN | TestDataReductionProxyParams::HAS_DEV_ORIGIN |
...@@ -216,6 +242,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -216,6 +242,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
true true
...@@ -224,6 +251,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -224,6 +251,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_SSL_ORIGIN, TestDataReductionProxyParams::HAS_SSL_ORIGIN,
false false
...@@ -232,6 +260,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -232,6 +260,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_ALT_ORIGIN, TestDataReductionProxyParams::HAS_ALT_ORIGIN,
false false
...@@ -240,6 +269,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -240,6 +269,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
true true
...@@ -249,14 +279,24 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -249,14 +279,24 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
false
},
{
true,
false,
true,
false,
true,
TestDataReductionProxyParams::HAS_PROBE_URL, TestDataReductionProxyParams::HAS_PROBE_URL,
false false
}, },
{ {
true, true,
true, true,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_NOTHING, TestDataReductionProxyParams::HAS_NOTHING,
true true
...@@ -265,6 +305,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -265,6 +305,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_ORIGIN | TestDataReductionProxyParams::HAS_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_ORIGIN | TestDataReductionProxyParams::HAS_DEV_ORIGIN |
...@@ -275,6 +316,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -275,6 +316,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN | TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN,
...@@ -284,6 +326,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -284,6 +326,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_SSL_ORIGIN, TestDataReductionProxyParams::HAS_SSL_ORIGIN,
true true
...@@ -292,6 +335,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -292,6 +335,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_ALT_ORIGIN, TestDataReductionProxyParams::HAS_ALT_ORIGIN,
true true
...@@ -300,6 +344,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -300,6 +344,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
true, true,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
true true
...@@ -309,6 +354,16 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -309,6 +354,16 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
true, true,
true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
false
},
{
true,
true,
false,
false,
true,
TestDataReductionProxyParams::HAS_PROBE_URL, TestDataReductionProxyParams::HAS_PROBE_URL,
false false
}, },
...@@ -316,6 +371,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -316,6 +371,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_ORIGIN | TestDataReductionProxyParams::HAS_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_ORIGIN | TestDataReductionProxyParams::HAS_DEV_ORIGIN |
...@@ -326,6 +382,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -326,6 +382,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
true true
...@@ -334,6 +391,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -334,6 +391,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_SSL_ORIGIN, TestDataReductionProxyParams::HAS_SSL_ORIGIN,
true true
...@@ -342,6 +400,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -342,6 +400,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_ALT_ORIGIN, TestDataReductionProxyParams::HAS_ALT_ORIGIN,
true true
...@@ -350,6 +409,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -350,6 +409,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
true, true,
false, false,
false, false,
false,
true, true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
true true
...@@ -359,6 +419,16 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -359,6 +419,16 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
false, false,
true, true,
true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
false
},
{
true,
false,
false,
false,
true,
TestDataReductionProxyParams::HAS_PROBE_URL, TestDataReductionProxyParams::HAS_PROBE_URL,
false false
}, },
...@@ -366,6 +436,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -366,6 +436,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_NOTHING, TestDataReductionProxyParams::HAS_NOTHING,
false false
...@@ -374,6 +445,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -374,6 +445,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_ORIGIN | TestDataReductionProxyParams::HAS_ORIGIN |
TestDataReductionProxyParams::HAS_DEV_ORIGIN | TestDataReductionProxyParams::HAS_DEV_ORIGIN |
...@@ -384,6 +456,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -384,6 +456,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
false false
...@@ -392,6 +465,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -392,6 +465,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_SSL_ORIGIN, TestDataReductionProxyParams::HAS_SSL_ORIGIN,
false false
...@@ -400,6 +474,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -400,6 +474,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_ALT_ORIGIN, TestDataReductionProxyParams::HAS_ALT_ORIGIN,
false false
...@@ -408,6 +483,16 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -408,6 +483,16 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
false,
true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
false
},
{
false,
true,
true,
true,
true, true,
TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
false false
...@@ -416,6 +501,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -416,6 +501,7 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
false, false,
true, true,
true, true,
false,
true, true,
TestDataReductionProxyParams::HAS_PROBE_URL, TestDataReductionProxyParams::HAS_PROBE_URL,
false false
...@@ -430,6 +516,8 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { ...@@ -430,6 +516,8 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
flags |= DataReductionProxyParams::kFallbackAllowed; flags |= DataReductionProxyParams::kFallbackAllowed;
if (tests[i].alternative_allowed) if (tests[i].alternative_allowed)
flags |= DataReductionProxyParams::kAlternativeAllowed; flags |= DataReductionProxyParams::kAlternativeAllowed;
if (tests[i].alternative_fallback_allowed)
flags |= DataReductionProxyParams::kAlternativeFallbackAllowed;
if (tests[i].promo_allowed) if (tests[i].promo_allowed)
flags |= DataReductionProxyParams::kPromoAllowed; flags |= DataReductionProxyParams::kPromoAllowed;
TestDataReductionProxyParams params( TestDataReductionProxyParams params(
...@@ -444,6 +532,7 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -444,6 +532,7 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
const struct { const struct {
net::HostPortPair host_port_pair; net::HostPortPair host_port_pair;
bool fallback_allowed; bool fallback_allowed;
bool alt_fallback_allowed;
bool set_dev_origin; bool set_dev_origin;
bool expected_result; bool expected_result;
net::HostPortPair expected_first; net::HostPortPair expected_first;
...@@ -452,9 +541,11 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -452,9 +541,11 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
bool expected_is_alternative; bool expected_is_alternative;
bool expected_is_ssl; bool expected_is_ssl;
} tests[] = { } tests[] = {
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultOrigin())), TestDataReductionProxyParams::DefaultOrigin())),
true, true,
true,
false, false,
true, true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
...@@ -465,10 +556,12 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -465,10 +556,12 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
false, false,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultOrigin())), TestDataReductionProxyParams::DefaultOrigin())),
false, false,
false, false,
false,
true, true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultOrigin())), TestDataReductionProxyParams::DefaultOrigin())),
...@@ -477,9 +570,11 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -477,9 +570,11 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
false, false,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultFallbackOrigin())), TestDataReductionProxyParams::DefaultFallbackOrigin())),
true, true,
true,
false, false,
true, true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
...@@ -489,20 +584,24 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -489,20 +584,24 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
false, false,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultFallbackOrigin())), TestDataReductionProxyParams::DefaultFallbackOrigin())),
false, false,
false, false,
false, false,
false,
net::HostPortPair::FromURL(GURL()), net::HostPortPair::FromURL(GURL()),
net::HostPortPair::FromURL(GURL()), net::HostPortPair::FromURL(GURL()),
false, false,
false, false,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultAltOrigin())), TestDataReductionProxyParams::DefaultAltOrigin())),
true, true,
true,
false, false,
true, true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
...@@ -513,10 +612,12 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -513,10 +612,12 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
true, true,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultAltOrigin())), TestDataReductionProxyParams::DefaultAltOrigin())),
false, false,
false, false,
false,
true, true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultAltOrigin())), TestDataReductionProxyParams::DefaultAltOrigin())),
...@@ -525,9 +626,11 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -525,9 +626,11 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
true, true,
false false
}, },
{ net::HostPortPair::FromURL( {
net::HostPortPair::FromURL(
GURL(TestDataReductionProxyParams::DefaultAltFallbackOrigin())), GURL(TestDataReductionProxyParams::DefaultAltFallbackOrigin())),
true, true,
true,
false, false,
true, true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
...@@ -537,20 +640,24 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -537,20 +640,24 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
true, true,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultAltFallbackOrigin())), TestDataReductionProxyParams::DefaultAltFallbackOrigin())),
false, false,
false, false,
false, false,
false,
net::HostPortPair::FromURL(GURL()), net::HostPortPair::FromURL(GURL()),
net::HostPortPair::FromURL(GURL()), net::HostPortPair::FromURL(GURL()),
false, false,
false, false,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultSSLOrigin())), TestDataReductionProxyParams::DefaultSSLOrigin())),
true, true,
true,
false, false,
true, true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
...@@ -560,11 +667,13 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -560,11 +667,13 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
false, false,
true true
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultDevOrigin())), TestDataReductionProxyParams::DefaultDevOrigin())),
true, true,
true, true,
true, true,
true,
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultDevOrigin())), TestDataReductionProxyParams::DefaultDevOrigin())),
net::HostPortPair::FromURL(GURL( net::HostPortPair::FromURL(GURL(
...@@ -573,10 +682,12 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -573,10 +682,12 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
false, false,
false false
}, },
{ net::HostPortPair::FromURL(GURL( {
net::HostPortPair::FromURL(GURL(
TestDataReductionProxyParams::DefaultOrigin())), TestDataReductionProxyParams::DefaultOrigin())),
true, true,
true, true,
true,
false, false,
net::HostPortPair::FromURL(GURL()), net::HostPortPair::FromURL(GURL()),
net::HostPortPair::FromURL(GURL()), net::HostPortPair::FromURL(GURL()),
...@@ -590,6 +701,8 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) { ...@@ -590,6 +701,8 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
DataReductionProxyParams::kAlternativeAllowed; DataReductionProxyParams::kAlternativeAllowed;
if (tests[i].fallback_allowed) if (tests[i].fallback_allowed)
flags |= DataReductionProxyParams::kFallbackAllowed; flags |= DataReductionProxyParams::kFallbackAllowed;
if (tests[i].alt_fallback_allowed)
flags |= DataReductionProxyParams::kAlternativeFallbackAllowed;
unsigned int has_definitions = TestDataReductionProxyParams::HAS_EVERYTHING; unsigned int has_definitions = TestDataReductionProxyParams::HAS_EVERYTHING;
if (!tests[i].set_dev_origin) { if (!tests[i].set_dev_origin) {
has_definitions &= ~TestDataReductionProxyParams::HAS_DEV_ORIGIN; has_definitions &= ~TestDataReductionProxyParams::HAS_DEV_ORIGIN;
......
...@@ -339,6 +339,10 @@ void DataReductionProxySettings::OnIPAddressChanged() { ...@@ -339,6 +339,10 @@ void DataReductionProxySettings::OnIPAddressChanged() {
RecordNetworkChangeEvent(IP_CHANGED); RecordNetworkChangeEvent(IP_CHANGED);
if (DisableIfVPN()) if (DisableIfVPN())
return; return;
if (IsDataReductionProxyAlternativeEnabled() &&
!params_->alternative_fallback_allowed()) {
return;
}
ProbeWhetherDataReductionProxyIsAvailable(); ProbeWhetherDataReductionProxyIsAvailable();
} }
} }
...@@ -393,7 +397,9 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy( ...@@ -393,7 +397,9 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy(
at_startup); at_startup);
// Check if the proxy has been restricted explicitly by the carrier. // Check if the proxy has been restricted explicitly by the carrier.
if (enabled_by_user_ && !disabled_on_vpn_) { if (enabled_by_user_ && !disabled_on_vpn_ &&
!(IsDataReductionProxyAlternativeEnabled() &&
!params_->alternative_fallback_allowed())) {
ProbeWhetherDataReductionProxyIsAvailable(); ProbeWhetherDataReductionProxyIsAvailable();
} }
} }
...@@ -411,9 +417,9 @@ void DataReductionProxySettings::SetProxyConfigs(bool enabled, ...@@ -411,9 +417,9 @@ void DataReductionProxySettings::SetProxyConfigs(bool enabled,
if (enabled & !params_->holdback()) { if (enabled & !params_->holdback()) {
if (alternative_enabled) { if (alternative_enabled) {
configurator_->Enable(restricted, configurator_->Enable(restricted,
!params_->fallback_allowed(), !params_->alternative_fallback_allowed(),
params_->alt_origin().spec(), params_->alt_origin().spec(),
params_->alt_fallback_origin().spec(), std::string(),
params_->ssl_origin().spec()); params_->ssl_origin().spec());
} else { } else {
configurator_->Enable(restricted, configurator_->Enable(restricted,
......
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