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

Unified Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h

Issue 30883003: Simple fallback implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patched
Patch Set: Updated javadocs. Created 7 years, 2 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: chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h
index f066d661713d4b39fbef8b3e680667d43f6546dc..3f003da2f81ad2727645b4a330b9083daee7139e 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h
@@ -18,6 +18,10 @@
class PrefService;
namespace net {
+class AuthChallengeInfo;
+class HostPortPair;
+class HttpAuthCache;
+class HttpNetworkSession;
class URLFetcher;
}
@@ -37,17 +41,25 @@ COMPILE_ASSERT(kNumDaysInHistorySummary <= kNumDaysInHistory,
// Central point for configuring the data reduction proxy.
// This object lives on the UI thread and all of its methods are expected to
// be called from there.
+// TODO(marq): Convert this to be a BrowserContextKeyedService with an
+// associated factory class, and refactor the Java call sites accordingly.
class DataReductionProxySettings
: public net::URLFetcherDelegate,
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;
DataReductionProxySettings();
virtual ~DataReductionProxySettings();
void InitDataReductionProxySettings();
+ // If proxy authentication is compiled in, pre-cache authentication
+ // keys for all configured proxies in |session|.
+ static void InitDataReductionProxySession(net::HttpNetworkSession* session);
+
// Add a host pattern to bypass. This should follow the same syntax used
// in net::ProxyBypassRules; that is, a hostname pattern, a hostname suffix
// pattern, an IP literal, a CIDR block, or the magic string '<local>'.
@@ -64,19 +76,31 @@ class DataReductionProxySettings
// instance of Chrome. 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.
- bool IsDataReductionProxyAllowed();
+ 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.
- bool IsDataReductionProxyPromoAllowed();
+ static bool IsDataReductionProxyPromoAllowed();
// Returns the URL of the data reduction proxy.
- std::string GetDataReductionProxyOrigin();
+ 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();
- // Returns a configuration string for the proxy.
- std::string GetDataReductionProxyAuth();
+ // Returns true if |auth_info| represents an authentication challenge from
+ // a compatible, configured proxy.
+ 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
+ // be correctly generated for |auth_info|, returns an empty UTF16 string.
+ base::string16 GetTokenForAuthChallenge(net::AuthChallengeInfo* auth_info);
// Returns true if the proxy is enabled.
bool IsDataReductionProxyEnabled();
@@ -107,15 +131,13 @@ class DataReductionProxySettings
protected:
void InitPrefMembers();
+
virtual net::URLFetcher* GetURLFetcher();
// Virtualized for unit test support.
virtual PrefService* GetOriginalProfilePrefs();
virtual PrefService* GetLocalStatePrefs();
- std::string GetDataReductionProxyOriginHostPort();
-
- bool IsProxyOriginSetOnCommandLine();
void GetContentLengths(unsigned int days,
int64* original_content_length,
int64* received_content_length,
@@ -134,8 +156,8 @@ class DataReductionProxySettings
virtual void AddDefaultProxyBypassRules();
// Writes a warning to the log that is used in backend processing of
- // customer feedback.
- void LogProxyState(bool enabled, bool at_startup);
+ // customer feedback. Virtual so tests can mock it for verification.
+ virtual void LogProxyState(bool enabled, bool at_startup);
bool HasTurnedOn() { return has_turned_on_; }
bool HasTurnedOff() { return has_turned_off_; }
@@ -150,6 +172,12 @@ class DataReductionProxySettings
friend class DataReductionProxySettingsTestBase;
friend class DataReductionProxySettingsTest;
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
+ TestAuthenticationInit);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
+ TestAuthHashGeneration);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
+ TestAuthHashGenerationWithOriginSetViaSwitch);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestResetDataReductionStatistics);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestIsProxyEnabledOrManaged);
@@ -173,6 +201,10 @@ class DataReductionProxySettings
// 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);
+
void OnProxyEnabledPrefChange();
void ResetDataReductionStatistics();
@@ -185,6 +217,11 @@ class DataReductionProxySettings
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);
+
std::vector<std::string> bypass_rules_;
// Indicate whether a user has turned on the data reduction proxy previously

Powered by Google App Engine
This is Rietveld 408576698