| 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 // Gets the ProxyConfig that would be used ignoring the holdback experiment. | 216 // Gets the ProxyConfig that would be used ignoring the holdback experiment. |
| 217 // This should only be used for logging purposes. | 217 // This should only be used for logging purposes. |
| 218 net::ProxyConfig ProxyConfigIgnoringHoldback() const; | 218 net::ProxyConfig ProxyConfigIgnoringHoldback() const; |
| 219 | 219 |
| 220 bool secure_proxy_allowed() const; | 220 bool secure_proxy_allowed() const; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 247 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, | 247 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
| 248 AreProxiesBypassedRetryDelay); | 248 AreProxiesBypassedRetryDelay); |
| 249 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiParams); | 249 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiParams); |
| 250 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiMissingParams); | 250 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, AutoLoFiMissingParams); |
| 251 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, | 251 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
| 252 AutoLoFiParamsSlowConnectionsFlag); | 252 AutoLoFiParamsSlowConnectionsFlag); |
| 253 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, LoFiAccuracy); | 253 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, LoFiAccuracy); |
| 254 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, | 254 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
| 255 LoFiAccuracyNonZeroDelay); | 255 LoFiAccuracyNonZeroDelay); |
| 256 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, WarmupURL); | 256 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, WarmupURL); |
| 257 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, |
| 258 ShouldAcceptServerLoFi); |
| 259 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, ShouldAcceptLitePages); |
| 257 | 260 |
| 258 // Values of the estimated network quality at the beginning of the most | 261 // Values of the estimated network quality at the beginning of the most |
| 259 // recent query of the Network Quality Estimator. | 262 // recent query of the Network Quality Estimator. |
| 260 enum NetworkQualityAtLastQuery { | 263 enum NetworkQualityAtLastQuery { |
| 261 NETWORK_QUALITY_AT_LAST_QUERY_UNKNOWN, | 264 NETWORK_QUALITY_AT_LAST_QUERY_UNKNOWN, |
| 262 NETWORK_QUALITY_AT_LAST_QUERY_SLOW, | 265 NETWORK_QUALITY_AT_LAST_QUERY_SLOW, |
| 263 NETWORK_QUALITY_AT_LAST_QUERY_NOT_SLOW | 266 NETWORK_QUALITY_AT_LAST_QUERY_NOT_SLOW |
| 264 }; | 267 }; |
| 265 | 268 |
| 266 // NetworkChangeNotifier::IPAddressObserver: | 269 // NetworkChangeNotifier::IPAddressObserver: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 293 // proxies are bypassed, returns the minimum retry delay of the bypassed data | 296 // 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 | 297 // 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 | 298 // bypassed data reduction proxies for the request scheme, returns false and |
| 296 // does not assign min_retry_delay. | 299 // does not assign min_retry_delay. |
| 297 bool AreProxiesBypassed( | 300 bool AreProxiesBypassed( |
| 298 const net::ProxyRetryInfoMap& retry_map, | 301 const net::ProxyRetryInfoMap& retry_map, |
| 299 const net::ProxyConfig::ProxyRules& proxy_rules, | 302 const net::ProxyConfig::ProxyRules& proxy_rules, |
| 300 bool is_https, | 303 bool is_https, |
| 301 base::TimeDelta* min_retry_delay) const; | 304 base::TimeDelta* min_retry_delay) const; |
| 302 | 305 |
| 306 // Returns whether the request is blacklisted (or if Lo-Fi is disabled). |
| 307 bool IsBlackListedOrDisabled( |
| 308 const net::URLRequest& request, |
| 309 const previews::PreviewsDecider& previews_decider, |
| 310 previews::PreviewsType previews_type) const; |
| 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) const; |
| 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( |
| 327 const net::URLRequest& request, |
| 328 const previews::PreviewsDecider& previews_decider) const; |
| 329 |
| 303 // Returns true when Lo-Fi Previews should be activated. Determines if Lo-Fi | 330 // 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 | 331 // 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. | 332 // quality is prohibitively slow. |network_quality_estimator| may be NULL. |
| 306 // |previews_decider| is a non-null object that determines eligibility of the | 333 // |previews_decider| is a non-null object that determines eligibility of the |
| 307 // showing the preview based on past opt outs. | 334 // showing the preview based on past opt outs. |
| 308 bool ShouldEnableLoFiInternal(const net::URLRequest& request, | 335 // Should NOT be used if the kDataReductionProxyDecidesTransform feature is |
| 309 previews::PreviewsDecider* previews_decider); | 336 // enabled. |
| 337 bool ShouldEnableLoFiInternal( |
| 338 const net::URLRequest& request, |
| 339 const previews::PreviewsDecider& previews_decider); |
| 310 | 340 |
| 311 // Returns true when Lite Page Previews should be activated. Determines if | 341 // Returns true when Lite Page Previews should be activated. Determines if |
| 312 // Lite Page Previewsmode should be activated by checking the Lite Page | 342 // Lite Page Previewsmode should be activated by checking the Lite Page |
| 313 // Previews flags and if the network quality is prohibitively slow. | 343 // Previews flags and if the network quality is prohibitively slow. |
| 314 // |network_quality_estimator| may be NULL. |previews_decider| is a non-null | 344 // |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 | 345 // object that determines eligibility of showing the preview based on past opt |
| 316 // outs. | 346 // outs. |
| 347 // Should NOT be used if the kDataReductionProxyDecidesTransform feature is |
| 348 // enabled. |
| 317 bool ShouldEnableLitePagesInternal( | 349 bool ShouldEnableLitePagesInternal( |
| 318 const net::URLRequest& request, | 350 const net::URLRequest& request, |
| 319 previews::PreviewsDecider* previews_decider); | 351 const previews::PreviewsDecider& previews_decider); |
| 320 | 352 |
| 321 // Returns true if the network quality is at least as poor as the one | 353 // Returns true if the network quality is at least as poor as the one |
| 322 // specified in the Auto Lo-Fi field trial parameters. | 354 // specified in the Auto Lo-Fi field trial parameters. |
| 323 // |network_quality_estimator| may be NULL. Virtualized for unit testing. | 355 // |network_quality_estimator| may be NULL. Virtualized for unit testing. |
| 324 virtual bool IsNetworkQualityProhibitivelySlow( | 356 virtual bool IsNetworkQualityProhibitivelySlow( |
| 325 const net::NetworkQualityEstimator* network_quality_estimator); | 357 const net::NetworkQualityEstimator* network_quality_estimator); |
| 326 | 358 |
| 327 // Records Lo-Fi accuracy metric. |measuring_duration| should belong to the | 359 // Records Lo-Fi accuracy metric. |measuring_duration| should belong to the |
| 328 // vector returned by LofiAccuracyRecordingIntervals(). | 360 // vector returned by LofiAccuracyRecordingIntervals(). |
| 329 // RecordAutoLoFiAccuracyRate should be called |measuring_duration| after a | 361 // 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_; | 468 bool is_captive_portal_; |
| 437 | 469 |
| 438 base::WeakPtrFactory<DataReductionProxyConfig> weak_factory_; | 470 base::WeakPtrFactory<DataReductionProxyConfig> weak_factory_; |
| 439 | 471 |
| 440 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfig); | 472 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfig); |
| 441 }; | 473 }; |
| 442 | 474 |
| 443 } // namespace data_reduction_proxy | 475 } // namespace data_reduction_proxy |
| 444 | 476 |
| 445 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CON
FIG_H_ | 477 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CON
FIG_H_ |
| OLD | NEW |