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