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

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: Unit tests passing, feedback applied. 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..6480378cc1d4fb0ba2fca20a3fa9bc5f51f77435 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h
@@ -18,6 +18,9 @@
class PrefService;
namespace net {
+class AuthChallengeInfo;
+class HostPortPair;
+class HttpNetworkSession;
class URLFetcher;
}
@@ -42,12 +45,17 @@ class DataReductionProxySettings
public net::NetworkChangeNotifier::IPAddressObserver {
public:
typedef std::vector<long long> ContentLengthList;
+ typedef std::vector<net::HostPortPair> DataReductionProxyList;
DataReductionProxySettings();
virtual ~DataReductionProxySettings();
void InitDataReductionProxySettings();
+ // If proxy authentication is compiled in, pre-cache authentication
+ // keys for all configured proxies in |session|.
+ 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>'.
@@ -75,8 +83,20 @@ class DataReductionProxySettings
// Returns the URL of the data reduction proxy.
std::string GetDataReductionProxyOrigin();
- // Returns a configuration string for the proxy.
- std::string GetDataReductionProxyAuth();
+ // Returns the URL of the fallback data reduction proxy.
+ std::string GetDataReductionProxyFallback();
+
+ // Returns a vector of HostPortPairs for all configured proxies.
bengr 2013/10/22 17:49:30 It seems a little strange to return a vector when
marq (ping after 24h) 2013/10/22 21:18:01 It's somewhat cleaner (to my mind) to write generi
+ DataReductionProxyList GetDataReductionProxies();
+
+ // 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();
@@ -113,8 +133,6 @@ class DataReductionProxySettings
virtual PrefService* GetOriginalProfilePrefs();
virtual PrefService* GetLocalStatePrefs();
- std::string GetDataReductionProxyOriginHostPort();
-
bool IsProxyOriginSetOnCommandLine();
void GetContentLengths(unsigned int days,
int64* original_content_length,
@@ -146,10 +164,18 @@ class DataReductionProxySettings
// Accessor for unit tests.
std::vector<std::string> BypassRules() { return bypass_rules_;}
+ // Accessors for default hostnames, virtual for testing.
+ virtual std::string GetDefaultProxyHost();
+ virtual std::string GetDefaultFallbackProxyHost();
+
private:
friend class DataReductionProxySettingsTestBase;
friend class DataReductionProxySettingsTest;
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
+ TestAuthHashGeneration);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
+ TestAuthHashGenerationWithOriginSetViaSwitch);
+ FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestResetDataReductionStatistics);
FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
TestIsProxyEnabledOrManaged);
@@ -185,6 +211,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.
+ 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