Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ | 6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 // The number of days of bandwidth usage statistics that are tracked. | 31 // The number of days of bandwidth usage statistics that are tracked. |
| 32 const unsigned int kNumDaysInHistory = 60; | 32 const unsigned int kNumDaysInHistory = 60; |
| 33 | 33 |
| 34 // The number of days of bandwidth usage statistics that are presented. | 34 // The number of days of bandwidth usage statistics that are presented. |
| 35 const unsigned int kNumDaysInHistorySummary = 30; | 35 const unsigned int kNumDaysInHistorySummary = 30; |
| 36 | 36 |
| 37 COMPILE_ASSERT(kNumDaysInHistorySummary <= kNumDaysInHistory, | 37 COMPILE_ASSERT(kNumDaysInHistorySummary <= kNumDaysInHistory, |
| 38 DataReductionProxySettings_summary_too_long); | 38 DataReductionProxySettings_summary_too_long); |
| 39 | 39 |
| 40 // Values of the UMA DataReductionProxy.StartupState histogram. | |
|
bengr
2014/01/02 17:30:40
Must this enum stay in sync with something in hist
marq (ping after 24h)
2014/01/02 20:45:47
Done.
| |
| 41 enum ProxyStartupState { | |
| 42 PROXY_NOT_AVAILABLE = 0, | |
| 43 PROXY_DISABLED, | |
| 44 PROXY_ENABLED, | |
| 45 PROXY_STARTUP_STATE_COUNT, | |
| 46 }; | |
| 47 | |
| 48 // Values of the UMA DataReductionProxy.ProbeURL histogram. | |
| 49 // This enum must remain synchronized with DataReductionProxyProbeURLFetchResu lt | |
|
bengr
2014/01/02 17:30:40
> 80 characters
marq (ping after 24h)
2014/01/02 20:45:47
Done.
| |
| 50 // in metrics/histograms/histograms.xml. | |
| 51 // These names are misleading -- for 'DISABLED', read 'RESTRICTED'. | |
|
bengr
2014/01/02 17:30:40
Why aren't we just changing these to 'RESTRICTED'
marq (ping after 24h)
2014/01/02 20:45:47
Mostly because I didn't want to propagate the rena
bengr
2014/01/06 16:51:23
Please add a TODO to rename.
| |
| 52 enum ProbeURLFetchResult { | |
| 53 // The probe failed because the internet was disconnected. | |
| 54 INTERNET_DISCONNECTED = 0, | |
| 55 | |
| 56 // The probe failed for any other reason, and as a result, the proxy was | |
| 57 // disabled. | |
| 58 FAILED_PROXY_DISABLED, | |
| 59 | |
| 60 // The probe failed, but the proxy was already restricted. | |
| 61 FAILED_PROXY_ALREADY_DISABLED, | |
| 62 | |
| 63 // THe probe succeeded, and as a result the proxy was restricted. | |
| 64 SUCCEEDED_PROXY_ENABLED, | |
| 65 | |
| 66 // The probe succeeded, but the proxy was already restricted. | |
| 67 SUCCEEDED_PROXY_ALREADY_ENABLED, | |
| 68 | |
| 69 // This must always be last. | |
| 70 FETCH_RESULT_COUNT | |
|
bengr
2014/01/02 17:30:40
Rename to PROBE_URL_FETCH_RESULT_COUNT?
marq (ping after 24h)
2014/01/02 20:45:47
Done.
| |
| 71 }; | |
| 72 | |
| 40 } // namespace spdyproxy | 73 } // namespace spdyproxy |
| 41 | 74 |
| 42 // Central point for configuring the data reduction proxy. | 75 // Central point for configuring the data reduction proxy. |
| 43 // This object lives on the UI thread and all of its methods are expected to | 76 // This object lives on the UI thread and all of its methods are expected to |
| 44 // be called from there. | 77 // be called from there. |
| 45 // TODO(marq): Convert this to be a BrowserContextKeyedService with an | 78 // TODO(marq): Convert this to be a BrowserContextKeyedService with an |
| 46 // associated factory class, and refactor the Java call sites accordingly. | 79 // associated factory class, and refactor the Java call sites accordingly. |
| 47 class DataReductionProxySettings | 80 class DataReductionProxySettings |
| 48 : public net::URLFetcherDelegate, | 81 : public net::URLFetcherDelegate, |
| 49 public net::NetworkChangeNotifier::IPAddressObserver { | 82 public net::NetworkChangeNotifier::IPAddressObserver { |
| 50 public: | 83 public: |
| 51 typedef std::vector<long long> ContentLengthList; | 84 typedef std::vector<long long> ContentLengthList; |
| 52 // TODO(marq): Consider instead using a std::pair instead of a vector. | 85 // TODO(marq): Consider instead using a std::pair instead of a vector. |
| 53 typedef std::vector<GURL> DataReductionProxyList; | 86 typedef std::vector<GURL> DataReductionProxyList; |
| 54 | 87 |
| 88 | |
|
bengr
2014/01/02 17:30:40
Remove extra blank line.
marq (ping after 24h)
2014/01/02 20:45:47
Done.
| |
| 55 DataReductionProxySettings(); | 89 DataReductionProxySettings(); |
| 56 virtual ~DataReductionProxySettings(); | 90 virtual ~DataReductionProxySettings(); |
| 57 | 91 |
| 58 void InitDataReductionProxySettings(); | 92 void InitDataReductionProxySettings(); |
| 59 | 93 |
| 60 // If proxy authentication is compiled in, pre-cache authentication | 94 // If proxy authentication is compiled in, pre-cache authentication |
| 61 // keys for all configured proxies in |session|. | 95 // keys for all configured proxies in |session|. |
| 62 static void InitDataReductionProxySession(net::HttpNetworkSession* session); | 96 static void InitDataReductionProxySession(net::HttpNetworkSession* session); |
| 63 | 97 |
| 64 // Add a host pattern to bypass. This should follow the same syntax used | 98 // Add a host pattern to bypass. This should follow the same syntax used |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 199 |
| 166 virtual void AddDefaultProxyBypassRules(); | 200 virtual void AddDefaultProxyBypassRules(); |
| 167 | 201 |
| 168 // Writes a warning to the log that is used in backend processing of | 202 // Writes a warning to the log that is used in backend processing of |
| 169 // customer feedback. Virtual so tests can mock it for verification. | 203 // customer feedback. Virtual so tests can mock it for verification. |
| 170 virtual void LogProxyState(bool enabled, bool restricted, bool at_startup); | 204 virtual void LogProxyState(bool enabled, bool restricted, bool at_startup); |
| 171 | 205 |
| 172 // Accessor for unit tests. | 206 // Accessor for unit tests. |
| 173 std::vector<std::string> BypassRules() { return bypass_rules_;} | 207 std::vector<std::string> BypassRules() { return bypass_rules_;} |
| 174 | 208 |
| 209 // Virtualzied for mocking | |
|
bengr
2014/01/02 17:30:40
spelling.
marq (ping after 24h)
2014/01/02 20:45:47
Done.
| |
| 210 virtual void RecordProbeURLFetchResult(spdyproxy::ProbeURLFetchResult result); | |
| 211 virtual void RecordStartupState(spdyproxy::ProxyStartupState state); | |
| 212 | |
| 213 | |
| 175 private: | 214 private: |
| 176 friend class DataReductionProxySettingsTestBase; | 215 friend class DataReductionProxySettingsTestBase; |
| 177 friend class DataReductionProxySettingsTest; | 216 friend class DataReductionProxySettingsTest; |
| 178 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 217 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
| 179 TestAuthenticationInit); | 218 TestAuthenticationInit); |
| 180 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 219 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
| 181 TestAuthHashGeneration); | 220 TestAuthHashGeneration); |
| 182 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 221 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
| 183 TestAuthHashGenerationWithOriginSetViaSwitch); | 222 TestAuthHashGenerationWithOriginSetViaSwitch); |
| 184 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 223 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 bool restricted_by_carrier_; | 270 bool restricted_by_carrier_; |
| 232 bool enabled_by_user_; | 271 bool enabled_by_user_; |
| 233 | 272 |
| 234 scoped_ptr<net::URLFetcher> fetcher_; | 273 scoped_ptr<net::URLFetcher> fetcher_; |
| 235 BooleanPrefMember spdy_proxy_auth_enabled_; | 274 BooleanPrefMember spdy_proxy_auth_enabled_; |
| 236 | 275 |
| 237 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); | 276 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); |
| 238 }; | 277 }; |
| 239 | 278 |
| 240 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ | 279 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ |
| OLD | NEW |