OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG
_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_serve
r.h" | 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_serve
r.h" |
| 22 #include "components/previews/core/previews_experiments.h" |
22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
23 #include "net/base/network_change_notifier.h" | 24 #include "net/base/network_change_notifier.h" |
24 #include "net/base/network_interfaces.h" | 25 #include "net/base/network_interfaces.h" |
25 #include "net/log/net_log_with_source.h" | 26 #include "net/log/net_log_with_source.h" |
26 #include "net/nqe/effective_connection_type.h" | 27 #include "net/nqe/effective_connection_type.h" |
27 #include "net/nqe/network_quality_estimator.h" | 28 #include "net/nqe/network_quality_estimator.h" |
28 #include "net/proxy/proxy_config.h" | 29 #include "net/proxy/proxy_config.h" |
29 #include "net/proxy/proxy_retry_info.h" | 30 #include "net/proxy/proxy_retry_info.h" |
30 | 31 |
31 class GURL; | 32 class GURL; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool promo_allowed() const; | 191 bool promo_allowed() const; |
191 | 192 |
192 // Sets |lofi_off_| to true. | 193 // Sets |lofi_off_| to true. |
193 void SetLoFiModeOff(); | 194 void SetLoFiModeOff(); |
194 | 195 |
195 // Returns |lofi_off_|. | 196 // Returns |lofi_off_|. |
196 bool lofi_off() const { return lofi_off_; } | 197 bool lofi_off() const { return lofi_off_; } |
197 | 198 |
198 // Returns true when Lo-Fi Previews should be activated. Records metrics for | 199 // Returns true when Lo-Fi Previews should be activated. Records metrics for |
199 // Lo-Fi state changes. |request| is used to get the network quality estimator | 200 // Lo-Fi state changes. |request| is used to get the network quality estimator |
200 // from the URLRequestContext. |previews_decider| is a non-null object that | 201 // from the URLRequestContext. |previews_decider| is used to check if |
201 // determines eligibility of showing the preview based on past opt outs. | 202 // |request| is locally blacklisted. |
202 bool ShouldEnableLoFi(const net::URLRequest& request, | 203 bool ShouldEnableLoFi(const net::URLRequest& request, |
203 previews::PreviewsDecider* previews_decider); | 204 const previews::PreviewsDecider& previews_decider); |
204 | 205 |
205 // Returns true when Lite Page Previews should be activated. |request| is used | 206 // Returns true when Lite Page Previews should be activated. |request| is used |
206 // to get the network quality estimator from the URLRequestContext. | 207 // to get the network quality estimator from the URLRequestContext. |
207 // |previews_decider| is a non-null object that determines eligibility of | 208 // |previews_decider| is used to check if |request| is locally blacklisted. |
208 // showing the preview based on past opt outs. | |
209 bool ShouldEnableLitePages(const net::URLRequest& request, | 209 bool ShouldEnableLitePages(const net::URLRequest& request, |
210 previews::PreviewsDecider* previews_decider); | 210 const previews::PreviewsDecider& previews_decider); |
211 | 211 |
212 // Returns true if the data saver has been enabled by the user, and the data | 212 // Returns true if the data saver has been enabled by the user, and the data |
213 // saver proxy is reachable. | 213 // saver proxy is reachable. |
214 bool enabled_by_user_and_reachable() const; | 214 bool enabled_by_user_and_reachable() const; |
215 | 215 |
| 216 // Returns whether the request is blacklisted (or if Lo-Fi is disabled). |
| 217 bool IsBlackListedOrDisabled( |
| 218 const net::URLRequest& request, |
| 219 const previews::PreviewsDecider& previews_decider, |
| 220 previews::PreviewsType previews_type); |
| 221 |
216 // Gets the ProxyConfig that would be used ignoring the holdback experiment. | 222 // Gets the ProxyConfig that would be used ignoring the holdback experiment. |
217 // This should only be used for logging purposes. | 223 // This should only be used for logging purposes. |
218 net::ProxyConfig ProxyConfigIgnoringHoldback() const; | 224 net::ProxyConfig ProxyConfigIgnoringHoldback() const; |
219 | 225 |
220 bool secure_proxy_allowed() const; | 226 bool secure_proxy_allowed() const; |
221 | 227 |
222 std::vector<DataReductionProxyServer> GetProxiesForHttp() const; | 228 std::vector<DataReductionProxyServer> GetProxiesForHttp() const; |
223 | 229 |
224 protected: | 230 protected: |
225 // Virtualized for mocking. Returns the list of network interfaces in use. | 231 // Virtualized for mocking. Returns the list of network interfaces in use. |
(...skipping 21 matching lines...) Expand all Loading... |
247 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, | 253 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
248 AreProxiesBypassedRetryDelay); | 254 AreProxiesBypassedRetryDelay); |
249 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiParams); | 255 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiParams); |
250 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiMissingParams); | 256 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiMissingParams); |
251 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, | 257 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
252 AutoLoFiParamsSlowConnectionsFlag); | 258 AutoLoFiParamsSlowConnectionsFlag); |
253 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, LoFiAccuracy); | 259 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, LoFiAccuracy); |
254 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, | 260 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
255 LoFiAccuracyNonZeroDelay); | 261 LoFiAccuracyNonZeroDelay); |
256 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, WarmupURL); | 262 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, WarmupURL); |
| 263 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
| 264 ShouldAcceptServerLoFi); |
| 265 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, ShouldAcceptLitePages); |
257 | 266 |
258 // Values of the estimated network quality at the beginning of the most | 267 // Values of the estimated network quality at the beginning of the most |
259 // recent query of the Network Quality Estimator. | 268 // recent query of the Network Quality Estimator. |
260 enum NetworkQualityAtLastQuery { | 269 enum NetworkQualityAtLastQuery { |
261 NETWORK_QUALITY_AT_LAST_QUERY_UNKNOWN, | 270 NETWORK_QUALITY_AT_LAST_QUERY_UNKNOWN, |
262 NETWORK_QUALITY_AT_LAST_QUERY_SLOW, | 271 NETWORK_QUALITY_AT_LAST_QUERY_SLOW, |
263 NETWORK_QUALITY_AT_LAST_QUERY_NOT_SLOW | 272 NETWORK_QUALITY_AT_LAST_QUERY_NOT_SLOW |
264 }; | 273 }; |
265 | 274 |
266 // NetworkChangeNotifier::IPAddressObserver: | 275 // NetworkChangeNotifier::IPAddressObserver: |
(...skipping 26 matching lines...) Expand all Loading... |
293 // proxies are bypassed, returns the minimum retry delay of the bypassed data | 302 // proxies are bypassed, returns the minimum retry delay of the bypassed data |
294 // reduction proxies in min_retry_delay (if not NULL). If there are no | 303 // reduction proxies in min_retry_delay (if not NULL). If there are no |
295 // bypassed data reduction proxies for the request scheme, returns false and | 304 // bypassed data reduction proxies for the request scheme, returns false and |
296 // does not assign min_retry_delay. | 305 // does not assign min_retry_delay. |
297 bool AreProxiesBypassed( | 306 bool AreProxiesBypassed( |
298 const net::ProxyRetryInfoMap& retry_map, | 307 const net::ProxyRetryInfoMap& retry_map, |
299 const net::ProxyConfig::ProxyRules& proxy_rules, | 308 const net::ProxyConfig::ProxyRules& proxy_rules, |
300 bool is_https, | 309 bool is_https, |
301 base::TimeDelta* min_retry_delay) const; | 310 base::TimeDelta* min_retry_delay) const; |
302 | 311 |
| 312 // Returns whether the client should report to the data reduction proxy that |
| 313 // it is willing to accept the Server Lo-Fi optimization for |request|. |
| 314 // |previews_decider| is used to check if |request| is locally blacklisted. |
| 315 // Should only be used if the kDataReductionProxyDecidesTransform feature is |
| 316 // enabled. |
| 317 bool ShouldAcceptServerLoFi( |
| 318 const net::URLRequest& request, |
| 319 const previews::PreviewsDecider& previews_decider); |
| 320 |
| 321 // Returns whether the client should report to the data reduction proxy that |
| 322 // it is willing to accept a LitePage optimization for |request|. |
| 323 // |previews_decider| is used to check if |request| is locally blacklisted. |
| 324 // Should only be used if the kDataReductionProxyDecidesTransform feature is |
| 325 // enabled. |
| 326 bool ShouldAcceptLitePages(const net::URLRequest& request, |
| 327 const previews::PreviewsDecider& previews_decider); |
| 328 |
303 // Returns true when Lo-Fi Previews should be activated. Determines if Lo-Fi | 329 // Returns true when Lo-Fi Previews should be activated. Determines if Lo-Fi |
304 // Previews should be activated by checking the Lo-Fi flags and if the network | 330 // Previews should be activated by checking the Lo-Fi flags and if the network |
305 // quality is prohibitively slow. |network_quality_estimator| may be NULL. | 331 // quality is prohibitively slow. |network_quality_estimator| may be NULL. |
306 // |previews_decider| is a non-null object that determines eligibility of the | 332 // |previews_decider| is a non-null object that determines eligibility of the |
307 // showing the preview based on past opt outs. | 333 // showing the preview based on past opt outs. |
308 bool ShouldEnableLoFiInternal(const net::URLRequest& request, | 334 // Should NOT be used if the kDataReductionProxyDecidesTransform feature is |
309 previews::PreviewsDecider* previews_decider); | 335 // enabled. |
| 336 bool ShouldEnableLoFiInternal( |
| 337 const net::URLRequest& request, |
| 338 const previews::PreviewsDecider& previews_decider); |
310 | 339 |
311 // Returns true when Lite Page Previews should be activated. Determines if | 340 // Returns true when Lite Page Previews should be activated. Determines if |
312 // Lite Page Previewsmode should be activated by checking the Lite Page | 341 // Lite Page Previewsmode should be activated by checking the Lite Page |
313 // Previews flags and if the network quality is prohibitively slow. | 342 // Previews flags and if the network quality is prohibitively slow. |
314 // |network_quality_estimator| may be NULL. |previews_decider| is a non-null | 343 // |network_quality_estimator| may be NULL. |previews_decider| is a non-null |
315 // object that determines eligibility of showing the preview based on past opt | 344 // object that determines eligibility of showing the preview based on past opt |
316 // outs. | 345 // outs. |
| 346 // Should NOT be used if the kDataReductionProxyDecidesTransform feature is |
| 347 // enabled. |
317 bool ShouldEnableLitePagesInternal( | 348 bool ShouldEnableLitePagesInternal( |
318 const net::URLRequest& request, | 349 const net::URLRequest& request, |
319 previews::PreviewsDecider* previews_decider); | 350 const previews::PreviewsDecider& previews_decider); |
320 | 351 |
321 // Returns true if the network quality is at least as poor as the one | 352 // Returns true if the network quality is at least as poor as the one |
322 // specified in the Auto Lo-Fi field trial parameters. | 353 // specified in the Auto Lo-Fi field trial parameters. |
323 // |network_quality_estimator| may be NULL. Virtualized for unit testing. | 354 // |network_quality_estimator| may be NULL. Virtualized for unit testing. |
324 virtual bool IsNetworkQualityProhibitivelySlow( | 355 virtual bool IsNetworkQualityProhibitivelySlow( |
325 const net::NetworkQualityEstimator* network_quality_estimator); | 356 const net::NetworkQualityEstimator* network_quality_estimator); |
326 | 357 |
327 // Records Lo-Fi accuracy metric. |measuring_duration| should belong to the | 358 // Records Lo-Fi accuracy metric. |measuring_duration| should belong to the |
328 // vector returned by LofiAccuracyRecordingIntervals(). | 359 // vector returned by LofiAccuracyRecordingIntervals(). |
329 // RecordAutoLoFiAccuracyRate should be called |measuring_duration| after a | 360 // RecordAutoLoFiAccuracyRate should be called |measuring_duration| after a |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 bool is_captive_portal_; | 467 bool is_captive_portal_; |
437 | 468 |
438 base::WeakPtrFactory<DataReductionProxyConfig> weak_factory_; | 469 base::WeakPtrFactory<DataReductionProxyConfig> weak_factory_; |
439 | 470 |
440 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfig); | 471 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfig); |
441 }; | 472 }; |
442 | 473 |
443 } // namespace data_reduction_proxy | 474 } // namespace data_reduction_proxy |
444 | 475 |
445 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CON
FIG_H_ | 476 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CON
FIG_H_ |
OLD | NEW |