diff options
author | jeremyim <jeremyim@chromium.org> | 2015-02-24 10:17:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-24 18:18:30 +0000 |
commit | c12e3722910a2b08e0feab59d9beac737d1cdd3f (patch) | |
tree | 597e7394ac1cec3bc93923915a19a050103e88d2 /chrome | |
parent | 7e5867f39c502050104dec84d7607484e08d9d2d (diff) | |
download | chromium_src-c12e3722910a2b08e0feab59d9beac737d1cdd3f.zip chromium_src-c12e3722910a2b08e0feab59d9beac737d1cdd3f.tar.gz chromium_src-c12e3722910a2b08e0feab59d9beac737d1cdd3f.tar.bz2 |
Replace usages of DataReductionProxyParams with DataReductionProxyConfig
- Bulk of the changes are in using DRPConfig in constructors instead of DRPParams.
- Copy method signatures from DRPParams to DRPConfig, and on
DRPConfig, pass the request through to DRPParams.
- Remove copy constructor on DRPParams.
BUG=452773
Review URL: https://codereview.chromium.org/949713002
Cr-Commit-Position: refs/heads/master@{#317827}
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc | 50 | ||||
-rw-r--r-- | chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_unittest.cc | 37 |
2 files changed, 55 insertions, 32 deletions
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 5d63307..295b4fa 100644 --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc @@ -16,7 +16,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/pref_names.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" @@ -24,10 +24,6 @@ #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "net/url_request/url_request_context_getter.h" -using data_reduction_proxy::Client; -using data_reduction_proxy::DataReductionProxyParams; -using data_reduction_proxy::DataReductionProxySettings; - // The Data Reduction Proxy has been turned into a "best effort" proxy, // meaning it is used only if the effective proxy configuration resolves to // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference @@ -62,15 +58,14 @@ void DataReductionProxyChromeSettings::MigrateDataReductionProxyOffProxyPrefs( return; net::ProxyConfig::ProxyRules proxy_rules; proxy_rules.ParseFromString(proxy_server); - if (!data_reduction_proxy::DataReductionProxyConfigurator:: - ContainsDataReductionProxy(proxy_rules)) { + if (!Config()->ContainsDataReductionProxy(proxy_rules)) { return; } prefs->ClearPref(prefs::kProxy); } DataReductionProxyChromeSettings::DataReductionProxyChromeSettings() - : DataReductionProxySettings() { + : data_reduction_proxy::DataReductionProxySettings() { } DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { @@ -104,16 +99,19 @@ void DataReductionProxyChromeSettings::InitDataReductionProxySettings( service = make_scoped_ptr( new data_reduction_proxy::DataReductionProxyService( statistics_prefs.Pass(), this, request_context_getter)); - DataReductionProxySettings::InitDataReductionProxySettings( - profile_prefs, io_data, service.Pass()); + data_reduction_proxy::DataReductionProxySettings:: + InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); io_data->SetDataReductionProxyService( data_reduction_proxy_service()->GetWeakPtr()); - DataReductionProxySettings::SetOnDataReductionEnabledCallback( - base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, - base::Unretained(this))); + data_reduction_proxy::DataReductionProxySettings:: + SetOnDataReductionEnabledCallback( + base::Bind( + &DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, + base::Unretained(this))); SetDataReductionProxyAlternativeEnabled( - DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); + data_reduction_proxy::DataReductionProxyParams:: + IsIncludedInAlternativeFieldTrial()); // TODO(bengr): Remove after M46. See http://crbug.com/445599. MigrateDataReductionProxyOffProxyPrefs(profile_prefs); } @@ -126,28 +124,28 @@ void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( } // static -Client DataReductionProxyChromeSettings::GetClient() { +data_reduction_proxy::Client DataReductionProxyChromeSettings::GetClient() { #if defined(OS_ANDROID) - return Client::CHROME_ANDROID; + return data_reduction_proxy::Client::CHROME_ANDROID; #elif defined(OS_IOS) - return Client::CHROME_IOS; + return data_reduction_proxy::Client::CHROME_IOS; #elif defined(OS_MACOSX) - return Client::CHROME_MAC; + return data_reduction_proxy::Client::CHROME_MAC; #elif defined(OS_CHROMEOS) - return Client::CHROME_CHROMEOS; + return data_reduction_proxy::Client::CHROME_CHROMEOS; #elif defined(OS_LINUX) - return Client::CHROME_LINUX; + return data_reduction_proxy::Client::CHROME_LINUX; #elif defined(OS_WIN) - return Client::CHROME_WINDOWS; + return data_reduction_proxy::Client::CHROME_WINDOWS; #elif defined(OS_FREEBSD) - return Client::CHROME_FREEBSD; + return data_reduction_proxy::Client::CHROME_FREEBSD; #elif defined(OS_OPENBSD) - return Client::CHROME_OPENBSD; + return data_reduction_proxy::Client::CHROME_OPENBSD; #elif defined(OS_SOLARIS) - return Client::CHROME_SOLARIS; + return data_reduction_proxy::Client::CHROME_SOLARIS; #elif defined(OS_QNX) - return Client::CHROME_QNX; + return data_reduction_proxy::Client::CHROME_QNX; #else - return Client::UNKNOWN; + return data_reduction_proxy::Client::UNKNOWN; #endif } diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_unittest.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_unittest.cc index d36deb4..326095d 100644 --- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_unittest.cc +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_unittest.cc @@ -9,18 +9,35 @@ #include "base/prefs/testing_pref_service.h" #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" #include "chrome/common/pref_names.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" -using base::DictionaryValue; -using data_reduction_proxy::DataReductionProxyParams; -using data_reduction_proxy::DataReductionProxySettings; +using testing::_; +using testing::Return; class DataReductionProxyChromeSettingsTest : public testing::Test { public: void SetUp() override { drp_chrome_settings_ = make_scoped_ptr(new DataReductionProxyChromeSettings()); - dict_ = make_scoped_ptr(new DictionaryValue()); + test_context_.reset(new data_reduction_proxy::DataReductionProxyTestContext( + data_reduction_proxy::DataReductionProxyParams::kAllowed | + data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | + data_reduction_proxy::DataReductionProxyParams::kPromoAllowed, + data_reduction_proxy::TestDataReductionProxyParams::HAS_EVERYTHING & + ~data_reduction_proxy::TestDataReductionProxyParams:: + HAS_DEV_ORIGIN & + ~data_reduction_proxy::TestDataReductionProxyParams:: + HAS_DEV_FALLBACK_ORIGIN, + data_reduction_proxy::DataReductionProxyTestContext::USE_MOCK_CONFIG | + data_reduction_proxy::DataReductionProxyTestContext:: + SKIP_SETTINGS_INITIALIZATION)); + config_ = test_context_->mock_config(); + drp_chrome_settings_->ResetConfigForTest(config_); + dict_ = make_scoped_ptr(new base::DictionaryValue()); mock_pref_service_ = make_scoped_ptr(new TestingPrefServiceSimple()); PrefRegistrySimple* registry = mock_pref_service_->registry(); @@ -30,9 +47,12 @@ class DataReductionProxyChromeSettingsTest : public testing::Test { scoped_ptr<DataReductionProxyChromeSettings> drp_chrome_settings_; scoped_ptr<base::DictionaryValue> dict_; scoped_ptr<TestingPrefServiceSimple> mock_pref_service_; + scoped_ptr<data_reduction_proxy::DataReductionProxyTestContext> test_context_; + data_reduction_proxy::MockDataReductionProxyConfig* config_; }; TEST_F(DataReductionProxyChromeSettingsTest, MigrateEmptyProxy) { + EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( mock_pref_service_.get()); @@ -42,6 +62,7 @@ TEST_F(DataReductionProxyChromeSettingsTest, MigrateEmptyProxy) { TEST_F(DataReductionProxyChromeSettingsTest, MigrateSystemProxy) { dict_->SetString("mode", "system"); mock_pref_service_->Set(prefs::kProxy, *dict_.get()); + EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(0); drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( mock_pref_service_.get()); @@ -53,6 +74,8 @@ TEST_F(DataReductionProxyChromeSettingsTest, MigrateDataReductionProxy) { dict_->SetString("mode", "fixed_servers"); dict_->SetString("server", "http=https://proxy.googlezip.net"); mock_pref_service_->Set(prefs::kProxy, *dict_.get()); + EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) + .WillOnce(Return(true)); drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( mock_pref_service_.get()); @@ -64,12 +87,14 @@ TEST_F(DataReductionProxyChromeSettingsTest, MigrateIgnoreOtherProxy) { dict_->SetString("mode", "fixed_servers"); dict_->SetString("server", "http=https://youtube.com"); mock_pref_service_->Set(prefs::kProxy, *dict_.get()); + EXPECT_CALL(*config_, ContainsDataReductionProxy(_)).Times(1) + .WillOnce(Return(false)); drp_chrome_settings_->MigrateDataReductionProxyOffProxyPrefs( mock_pref_service_.get()); - DictionaryValue* value = - (DictionaryValue*)mock_pref_service_->GetUserPref(prefs::kProxy); + base::DictionaryValue* value = + (base::DictionaryValue*)mock_pref_service_->GetUserPref(prefs::kProxy); std::string mode; EXPECT_TRUE(value->GetString("mode", &mode)); EXPECT_EQ("fixed_servers", mode); |