summaryrefslogtreecommitdiffstats
path: root/components/data_reduction_proxy
diff options
context:
space:
mode:
authortbansal <tbansal@chromium.org>2015-02-19 19:44:18 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-20 03:44:52 +0000
commited0aeccb2df07b46ca69d7328d9fab6d5aae5f8e (patch)
treeddb4f9cb835f3924ea746831b8b27592b803eff0 /components/data_reduction_proxy
parentf406672b3f713ca0fdbfe38656b18dae285262c6 (diff)
downloadchromium_src-ed0aeccb2df07b46ca69d7328d9fab6d5aae5f8e.zip
chromium_src-ed0aeccb2df07b46ca69d7328d9fab6d5aae5f8e.tar.gz
chromium_src-ed0aeccb2df07b46ca69d7328d9fab6d5aae5f8e.tar.bz2
(1) Chrome data compression proxy should use QUIC only if
it is part of data compression QUIC field trial. (2) If QUIC is disabled by command line switch or flag, then QUIC should be disabled globally, including usage of QUIC in data compression proxy. (3) If Chrome is part of data compression QUIC field trial, it does NOT enable QUIC for non-proxy URLs. BUG=343579 Review URL: https://codereview.chromium.org/903213003 Cr-Commit-Position: refs/heads/master@{#317232}
Diffstat (limited to 'components/data_reduction_proxy')
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc5
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h3
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc3
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc67
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc2
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc2
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc31
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_params.h11
8 files changed, 116 insertions, 8 deletions
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc
index 7fdb3212..ebc3f13 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.cc
@@ -130,7 +130,8 @@ void DataReductionProxySettings::InitDataReductionProxySettings(
scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs,
net::URLRequestContextGetter* url_request_context_getter,
net::NetLog* net_log,
- DataReductionProxyEventStore* event_store) {
+ DataReductionProxyEventStore* event_store,
+ bool enable_quic) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(prefs);
DCHECK(!statistics_prefs_);
@@ -148,6 +149,8 @@ void DataReductionProxySettings::InitDataReductionProxySettings(
if (!params()->allowed())
return;
+ params()->EnableQuic(enable_quic);
+
AddDefaultProxyBypassRules();
net::NetworkChangeNotifier::AddIPAddressObserver(this);
}
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h
index 6443239..17c2e52 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h
@@ -87,7 +87,8 @@ class DataReductionProxySettings
scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs,
net::URLRequestContextGetter* url_request_context_getter,
net::NetLog* net_log,
- DataReductionProxyEventStore* event_store);
+ DataReductionProxyEventStore* event_store,
+ bool enable_quic);
// Constructs statistics prefs. This should not be called if a valid
// statistics prefs is passed into the constructor.
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc
index bab1889..0bc693d 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.cc
@@ -280,7 +280,8 @@ void DataReductionProxySettingsTestBase::CheckInitDataReductionProxy(
scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(),
request_context.get(),
&net_log_,
- event_store_.get());
+ event_store_.get(),
+ false);
settings_->SetOnDataReductionEnabledCallback(
base::Bind(&DataReductionProxySettingsTestBase::
RegisterSyntheticFieldTrialCallback,
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc
index b588554..d36d686 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/md5.h"
#include "base/message_loop/message_loop.h"
+#include "base/metrics/field_trial.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_simple_task_runner.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator_test_utils.h"
@@ -31,6 +32,16 @@ namespace data_reduction_proxy {
class DataReductionProxyStatisticsPrefs;
+class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
+ public:
+ ~BadEntropyProvider() override {}
+
+ double GetEntropyForTrial(const std::string& trial_name,
+ uint32 randomization_seed) const override {
+ return 0.5;
+ }
+};
+
class DataReductionProxySettingsTest
: public ConcreteDataReductionProxySettingsTest<
DataReductionProxySettings> {
@@ -428,7 +439,8 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
scoped_ptr<DataReductionProxyStatisticsPrefs>(),
request_context.get(),
&net_log_,
- event_store_.get());
+ event_store_.get(),
+ false);
settings_->SetOnDataReductionEnabledCallback(
base::Bind(&DataReductionProxySettingsTestBase::
RegisterSyntheticFieldTrialCallback,
@@ -437,4 +449,57 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
base::MessageLoop::current()->RunUntilIdle();
}
+TEST_F(DataReductionProxySettingsTest, CheckQUICFieldTrials) {
+ for (int i = 0; i < 2; ++i) {
+ bool enable_quic = i == 0;
+ // No call to |AddProxyToCommandLine()| was made, so the proxy feature
+ // should be unavailable.
+ base::MessageLoopForUI loop;
+ // Clear the command line. Setting flags can force the proxy to be allowed.
+ base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
+
+ 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));
+
+ scoped_ptr<DataReductionProxyConfigurator> configurator(
+ new TestDataReductionProxyConfigurator(
+ scoped_refptr<base::TestSimpleTaskRunner>(
+ new base::TestSimpleTaskRunner()),
+ &net_log_, event_store_.get()));
+ settings_->SetProxyConfigurator(configurator.get());
+ scoped_refptr<net::TestURLRequestContextGetter> request_context =
+ new net::TestURLRequestContextGetter(base::MessageLoopProxy::current());
+
+ settings_->InitDataReductionProxySettings(
+ &pref_service_,
+ scoped_ptr<DataReductionProxyStatisticsPrefs>(),
+ request_context.get(),
+ &net_log_,
+ event_store_.get(),
+ false);
+
+ base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ if (enable_quic) {
+ base::FieldTrialList::CreateFieldTrial(
+ DataReductionProxyParams::GetQuicFieldTrialName(),
+ "Enabled");
+ } else {
+ base::FieldTrialList::CreateFieldTrial(
+ DataReductionProxyParams::GetQuicFieldTrialName(),
+ "Disabled");
+ }
+ settings_->params()->EnableQuic(enable_quic);
+
+ settings_->SetOnDataReductionEnabledCallback(
+ base::Bind(&DataReductionProxySettingsTestBase::
+ RegisterSyntheticFieldTrialCallback,
+ base::Unretained(this)));
+
+ EXPECT_EQ(enable_quic,
+ settings->params()->origin().is_quic()) << i;
+ }
+}
+
} // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc
index 278b076e..b9dbb69 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.cc
@@ -100,7 +100,7 @@ void DataReductionProxyTestContext::InitSettings() {
DataReductionProxyTestContext::SKIP_SETTINGS_INITIALIZATION);
settings_->InitDataReductionProxySettings(
&simple_pref_service_, CreateStatisticsPrefs(), request_context_.get(),
- io_data_->net_log(), io_data_->event_store());
+ io_data_->net_log(), io_data_->event_store(), false);
io_data_->SetDataReductionProxyStatisticsPrefs(settings_->statistics_prefs());
}
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc
index 24e4363..8518980 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc
@@ -595,7 +595,7 @@ class DataReductionProxyUsageStatsEndToEndTest : public testing::Test {
settings()->InitDataReductionProxySettings(
test_context_->pref_service(), test_context_->CreateStatisticsPrefs(),
test_context_->request_context(), test_context_->net_log(),
- test_context_->event_store());
+ test_context_->event_store(), false);
test_context_->io_data()->SetDataReductionProxyStatisticsPrefs(
settings()->statistics_prefs());
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
index 9bbec29..b3422c8 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc
@@ -30,7 +30,8 @@ using base::FieldTrialList;
namespace {
const char kEnabled[] = "Enabled";
-const char kDefaultOrigin[] = "https://proxy.googlezip.net:443";
+const char kDefaultSpdyOrigin[] = "https://proxy.googlezip.net:443";
+const char kDefaultQuicOrigin[] = "quic://proxy.googlezip.net:443";
const char kDevOrigin[] = "https://proxy-dev.googlezip.net:443";
const char kDevFallbackOrigin[] = "proxy-dev.googlezip.net:80";
const char kDefaultFallbackOrigin[] = "compress.googlezip.net:80";
@@ -44,6 +45,8 @@ const char kDefaultProbeUrl[] = "http://check.googlezip.net/connect";
const char kDefaultWarmupUrl[] = "http://www.gstatic.com/generate_204";
const char kAndroidOneIdentifier[] = "sprout";
+
+const char kQuicFieldTrial[] = "DataReductionProxyUseQuic";
} // namespace
namespace data_reduction_proxy {
@@ -120,6 +123,24 @@ bool DataReductionProxyParams::CanProxyURLScheme(const GURL& url) {
return url.SchemeIs(url::kHttpScheme);
}
+// static
+bool DataReductionProxyParams::IsIncludedInQuicFieldTrial() {
+ return FieldTrialList::FindFullName(kQuicFieldTrial) == kEnabled;
+}
+
+// static
+std::string DataReductionProxyParams::GetQuicFieldTrialName() {
+ return kQuicFieldTrial;
+}
+
+void DataReductionProxyParams::EnableQuic(bool enable) {
+ quic_enabled_ = enable;
+ DCHECK(!quic_enabled_ || IsIncludedInQuicFieldTrial());
+ if (override_quic_origin_.empty() && quic_enabled_)
+ origin_ = net::ProxyServer::FromURI(kDefaultQuicOrigin,
+ net::ProxyServer::SCHEME_HTTP);
+}
+
DataReductionProxyTypeInfo::DataReductionProxyTypeInfo()
: proxy_servers(),
is_fallback(false),
@@ -138,6 +159,7 @@ DataReductionProxyParams::DataReductionProxyParams(int flags)
(flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback),
+ quic_enabled_(false),
configured_on_command_line_(false) {
bool result = Init(
allowed_, fallback_allowed_, alt_allowed_, alt_fallback_allowed_);
@@ -164,6 +186,8 @@ DataReductionProxyParams::DataReductionProxyParams(
alt_fallback_allowed_(other.alt_fallback_allowed_),
promo_allowed_(other.promo_allowed_),
holdback_(other.holdback_),
+ quic_enabled_(other.quic_enabled_),
+ override_quic_origin_(other.override_quic_origin_),
configured_on_command_line_(other.configured_on_command_line_) {
}
@@ -196,6 +220,7 @@ DataReductionProxyParams::DataReductionProxyParams(int flags,
(flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
holdback_((flags & kHoldback) == kHoldback),
+ quic_enabled_(false),
configured_on_command_line_(false) {
if (should_call_init) {
bool result = Init(
@@ -314,6 +339,7 @@ void DataReductionProxyParams::InitWithoutChecks() {
// command line.
if (origin.empty())
origin = GetDefaultDevOrigin();
+ override_quic_origin_ = origin;
if (origin.empty())
origin = GetDefaultOrigin();
if (fallback_origin.empty())
@@ -542,7 +568,8 @@ bool DataReductionProxyParams::IsProxyBypassed(
// TODO(kundaji): Remove tests for macro definitions.
std::string DataReductionProxyParams::GetDefaultOrigin() const {
- return kDefaultOrigin;
+ return quic_enabled_ ?
+ kDefaultQuicOrigin : kDefaultSpdyOrigin;
}
std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const {
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h
index 98676a7..da4905b 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params.h
@@ -111,6 +111,15 @@ class DataReductionProxyParams {
// provided |url|.
static bool CanProxyURLScheme(const GURL& url);
+ // Returns true if this client is part of a field trial that sets the origin
+ // proxy server as quic://proxy.googlezip.net.
+ static bool IsIncludedInQuicFieldTrial();
+
+ static std::string GetQuicFieldTrialName();
+
+ // If true, uses QUIC instead of SPDY to connect to proxies that use TLS.
+ void EnableQuic(bool enable);
+
// 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
@@ -333,6 +342,8 @@ class DataReductionProxyParams {
bool alt_fallback_allowed_;
bool promo_allowed_;
bool holdback_;
+ bool quic_enabled_;
+ std::string override_quic_origin_;
bool configured_on_command_line_;
};