Commit 4832621e authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Don't retry an empty proxy config

This allows the config server to send an empty config in order to
effectivly turn off DataSaver if needed.

Bug: 840978
Change-Id: I7b5e57728737401c286da29ccbd7cc4564c73732
Reviewed-on: https://chromium-review.googlesource.com/1050805
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557221}
parent 2899c7a5
...@@ -555,12 +555,11 @@ bool DataReductionProxyConfigServiceClient::ParseAndApplyProxyConfig( ...@@ -555,12 +555,11 @@ bool DataReductionProxyConfigServiceClient::ParseAndApplyProxyConfig(
if (!config.has_proxy_config()) if (!config.has_proxy_config())
return false; return false;
// An empty proxy config is OK, and allows the server to effectively turn off
// DataSaver if needed. See http://crbug.com/840978.
std::vector<DataReductionProxyServer> proxies = std::vector<DataReductionProxyServer> proxies =
GetProxiesForHTTP(config.proxy_config()); GetProxiesForHTTP(config.proxy_config());
if (proxies.empty())
return false;
request_options_->SetSecureSession(config.session_key()); request_options_->SetSecureSession(config.session_key());
config_values_->UpdateValues(proxies); config_values_->UpdateValues(proxies);
config_->OnNewClientConfigFetched(); config_->OnNewClientConfigFetched();
......
...@@ -229,6 +229,13 @@ class DataReductionProxyConfigServiceClientTest : public testing::Test { ...@@ -229,6 +229,13 @@ class DataReductionProxyConfigServiceClientTest : public testing::Test {
half_reporting_fraction_encoded_config_ = half_reporting_fraction_encoded_config_ =
EncodeConfig(half_reporting_fraction_config); EncodeConfig(half_reporting_fraction_config);
ClientConfig no_proxies_config;
no_proxies_config.set_session_key(kSuccessSessionKey);
no_proxies_config.mutable_refresh_duration()->set_seconds(
kConfigRefreshDurationSeconds);
no_proxies_config.mutable_refresh_duration()->set_nanos(0);
no_proxies_config_ = EncodeConfig(no_proxies_config);
success_reads_[0] = net::MockRead("HTTP/1.1 200 OK\r\n\r\n"); success_reads_[0] = net::MockRead("HTTP/1.1 200 OK\r\n\r\n");
success_reads_[1] = success_reads_[1] =
net::MockRead(net::ASYNC, config_.c_str(), config_.length()); net::MockRead(net::ASYNC, config_.c_str(), config_.length());
...@@ -447,6 +454,7 @@ class DataReductionProxyConfigServiceClientTest : public testing::Test { ...@@ -447,6 +454,7 @@ class DataReductionProxyConfigServiceClientTest : public testing::Test {
const std::string& half_reporting_fraction_encoded_config() const { const std::string& half_reporting_fraction_encoded_config() const {
return half_reporting_fraction_encoded_config_; return half_reporting_fraction_encoded_config_;
} }
const std::string& no_proxies_config() const { return no_proxies_config_; }
const std::string& loaded_config() const { return loaded_config_; } const std::string& loaded_config() const { return loaded_config_; }
...@@ -490,6 +498,9 @@ class DataReductionProxyConfigServiceClientTest : public testing::Test { ...@@ -490,6 +498,9 @@ class DataReductionProxyConfigServiceClientTest : public testing::Test {
// A configuration where the pingback reporting fraction is set to 0.5f. // A configuration where the pingback reporting fraction is set to 0.5f.
std::string half_reporting_fraction_encoded_config_; std::string half_reporting_fraction_encoded_config_;
// A configuration where no proxies are configured.
std::string no_proxies_config_;
// Mock socket data. // Mock socket data.
std::vector<std::unique_ptr<net::SocketDataProvider>> socket_data_providers_; std::vector<std::unique_ptr<net::SocketDataProvider>> socket_data_providers_;
...@@ -1359,6 +1370,16 @@ TEST_F(DataReductionProxyConfigServiceClientTest, ...@@ -1359,6 +1370,16 @@ TEST_F(DataReductionProxyConfigServiceClientTest,
EXPECT_EQ(0.5f, pingback_reporting_fraction()); EXPECT_EQ(0.5f, pingback_reporting_fraction());
} }
TEST_F(DataReductionProxyConfigServiceClientTest, EmptyConfigDisablesDRP) {
Init(true);
SetDataReductionProxyEnabled(true, true);
EXPECT_EQ(std::vector<net::ProxyServer>(), GetConfiguredProxiesForHttp());
config_client()->ApplySerializedConfig(no_proxies_config());
EXPECT_EQ(std::vector<net::ProxyServer>(), GetConfiguredProxiesForHttp());
EXPECT_TRUE(configurator()->GetProxyConfig().proxy_rules().empty());
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Verifies the correctness of fetching config when Chromium is in background // Verifies the correctness of fetching config when Chromium is in background
// and foreground. // and foreground.
......
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