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)
: allowed_((flags & kAllowed) == kAllowed),
fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
alt_fallback_allowed_(
(flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback),
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);
}
......@@ -117,6 +120,7 @@ DataReductionProxyParams::DataReductionProxyParams(
allowed_(other.allowed_),
fallback_allowed_(other.fallback_allowed_),
alt_allowed_(other.alt_allowed_),
alt_fallback_allowed_(other.alt_fallback_allowed_),
promo_allowed_(other.promo_allowed_),
holdback_(other.holdback_),
configured_on_command_line_(other.configured_on_command_line_) {
......@@ -137,7 +141,7 @@ DataReductionProxyParams::GetAllowedProxies() const {
list.push_back(alt_origin_);
list.push_back(ssl_origin_);
}
if (alt_allowed_ && fallback_allowed_)
if (alt_allowed_ && alt_fallback_allowed_)
list.push_back(alt_fallback_origin_);
return list;
}
......@@ -147,17 +151,22 @@ DataReductionProxyParams::DataReductionProxyParams(int flags,
: allowed_((flags & kAllowed) == kAllowed),
fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
alt_fallback_allowed_(
(flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
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_);
bool result = Init(
allowed_, fallback_allowed_, alt_allowed_, alt_fallback_allowed_);
DCHECK(result);
}
}
bool DataReductionProxyParams::Init(
bool allowed, bool fallback_allowed, bool alt_allowed) {
bool DataReductionProxyParams::Init(bool allowed,
bool fallback_allowed,
bool alt_allowed,
bool alt_fallback_allowed) {
InitWithoutChecks();
// Verify that all necessary params are set.
if (allowed) {
......@@ -191,7 +200,7 @@ bool DataReductionProxyParams::Init(
}
}
if (alt_allowed && fallback_allowed) {
if (alt_allowed && alt_fallback_allowed) {
if (!alt_fallback_origin_.is_valid()) {
DVLOG(1) << "Invalid alternative fallback origin:"
<< alt_fallback_origin_.spec();
......@@ -209,6 +218,11 @@ bool DataReductionProxyParams::Init(
<< "the data reduction proxy is not allowed";
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_) {
DVLOG(1) << "The data reduction proxy promo cannot be allowed if the "
<< "data reduction proxy is not allowed";
......@@ -246,8 +260,7 @@ void DataReductionProxyParams::InitWithoutChecks() {
if (configured_on_command_line_)
allowed_ = true;
if (!(ssl_origin.empty() &&
alt_origin.empty() &&
alt_fallback_origin.empty()))
alt_origin.empty()))
alt_allowed_ = true;
std::string probe_url = command_line.GetSwitchValueASCII(
......@@ -318,12 +331,12 @@ bool DataReductionProxyParams::IsDataReductionProxy(
if (proxy_info) {
proxy_info->proxy_servers.first = alt_origin();
proxy_info->is_alternative = true;
if (fallback_allowed())
if (alternative_fallback_allowed())
proxy_info->proxy_servers.second = alt_fallback_origin();
}
return true;
}
if (fallback_allowed() &&
if (alternative_fallback_allowed() &&
net::HostPortPair::FromURL(alt_fallback_origin()).Equals(
host_port_pair)) {
if (proxy_info) {
......
......@@ -51,8 +51,9 @@ class DataReductionProxyParams {
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);
static const unsigned int kAlternativeFallbackAllowed = (1 << 3);
static const unsigned int kPromoAllowed = (1 << 4);
static const unsigned int kHoldback = (1 << 5);
typedef std::vector<GURL> DataReductionProxyList;
......@@ -216,6 +217,12 @@ class DataReductionProxyParams {
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.
// This is idependent of whether the data reduction proxy is allowed.
// TODO(bengr): maybe tie to whether proxy is allowed.
......@@ -248,7 +255,10 @@ class DataReductionProxyParams {
// Initialize the values of the proxies, and probe URL, from command
// line flags and preprocessor constants, and check that there are
// 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
// line flags and preprocessor constants.
......@@ -290,6 +300,7 @@ class DataReductionProxyParams {
bool allowed_;
bool fallback_allowed_;
bool alt_allowed_;
bool alt_fallback_allowed_;
bool promo_allowed_;
bool holdback_;
......
......@@ -28,9 +28,11 @@ TestDataReductionProxyParams::TestDataReductionProxyParams(
int flags, unsigned int has_definitions)
: DataReductionProxyParams(flags, false),
has_definitions_(has_definitions) {
init_result_ = Init(flags & DataReductionProxyParams::kAllowed,
flags & DataReductionProxyParams::kFallbackAllowed,
flags & DataReductionProxyParams::kAlternativeAllowed);
init_result_ = Init(
flags & DataReductionProxyParams::kAllowed,
flags & DataReductionProxyParams::kFallbackAllowed,
flags & DataReductionProxyParams::kAlternativeAllowed,
flags & DataReductionProxyParams::kAlternativeFallbackAllowed);
}
bool TestDataReductionProxyParams::init_result() const {
......
......@@ -339,6 +339,10 @@ void DataReductionProxySettings::OnIPAddressChanged() {
RecordNetworkChangeEvent(IP_CHANGED);
if (DisableIfVPN())
return;
if (IsDataReductionProxyAlternativeEnabled() &&
!params_->alternative_fallback_allowed()) {
return;
}
ProbeWhetherDataReductionProxyIsAvailable();
}
}
......@@ -393,7 +397,9 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy(
at_startup);
// 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();
}
}
......@@ -411,9 +417,9 @@ void DataReductionProxySettings::SetProxyConfigs(bool enabled,
if (enabled & !params_->holdback()) {
if (alternative_enabled) {
configurator_->Enable(restricted,
!params_->fallback_allowed(),
!params_->alternative_fallback_allowed(),
params_->alt_origin().spec(),
params_->alt_fallback_origin().spec(),
std::string(),
params_->ssl_origin().spec());
} else {
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