OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_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" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" | 17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" |
18 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 18 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
19 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" | |
20 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
21 #include "net/base/network_change_notifier.h" | 20 #include "net/base/network_change_notifier.h" |
22 #include "net/url_request/url_fetcher_delegate.h" | 21 #include "net/url_request/url_fetcher_delegate.h" |
23 | 22 |
24 class PrefService; | 23 class PrefService; |
25 | 24 |
26 namespace net { | 25 namespace net { |
27 class HostPortPair; | 26 class HostPortPair; |
28 class HttpNetworkSession; | 27 class HttpNetworkSession; |
29 class HttpResponseHeaders; | 28 class HttpResponseHeaders; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 90 |
92 static bool IsProxyKeySetOnCommandLine(); | 91 static bool IsProxyKeySetOnCommandLine(); |
93 | 92 |
94 DataReductionProxySettings(DataReductionProxyParams* params); | 93 DataReductionProxySettings(DataReductionProxyParams* params); |
95 virtual ~DataReductionProxySettings(); | 94 virtual ~DataReductionProxySettings(); |
96 | 95 |
97 DataReductionProxyParams* params() const { | 96 DataReductionProxyParams* params() const { |
98 return params_.get(); | 97 return params_.get(); |
99 } | 98 } |
100 | 99 |
101 DataReductionProxyUsageStats* usage_stats() const { | |
102 return usage_stats_; | |
103 } | |
104 | |
105 // Initializes the data reduction proxy with profile and local state prefs, | 100 // Initializes the data reduction proxy with profile and local state prefs, |
106 // and a |UrlRequestContextGetter| for canary probes. The caller must ensure | 101 // and a |UrlRequestContextGetter| for canary probes. The caller must ensure |
107 // that all parameters remain alive for the lifetime of the | 102 // that all parameters remain alive for the lifetime of the |
108 // |DataReductionProxySettings| instance. | 103 // |DataReductionProxySettings| instance. |
109 void InitDataReductionProxySettings( | 104 void InitDataReductionProxySettings( |
110 PrefService* prefs, | 105 PrefService* prefs, |
111 PrefService* local_state_prefs, | 106 PrefService* local_state_prefs, |
112 net::URLRequestContextGetter* url_request_context_getter); | 107 net::URLRequestContextGetter* url_request_context_getter); |
113 | 108 |
114 // Initializes the data reduction proxy with profile and local state prefs, | 109 // Initializes the data reduction proxy with profile and local state prefs, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // data reduction proxy. Each element in the vector contains one day of data. | 153 // data reduction proxy. Each element in the vector contains one day of data. |
159 ContentLengthList GetDailyOriginalContentLengths(); | 154 ContentLengthList GetDailyOriginalContentLengths(); |
160 | 155 |
161 // Returns aggregate received and original content lengths over the specified | 156 // Returns aggregate received and original content lengths over the specified |
162 // number of days, as well as the time these stats were last updated. | 157 // number of days, as well as the time these stats were last updated. |
163 void GetContentLengths(unsigned int days, | 158 void GetContentLengths(unsigned int days, |
164 int64* original_content_length, | 159 int64* original_content_length, |
165 int64* received_content_length, | 160 int64* received_content_length, |
166 int64* last_update_time); | 161 int64* last_update_time); |
167 | 162 |
| 163 // Records that the data reduction proxy is unreachable or not. |
| 164 void SetUnreachable(bool unreachable); |
| 165 |
168 // Returns whether the data reduction proxy is unreachable. Returns true | 166 // Returns whether the data reduction proxy is unreachable. Returns true |
169 // if no request has successfully completed through proxy, even though atleast | 167 // if no request has successfully completed through proxy, even though atleast |
170 // some of them should have. | 168 // some of them should have. |
171 bool IsDataReductionProxyUnreachable(); | 169 bool IsDataReductionProxyUnreachable(); |
172 | 170 |
173 // Set the data reduction proxy usage stats. | |
174 void SetDataReductionProxyUsageStats( | |
175 DataReductionProxyUsageStats* usage_stats); | |
176 | |
177 // Returns an vector containing the aggregate received HTTP content in the | 171 // Returns an vector containing the aggregate received HTTP content in the |
178 // last |kNumDaysInHistory| days. | 172 // last |kNumDaysInHistory| days. |
179 ContentLengthList GetDailyReceivedContentLengths(); | 173 ContentLengthList GetDailyReceivedContentLengths(); |
180 | 174 |
181 ContentLengthList GetDailyContentLengths(const char* pref_name); | 175 ContentLengthList GetDailyContentLengths(const char* pref_name); |
182 | 176 |
183 // net::URLFetcherDelegate: | 177 // net::URLFetcherDelegate: |
184 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 178 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
185 | 179 |
186 protected: | 180 protected: |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // data reduction proxy has been disabled. | 291 // data reduction proxy has been disabled. |
298 bool DisableIfVPN(); | 292 bool DisableIfVPN(); |
299 | 293 |
300 // Generic method to get a URL fetcher. | 294 // Generic method to get a URL fetcher. |
301 net::URLFetcher* GetBaseURLFetcher(const GURL& gurl, int load_flags); | 295 net::URLFetcher* GetBaseURLFetcher(const GURL& gurl, int load_flags); |
302 | 296 |
303 std::string key_; | 297 std::string key_; |
304 bool restricted_by_carrier_; | 298 bool restricted_by_carrier_; |
305 bool enabled_by_user_; | 299 bool enabled_by_user_; |
306 bool disabled_on_vpn_; | 300 bool disabled_on_vpn_; |
| 301 bool unreachable_; |
307 | 302 |
308 scoped_ptr<net::URLFetcher> fetcher_; | 303 scoped_ptr<net::URLFetcher> fetcher_; |
309 scoped_ptr<net::URLFetcher> warmup_fetcher_; | 304 scoped_ptr<net::URLFetcher> warmup_fetcher_; |
310 | 305 |
311 BooleanPrefMember spdy_proxy_auth_enabled_; | 306 BooleanPrefMember spdy_proxy_auth_enabled_; |
312 BooleanPrefMember data_reduction_proxy_alternative_enabled_; | 307 BooleanPrefMember data_reduction_proxy_alternative_enabled_; |
313 | 308 |
314 PrefService* prefs_; | 309 PrefService* prefs_; |
315 PrefService* local_state_prefs_; | 310 PrefService* local_state_prefs_; |
316 | 311 |
317 net::URLRequestContextGetter* url_request_context_getter_; | 312 net::URLRequestContextGetter* url_request_context_getter_; |
318 | 313 |
319 base::Callback<void(bool)> on_data_reduction_proxy_enabled_; | 314 base::Callback<void(bool)> on_data_reduction_proxy_enabled_; |
320 | 315 |
321 scoped_ptr<DataReductionProxyConfigurator> configurator_; | 316 scoped_ptr<DataReductionProxyConfigurator> configurator_; |
322 | 317 |
323 base::ThreadChecker thread_checker_; | 318 base::ThreadChecker thread_checker_; |
324 | 319 |
325 scoped_ptr<DataReductionProxyParams> params_; | 320 scoped_ptr<DataReductionProxyParams> params_; |
326 DataReductionProxyUsageStats* usage_stats_; | |
327 | 321 |
328 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); | 322 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); |
329 }; | 323 }; |
330 | 324 |
331 } // namespace data_reduction_proxy | 325 } // namespace data_reduction_proxy |
332 | 326 |
333 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS
_H_ | 327 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS
_H_ |
OLD | NEW |