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. |
| 41 // This enum must remain synchronized with DataReductionProxyStartupState |
| 42 // in metrics/histograms/histograms.xml. |
| 43 enum ProxyStartupState { |
| 44 PROXY_NOT_AVAILABLE = 0, |
| 45 PROXY_DISABLED, |
| 46 PROXY_ENABLED, |
| 47 PROXY_STARTUP_STATE_COUNT, |
| 48 }; |
| 49 |
| 50 // Values of the UMA DataReductionProxy.ProbeURL histogram. |
| 51 // This enum must remain synchronized with |
| 52 // DataReductionProxyProbeURLFetchResult in metrics/histograms/histograms.xml. |
| 53 // TODO(marq): Rename these histogram buckets with s/DISABLED/RESTRICTED/, so |
| 54 // their names match the behavior they track. |
| 55 enum ProbeURLFetchResult { |
| 56 // The probe failed because the internet was disconnected. |
| 57 INTERNET_DISCONNECTED = 0, |
| 58 |
| 59 // The probe failed for any other reason, and as a result, the proxy was |
| 60 // disabled. |
| 61 FAILED_PROXY_DISABLED, |
| 62 |
| 63 // The probe failed, but the proxy was already restricted. |
| 64 FAILED_PROXY_ALREADY_DISABLED, |
| 65 |
| 66 // THe probe succeeded, and as a result the proxy was restricted. |
| 67 SUCCEEDED_PROXY_ENABLED, |
| 68 |
| 69 // The probe succeeded, but the proxy was already restricted. |
| 70 SUCCEEDED_PROXY_ALREADY_ENABLED, |
| 71 |
| 72 // This must always be last. |
| 73 PROBE_URL_FETCH_RESULT_COUNT |
| 74 }; |
| 75 |
40 } // namespace spdyproxy | 76 } // namespace spdyproxy |
41 | 77 |
42 // Central point for configuring the data reduction proxy. | 78 // Central point for configuring the data reduction proxy. |
43 // This object lives on the UI thread and all of its methods are expected to | 79 // This object lives on the UI thread and all of its methods are expected to |
44 // be called from there. | 80 // be called from there. |
45 // TODO(marq): Convert this to be a BrowserContextKeyedService with an | 81 // TODO(marq): Convert this to be a BrowserContextKeyedService with an |
46 // associated factory class, and refactor the Java call sites accordingly. | 82 // associated factory class, and refactor the Java call sites accordingly. |
47 class DataReductionProxySettings | 83 class DataReductionProxySettings |
48 : public net::URLFetcherDelegate, | 84 : public net::URLFetcherDelegate, |
49 public net::NetworkChangeNotifier::IPAddressObserver { | 85 public net::NetworkChangeNotifier::IPAddressObserver { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 201 |
166 virtual void AddDefaultProxyBypassRules(); | 202 virtual void AddDefaultProxyBypassRules(); |
167 | 203 |
168 // Writes a warning to the log that is used in backend processing of | 204 // Writes a warning to the log that is used in backend processing of |
169 // customer feedback. Virtual so tests can mock it for verification. | 205 // customer feedback. Virtual so tests can mock it for verification. |
170 virtual void LogProxyState(bool enabled, bool restricted, bool at_startup); | 206 virtual void LogProxyState(bool enabled, bool restricted, bool at_startup); |
171 | 207 |
172 // Accessor for unit tests. | 208 // Accessor for unit tests. |
173 std::vector<std::string> BypassRules() { return bypass_rules_;} | 209 std::vector<std::string> BypassRules() { return bypass_rules_;} |
174 | 210 |
| 211 // Virtualized for mocking |
| 212 virtual void RecordProbeURLFetchResult(spdyproxy::ProbeURLFetchResult result); |
| 213 virtual void RecordStartupState(spdyproxy::ProxyStartupState state); |
| 214 |
175 private: | 215 private: |
176 friend class DataReductionProxySettingsTestBase; | 216 friend class DataReductionProxySettingsTestBase; |
177 friend class DataReductionProxySettingsTest; | 217 friend class DataReductionProxySettingsTest; |
178 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 218 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
179 TestAuthenticationInit); | 219 TestAuthenticationInit); |
180 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 220 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
181 TestAuthHashGeneration); | 221 TestAuthHashGeneration); |
182 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 222 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
183 TestAuthHashGenerationWithOriginSetViaSwitch); | 223 TestAuthHashGenerationWithOriginSetViaSwitch); |
184 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, | 224 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 bool restricted_by_carrier_; | 271 bool restricted_by_carrier_; |
232 bool enabled_by_user_; | 272 bool enabled_by_user_; |
233 | 273 |
234 scoped_ptr<net::URLFetcher> fetcher_; | 274 scoped_ptr<net::URLFetcher> fetcher_; |
235 BooleanPrefMember spdy_proxy_auth_enabled_; | 275 BooleanPrefMember spdy_proxy_auth_enabled_; |
236 | 276 |
237 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); | 277 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); |
238 }; | 278 }; |
239 | 279 |
240 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ | 280 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_H_ |
OLD | NEW |