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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings.h

Issue 412143009: Moved data reduction proxy initialization logic to ProfileImplIOData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
OLDNEW
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
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 140
146 // Returns the time in microseconds that the last update was made to the 141 // Returns the time in microseconds that the last update was made to the
147 // daily original and received content lengths. 142 // daily original and received content lengths.
148 int64 GetDataReductionLastUpdateTime(); 143 int64 GetDataReductionLastUpdateTime();
149 144
150 // Returns a vector containing the total size of all HTTP content that was 145 // Returns a vector containing the total size of all HTTP content that was
151 // received over the last |kNumDaysInHistory| before any compression by the 146 // received over the last |kNumDaysInHistory| before any compression by the
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
150 // Returns aggregate received and original content lengths over the specified
151 // number of days, as well as the time these stats were last updated.
152 void GetContentLengths(unsigned int days,
153 int64* original_content_length,
154 int64* received_content_length,
155 int64* last_update_time);
156
157 // Records that the data reduction proxy is unreachable or not.
158 void SetUnreachable(bool unreachable);
159
155 // Returns whether the data reduction proxy is unreachable. Returns true 160 // Returns whether the data reduction proxy is unreachable. Returns true
156 // if no request has successfully completed through proxy, even though atleast 161 // if no request has successfully completed through proxy, even though atleast
157 // some of them should have. 162 // some of them should have.
158 bool IsDataReductionProxyUnreachable(); 163 bool IsDataReductionProxyUnreachable();
159 164
160 // Set the data reduction proxy usage stats.
161 void SetDataReductionProxyUsageStats(
162 DataReductionProxyUsageStats* usage_stats);
163
164 // Returns an vector containing the aggregate received HTTP content in the 165 // Returns an vector containing the aggregate received HTTP content in the
165 // last |kNumDaysInHistory| days. 166 // last |kNumDaysInHistory| days.
166 ContentLengthList GetDailyReceivedContentLengths(); 167 ContentLengthList GetDailyReceivedContentLengths();
167 168
169 ContentLengthList GetDailyContentLengths(const char* pref_name);
170
168 // net::URLFetcherDelegate: 171 // net::URLFetcherDelegate:
169 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 172 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
170 173
171 protected: 174 protected:
172 void InitPrefMembers(); 175 void InitPrefMembers();
173 176
174 // Returns a fetcher for the probe to check if OK for the proxy to use SPDY. 177 // Returns a fetcher for the probe to check if OK for the proxy to use SPDY.
175 // Virtual for testing. 178 // Virtual for testing.
176 virtual net::URLFetcher* GetURLFetcherForAvailabilityCheck(); 179 virtual net::URLFetcher* GetURLFetcherForAvailabilityCheck();
177 180
178 // Returns a fetcher to warm up the connection to the data reduction proxy. 181 // Returns a fetcher to warm up the connection to the data reduction proxy.
179 // Virtual for testing. 182 // Virtual for testing.
180 virtual net::URLFetcher* GetURLFetcherForWarmup(); 183 virtual net::URLFetcher* GetURLFetcherForWarmup();
181 184
182 // Virtualized for unit test support. 185 // Virtualized for unit test support.
183 virtual PrefService* GetOriginalProfilePrefs(); 186 virtual PrefService* GetOriginalProfilePrefs();
184 virtual PrefService* GetLocalStatePrefs(); 187 virtual PrefService* GetLocalStatePrefs();
185 188
186 void GetContentLengths(unsigned int days,
187 int64* original_content_length,
188 int64* received_content_length,
189 int64* last_update_time);
190 ContentLengthList GetDailyContentLengths(const char* pref_name);
191
192 // Sets the proxy configs, enabling or disabling the proxy according to 189 // Sets the proxy configs, enabling or disabling the proxy according to
193 // the value of |enabled| and |alternative_enabled|. Use the alternative 190 // the value of |enabled| and |alternative_enabled|. Use the alternative
194 // configuration only if |enabled| and |alternative_enabled| are true. If 191 // configuration only if |enabled| and |alternative_enabled| are true. If
195 // |restricted| is true, only enable the fallback proxy. |at_startup| is true 192 // |restricted| is true, only enable the fallback proxy. |at_startup| is true
196 // when this method is called from InitDataReductionProxySettings. 193 // when this method is called from InitDataReductionProxySettings.
197 virtual void SetProxyConfigs(bool enabled, 194 virtual void SetProxyConfigs(bool enabled,
198 bool alternative_enabled, 195 bool alternative_enabled,
199 bool restricted, 196 bool restricted,
200 bool at_startup); 197 bool at_startup);
201 198
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // data reduction proxy has been disabled. 285 // data reduction proxy has been disabled.
289 bool DisableIfVPN(); 286 bool DisableIfVPN();
290 287
291 // Generic method to get a URL fetcher. 288 // Generic method to get a URL fetcher.
292 net::URLFetcher* GetBaseURLFetcher(const GURL& gurl, int load_flags); 289 net::URLFetcher* GetBaseURLFetcher(const GURL& gurl, int load_flags);
293 290
294 std::string key_; 291 std::string key_;
295 bool restricted_by_carrier_; 292 bool restricted_by_carrier_;
296 bool enabled_by_user_; 293 bool enabled_by_user_;
297 bool disabled_on_vpn_; 294 bool disabled_on_vpn_;
295 bool unreachable_;
298 296
299 scoped_ptr<net::URLFetcher> fetcher_; 297 scoped_ptr<net::URLFetcher> fetcher_;
300 scoped_ptr<net::URLFetcher> warmup_fetcher_; 298 scoped_ptr<net::URLFetcher> warmup_fetcher_;
301 299
302 BooleanPrefMember spdy_proxy_auth_enabled_; 300 BooleanPrefMember spdy_proxy_auth_enabled_;
303 BooleanPrefMember data_reduction_proxy_alternative_enabled_; 301 BooleanPrefMember data_reduction_proxy_alternative_enabled_;
304 302
305 PrefService* prefs_; 303 PrefService* prefs_;
306 PrefService* local_state_prefs_; 304 PrefService* local_state_prefs_;
307 305
308 net::URLRequestContextGetter* url_request_context_getter_; 306 net::URLRequestContextGetter* url_request_context_getter_;
309 307
310 scoped_ptr<DataReductionProxyConfigurator> configurator_; 308 scoped_ptr<DataReductionProxyConfigurator> configurator_;
311 309
312 base::ThreadChecker thread_checker_; 310 base::ThreadChecker thread_checker_;
313 311
314 scoped_ptr<DataReductionProxyParams> params_; 312 scoped_ptr<DataReductionProxyParams> params_;
315 DataReductionProxyUsageStats* usage_stats_;
316 313
317 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); 314 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings);
318 }; 315 };
319 316
320 } // namespace data_reduction_proxy 317 } // namespace data_reduction_proxy
321 318
322 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _H_ 319 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698