Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings.h

Issue 286013002: Added alternative configuration for the data reduction proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK fix Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/browser/data_reduction_proxy_settings.h
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h
index 27bf1588c904c2710bbe5b0bd3d47b891ba498e4..cf0abe105c15062a070d8d7c6abddb28db2e692d 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h
@@ -14,6 +14,7 @@
#include "base/prefs/pref_member.h"
#include "base/threading/thread_checker.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_configurator.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
#include "net/base/network_change_notifier.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -86,34 +87,14 @@ class DataReductionProxySettings
public net::NetworkChangeNotifier::IPAddressObserver {
public:
typedef std::vector<long long> ContentLengthList;
- // TODO(marq): Consider instead using a std::pair instead of a vector.
- typedef std::vector<GURL> DataReductionProxyList;
- // Returns true of the data reduction proxy origin is set on the command line.
- static bool IsProxyOriginSetOnCommandLine();
-
- // Returns true if the data reduction proxy key is set on the command line.
static bool IsProxyKeySetOnCommandLine();
- // Returns true if this application instance is part of the data reduction
- // proxy field trial, or if it a proxy origin is set in flags. This is a
- // convenience method for platforms like Chrome on Android and iOS, to
- // determine if the data reduction proxy is allowed.
- static bool IsIncludedInFieldTrialOrFlags();
-
- static void SetAllowed(bool allowed);
- static void SetPromoAllowed(bool promo_allowed);
-
- DataReductionProxySettings();
+ DataReductionProxySettings(DataReductionProxyParams* params);
virtual ~DataReductionProxySettings();
- // Set and get the key to be used for data reduction proxy authentication.
- void set_key(const std::string& key) {
- key_ = key;
- }
-
- const std::string& key() const {
- return key_;
+ DataReductionProxyParams* params() const {
+ return params_.get();
}
// Initializes the data reduction proxy with profile and local state prefs,
@@ -134,45 +115,22 @@ class DataReductionProxySettings
PrefService* prefs,
PrefService* local_state_prefs,
net::URLRequestContextGetter* url_request_context_getter,
- scoped_ptr<DataReductionProxyConfigurator> config);
+ scoped_ptr<DataReductionProxyConfigurator> configurator);
// Sets the logic the embedder uses to set the networking configuration that
// causes traffic to be proxied.
void SetProxyConfigurator(
scoped_ptr<DataReductionProxyConfigurator> configurator);
- // If proxy authentication is compiled in, pre-cache an authentication
- // |key| for all configured proxies in |session|.
- static void InitDataReductionProxySession(net::HttpNetworkSession* session,
- const std::string& key);
-
- // Returns true if the data reduction proxy is allowed to be used. This could
- // return false, for example, if this instance is not part of the field trial,
- // or if the proxy name is not configured via gyp.
- static bool IsDataReductionProxyAllowed();
-
- // Returns true if a screen promoting the data reduction proxy is allowed to
- // be shown. Logic that decides when to show the promo should check its
- // availability. This would return false if not part of a separate field
- // trial that governs the use of the promotion.
- static bool IsDataReductionProxyPromoAllowed();
-
- // Returns true if preconnect advisory hinting is enabled by command line
- // flag or Finch trial.
- static bool IsPreconnectHintingAllowed();
-
- // Returns the URL of the data reduction proxy.
- static std::string GetDataReductionProxyOrigin();
-
- // Returns the URL of the fallback data reduction proxy.
- static std::string GetDataReductionProxyFallback();
-
- // Returns a vector of GURLs for all configured proxies.
- static DataReductionProxyList GetDataReductionProxies();
+ // If proxy authentication is compiled in, pre-cache authentication
+ // keys for all configured proxies in |session|.
+ static void InitDataReductionProxySession(
+ net::HttpNetworkSession* session,
+ const DataReductionProxyParams* params);
// Returns true if |auth_info| represents an authentication challenge from
// a compatible, configured proxy.
- static bool IsAcceptableAuthChallenge(net::AuthChallengeInfo* auth_info);
+ bool IsAcceptableAuthChallenge(net::AuthChallengeInfo* auth_info);
// Returns a UTF16 string suitable for use as an authentication token in
// response to the challenge represented by |auth_info|. If the token can't
@@ -182,6 +140,9 @@ class DataReductionProxySettings
// Returns true if the proxy is enabled.
bool IsDataReductionProxyEnabled();
+ // Returns true if the alternative proxy is enabled.
+ bool IsDataReductionProxyAlternativeEnabled();
+
// Returns true if the proxy is managed by an adminstrator's policy.
bool IsDataReductionProxyManaged();
@@ -190,15 +151,8 @@ class DataReductionProxySettings
// probe succeeds.
void SetDataReductionProxyEnabled(bool enabled);
- // If |allowed|, the fallback proxy will be included in the proxy
- // configuration.
- void set_fallback_allowed(bool allowed) {
- fallback_allowed_ = allowed;
- }
-
- bool fallback_allowed() const {
- return fallback_allowed_;
- }
+ // Enables or disables the alternative data reduction proxy configuration.
+ void SetDataReductionProxyAlternativeEnabled(bool enabled);
// Returns the time in microseconds that the last update was made to the
// daily original and received content lengths.
@@ -232,13 +186,17 @@ class DataReductionProxySettings
ContentLengthList GetDailyContentLengths(const char* pref_name);
// Sets the proxy configs, enabling or disabling the proxy according to
- // the value of |enabled|. If |restricted| is true, only enable the fallback
- // proxy. |at_startup| is true when this method is called from
- // InitDataReductionProxySettings.
- virtual void SetProxyConfigs(bool enabled, bool restricted, bool at_startup);
-
- // Metrics methods. Subclasses should override if they wish to provide
- // alternate methods.
+ // the value of |enabled| and |alternative_enabled|. Use the alternative
+ // configuration only if |enabled| and |alternative_enabled| are true. If
+ // |restricted| is true, only enable the fallback proxy. |at_startup| is true
+ // when this method is called from InitDataReductionProxySettings.
+ virtual void SetProxyConfigs(bool enabled,
+ bool alternative_enabled,
+ bool restricted,
+ bool at_startup);
+
+ // Metrics method. Subclasses should override if they wish to provide
+ // alternatives.
virtual void RecordDataReductionInit();
virtual void AddDefaultProxyBypassRules();
@@ -253,10 +211,13 @@ class DataReductionProxySettings
virtual void RecordStartupState(
data_reduction_proxy::ProxyStartupState state);
- DataReductionProxyConfigurator* config() {
- return config_.get();
+ DataReductionProxyConfigurator* configurator() {
+ return configurator_.get();
}
+ // Reset params for tests.
+ void ResetParamsForTest(DataReductionProxyParams* params);
+
private:
friend class DataReductionProxySettingsTestBase;
friend class DataReductionProxySettingsTest;
@@ -288,16 +249,20 @@ class DataReductionProxySettings
TestBypassList);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
CheckInitMetricsWhenNotAllowed);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
+ TestSetProxyConfigs);
// NetworkChangeNotifier::IPAddressObserver:
virtual void OnIPAddressChanged() OVERRIDE;
// Underlying implementation of InitDataReductionProxySession(), factored
// out to be testable without creating a full HttpNetworkSession.
- static void InitDataReductionAuthentication(net::HttpAuthCache* auth_cache,
- const std::string& key);
+ static void InitDataReductionAuthentication(
+ net::HttpAuthCache* auth_cache,
+ const DataReductionProxyParams* params);
void OnProxyEnabledPrefChange();
+ void OnProxyAlternativeEnabledPrefChange();
void ResetDataReductionStatistics();
@@ -307,15 +272,12 @@ class DataReductionProxySettings
// the proxy, if enabled. Otherwise enables the proxy if disabled by a probe
// failure.
void ProbeWhetherDataReductionProxyIsAvailable();
- std::string GetProxyCheckURL();
// Returns a UTF16 string that's the hash of the configured authentication
// |key| and |salt|. Returns an empty UTF16 string if no key is configured or
// the data reduction proxy feature isn't available.
- static base::string16 AuthHashForSalt(int64 salt, const std::string& key);
-
- static bool allowed_;
- static bool promo_allowed_;
+ static base::string16 AuthHashForSalt(int64 salt,
+ const std::string& key);
std::string key_;
bool restricted_by_carrier_;
@@ -323,17 +285,18 @@ class DataReductionProxySettings
scoped_ptr<net::URLFetcher> fetcher_;
BooleanPrefMember spdy_proxy_auth_enabled_;
+ BooleanPrefMember data_reduction_proxy_alternative_enabled_;
PrefService* prefs_;
PrefService* local_state_prefs_;
net::URLRequestContextGetter* url_request_context_getter_;
- scoped_ptr<DataReductionProxyConfigurator> config_;
+ scoped_ptr<DataReductionProxyConfigurator> configurator_;
base::ThreadChecker thread_checker_;
- bool fallback_allowed_;
+ scoped_ptr<DataReductionProxyParams> params_;
DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings);
};

Powered by Google App Engine
This is Rietveld 408576698