diff options
author | tbansal <tbansal@chromium.org> | 2015-02-19 19:44:18 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-20 03:44:52 +0000 |
commit | ed0aeccb2df07b46ca69d7328d9fab6d5aae5f8e (patch) | |
tree | ddb4f9cb835f3924ea746831b8b27592b803eff0 | |
parent | f406672b3f713ca0fdbfe38656b18dae285262c6 (diff) | |
download | chromium_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}
20 files changed, 217 insertions, 19 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc index d113d74..2d2e8ee 100644 --- a/android_webview/browser/aw_browser_context.cc +++ b/android_webview/browser/aw_browser_context.cc @@ -280,7 +280,8 @@ void AwBrowserContext::CreateUserPrefServiceIfNecessary() { scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(), GetRequestContext(), GetAwURLRequestContext()->GetNetLog(), - data_reduction_proxy_io_data_->event_store()); + data_reduction_proxy_io_data_->event_store(), + false /* disable QUIC for WebView */); data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 41d8709..72a745b 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -42,6 +42,7 @@ #include "chrome/common/chrome_version_info.h" #include "chrome/common/pref_names.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h" +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/policy/core/common/policy_service.h" #include "components/variations/variations_associated_data.h" #include "content/public/browser/browser_thread.h" @@ -1039,6 +1040,7 @@ void IOThread::InitializeNetworkSessionParamsFromGlobals( ¶ms->alternate_protocol_probability_threshold); globals.enable_quic.CopyToIfSet(¶ms->enable_quic); + globals.enable_quic_for_proxies.CopyToIfSet(¶ms->enable_quic_for_proxies); globals.quic_always_require_handshake_confirmation.CopyToIfSet( ¶ms->quic_always_require_handshake_confirmation); globals.quic_disable_connection_pooling.CopyToIfSet( @@ -1168,6 +1170,9 @@ void IOThread::ConfigureQuicGlobals( IOThread::Globals* globals) { bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); globals->enable_quic.set(enable_quic); + bool enable_quic_for_proxies = ShouldEnableQuicForProxies(command_line, + quic_trial_group); + globals->enable_quic_for_proxies.set(enable_quic_for_proxies); if (enable_quic) { globals->quic_always_require_handshake_confirmation.set( ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); @@ -1249,6 +1254,25 @@ bool IOThread::ShouldEnableQuic(const base::CommandLine& command_line, quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); } +// static +bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, + base::StringPiece quic_trial_group) { + return ShouldEnableQuic(command_line, quic_trial_group) || + ShouldEnableQuicForDataReductionProxy(); +} + +// static +bool IOThread::ShouldEnableQuicForDataReductionProxy() { + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + + if (command_line.HasSwitch(switches::kDisableQuic)) + return false; + + return data_reduction_proxy::DataReductionProxyParams:: + IsIncludedInQuicFieldTrial(); +} + bool IOThread::ShouldEnableQuicPortSelection( const base::CommandLine& command_line) { if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h index 3fbbe9e..55c07a5 100644 --- a/chrome/browser/io_thread.h +++ b/chrome/browser/io_thread.h @@ -182,6 +182,7 @@ class IOThread : public content::BrowserThreadDelegate { Optional<double> alternate_protocol_probability_threshold; Optional<bool> enable_quic; + Optional<bool> enable_quic_for_proxies; Optional<bool> enable_quic_port_selection; Optional<bool> quic_always_require_handshake_confirmation; Optional<bool> quic_disable_connection_pooling; @@ -236,6 +237,10 @@ class IOThread : public content::BrowserThreadDelegate { base::TimeTicks creation_time() const; + // Returns true if QUIC should be enabled for data reduction proxy, either as + // a result of a field trial or a command line flag. + static bool ShouldEnableQuicForDataReductionProxy(); + private: // Map from name to value for all parameters associate with a field trial. typedef std::map<std::string, std::string> VariationParameters; @@ -330,6 +335,12 @@ class IOThread : public content::BrowserThreadDelegate { const base::CommandLine& command_line, base::StringPiece quic_trial_group); + // Returns true if QUIC should be enabled for proxies, either as a result + // of a field trial or a command line flag. + static bool ShouldEnableQuicForProxies( + const base::CommandLine& command_line, + base::StringPiece quic_trial_group); + // Returns true if the selection of the ephemeral port in bind() should be // performed by Chromium, and false if the OS should select the port. The OS // option is used to prevent Windows from posting a security security warning diff --git a/chrome/browser/io_thread_unittest.cc b/chrome/browser/io_thread_unittest.cc index 5b60d60..dfb0a9a 100644 --- a/chrome/browser/io_thread_unittest.cc +++ b/chrome/browser/io_thread_unittest.cc @@ -3,7 +3,9 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "base/metrics/field_trial.h" #include "chrome/browser/io_thread.h" +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "net/http/http_network_session.h" #include "net/http/http_server_properties_impl.h" #include "net/quic/quic_protocol.h" @@ -14,6 +16,16 @@ namespace test { using ::testing::ElementsAre; +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 IOThreadPeer { public: static void ConfigureQuicGlobals( @@ -114,6 +126,8 @@ TEST_F(IOThreadTest, DisableQuicByDefault) { net::HttpNetworkSession::Params params; InitializeNetworkSessionParams(¶ms); EXPECT_FALSE(params.enable_quic); + EXPECT_FALSE(params.enable_quic_for_proxies); + EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); } TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { @@ -124,6 +138,7 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { net::HttpNetworkSession::Params params; InitializeNetworkSessionParams(¶ms); EXPECT_TRUE(params.enable_quic); + EXPECT_TRUE(params.enable_quic_for_proxies); EXPECT_EQ(1350u, params.quic_max_packet_length); EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); EXPECT_EQ(default_params.quic_supported_versions, @@ -135,6 +150,21 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); EXPECT_FALSE(params.quic_enable_truncated_connection_ids); EXPECT_FALSE(params.quic_enable_connection_racing); + EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); +} + +TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { + base::FieldTrialList field_trial_list(new BadEntropyProvider()); + base::FieldTrialList::CreateFieldTrial( + data_reduction_proxy::DataReductionProxyParams::GetQuicFieldTrialName(), + "Enabled"); + + ConfigureQuicGlobals(); + net::HttpNetworkSession::Params params; + InitializeNetworkSessionParams(¶ms); + EXPECT_FALSE(params.enable_quic); + EXPECT_TRUE(params.enable_quic_for_proxies); + EXPECT_TRUE(IOThread::ShouldEnableQuicForDataReductionProxy()); } TEST_F(IOThreadTest, EnableQuicFromCommandLine) { @@ -144,6 +174,8 @@ TEST_F(IOThreadTest, EnableQuicFromCommandLine) { net::HttpNetworkSession::Params params; InitializeNetworkSessionParams(¶ms); EXPECT_TRUE(params.enable_quic); + EXPECT_TRUE(params.enable_quic_for_proxies); + EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); } TEST_F(IOThreadTest, EnablePacingFromCommandLine) { diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc index da920ff..d54fd26 100644 --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc @@ -79,14 +79,16 @@ void DataReductionProxyChromeSettings::InitDataReductionProxySettings( data_reduction_proxy::DataReductionProxyIOData* io_data, PrefService* profile_prefs, PrefService* local_state_prefs, - net::URLRequestContextGetter* request_context) { + net::URLRequestContextGetter* request_context, + bool enable_quic) { SetProxyConfigurator(io_data->configurator()); DataReductionProxySettings::InitDataReductionProxySettings( profile_prefs, io_data->PassStatisticsPrefs(), request_context, io_data->net_log(), - io_data->event_store()); + io_data->event_store(), + enable_quic); DataReductionProxySettings::SetOnDataReductionEnabledCallback( base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, base::Unretained(this))); diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h index 648e5e9..b3f1bdf 100644 --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h @@ -49,7 +49,8 @@ class DataReductionProxyChromeSettings data_reduction_proxy::DataReductionProxyIOData* io_data, PrefService* profile_prefs, PrefService* local_state_prefs, - net::URLRequestContextGetter* request_context); + net::URLRequestContextGetter* request_context, + bool enable_quic); // Gets the client type for the data reduction proxy. static data_reduction_proxy::Client GetClient(); diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index c6522a8..f6a04b2 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -179,11 +179,17 @@ void ProfileImplIOData::Handle::Init( BrowserThread::GetMessageLoopProxyForThread( BrowserThread::UI)).Pass()); + // TODO(tbansal): Move this to IO thread once the data reduction proxy + // params are unified into a single object. + bool enable_quic_for_data_reduction_proxy = + IOThread::ShouldEnableQuicForDataReductionProxy(); + DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_)-> InitDataReductionProxySettings(io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(), g_browser_process->local_state(), - profile_->GetRequestContext()); + profile_->GetRequestContext(), + enable_quic_for_data_reduction_proxy); } content::ResourceContext* 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_; }; diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index ff87956..276b3c8 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -90,6 +90,7 @@ HttpNetworkSession::Params::Params() use_alternate_protocols(false), alternate_protocol_probability_threshold(1), enable_quic(false), + enable_quic_for_proxies(false), enable_quic_port_selection(true), quic_always_require_handshake_confirmation(false), quic_disable_connection_pooling(false), @@ -265,6 +266,7 @@ base::Value* HttpNetworkSession::QuicInfoToValue() const { base::DictionaryValue* dict = new base::DictionaryValue(); dict->Set("sessions", quic_stream_factory_.QuicStreamFactoryInfoToValue()); dict->SetBoolean("quic_enabled", params_.enable_quic); + dict->SetBoolean("quic_enabled_for_proxies", params_.enable_quic_for_proxies); dict->SetBoolean("enable_quic_port_selection", params_.enable_quic_port_selection); base::ListValue* connection_options = new base::ListValue; diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 3216c6c..f290f55 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -113,6 +113,7 @@ class NET_EXPORT HttpNetworkSession double alternate_protocol_probability_threshold; bool enable_quic; + bool enable_quic_for_proxies; bool enable_quic_port_selection; bool quic_always_require_handshake_confirmation; bool quic_disable_connection_pooling; diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index d6e299e..b2cec9f 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -671,10 +671,15 @@ int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) { if (result == OK) { // Remove unsupported proxies from the list. - proxy_info_.RemoveProxiesWithoutScheme( - ProxyServer::SCHEME_DIRECT | ProxyServer::SCHEME_QUIC | - ProxyServer::SCHEME_HTTP | ProxyServer::SCHEME_HTTPS | - ProxyServer::SCHEME_SOCKS4 | ProxyServer::SCHEME_SOCKS5); + int supported_proxies = + ProxyServer::SCHEME_DIRECT | ProxyServer::SCHEME_HTTP | + ProxyServer::SCHEME_HTTPS | ProxyServer::SCHEME_SOCKS4 | + ProxyServer::SCHEME_SOCKS5; + + if (session_->params().enable_quic_for_proxies) + supported_proxies |= ProxyServer::SCHEME_QUIC; + + proxy_info_.RemoveProxiesWithoutScheme(supported_proxies); if (proxy_info_.is_empty()) { // No proxies/direct to choose from. This happens when we don't support @@ -747,11 +752,14 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { if (ShouldForceQuic()) using_quic_ = true; - if (proxy_info_.is_quic()) + DCHECK(!using_quic_ || session_->params().enable_quic); + + if (proxy_info_.is_quic()) { using_quic_ = true; + DCHECK(session_->params().enable_quic_for_proxies); + } if (using_quic_) { - DCHECK(session_->params().enable_quic); if (proxy_info_.is_quic() && !request_info_.url.SchemeIs("http")) { NOTREACHED(); // TODO(rch): support QUIC proxies for HTTPS urls. diff --git a/net/http/http_stream_factory_impl_unittest.cc b/net/http/http_stream_factory_impl_unittest.cc index 417b6b4..e55aff5 100644 --- a/net/http/http_stream_factory_impl_unittest.cc +++ b/net/http/http_stream_factory_impl_unittest.cc @@ -627,6 +627,7 @@ TEST_P(HttpStreamFactoryTest, UnreachableQuicProxyMarkedAsBad) { HttpNetworkSession::Params params; params.enable_quic = true; + params.enable_quic_for_proxies = true; scoped_refptr<SSLConfigServiceDefaults> ssl_config_service( new SSLConfigServiceDefaults); HttpServerPropertiesImpl http_server_properties; diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc index 3c85ca4..0410c59 100644 --- a/net/quic/quic_network_transaction_unittest.cc +++ b/net/quic/quic_network_transaction_unittest.cc @@ -420,6 +420,7 @@ TEST_P(QuicNetworkTransactionTest, ForceQuic) { } TEST_P(QuicNetworkTransactionTest, QuicProxy) { + params_.enable_quic_for_proxies = true; proxy_service_.reset( ProxyService::CreateFixedFromPacResult("QUIC myproxy:70")); |