Chromium Code Reviews| 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 NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 5 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 const char* GetNameForEffectiveConnectionType( | 310 const char* GetNameForEffectiveConnectionType( |
| 311 EffectiveConnectionType type) const; | 311 EffectiveConnectionType type) const; |
| 312 | 312 |
| 313 // Overrides the tick clock used by |this| for testing. | 313 // Overrides the tick clock used by |this| for testing. |
| 314 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 314 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| 315 | 315 |
| 316 private: | 316 private: |
| 317 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 317 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 318 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); | 318 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| 319 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); | 319 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); |
| 320 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | |
| 321 ObtainAlgorithmToUseFromParams); | |
| 320 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 322 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| 321 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); | 323 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); |
| 322 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); | 324 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); |
| 323 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 325 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 324 TestLRUCacheMaximumSize); | 326 TestLRUCacheMaximumSize); |
| 325 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince); | 327 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince); |
| 326 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 328 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 327 TestExternalEstimateProviderMergeEstimates); | 329 TestExternalEstimateProviderMergeEstimates); |
| 328 | 330 |
| 329 class SocketWatcher; | 331 class SocketWatcher; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 // Returns true only if the |request| can be used for RTT estimation. | 434 // Returns true only if the |request| can be used for RTT estimation. |
| 433 bool RequestProvidesRTTObservation(const URLRequest& request) const; | 435 bool RequestProvidesRTTObservation(const URLRequest& request) const; |
| 434 | 436 |
| 435 // Recomputes effective connection type, if it was computed more than the | 437 // Recomputes effective connection type, if it was computed more than the |
| 436 // specified duration ago, or if there has been a connection change recently. | 438 // specified duration ago, or if there has been a connection change recently. |
| 437 void MaybeRecomputeEffectiveConnectionType(); | 439 void MaybeRecomputeEffectiveConnectionType(); |
| 438 | 440 |
| 439 // Notify observers of a change in effective connection type. | 441 // Notify observers of a change in effective connection type. |
| 440 void NotifyObserversOfEffectiveConnectionTypeChanged(); | 442 void NotifyObserversOfEffectiveConnectionTypeChanged(); |
| 441 | 443 |
| 444 // Returns the effective type of the current connection based on only the | |
| 445 // samples observed after |start_time|. Uses algorithm 0 to compute the | |
| 446 // effective connection type. This algorithm uses HTTP RTT and downlink | |
| 447 // throughput as inputs, and requires both inputs to have a valid value. | |
| 448 // This method should be called only if |algorithm_| is 0. | |
| 449 EffectiveConnectionType GetRecentEffectiveConnectionTypeAlgorithm0( | |
| 450 const base::TimeTicks& start_time) const; | |
| 451 | |
| 442 // Values of external estimate provider status. This enum must remain | 452 // Values of external estimate provider status. This enum must remain |
| 443 // synchronized with the enum of the same name in | 453 // synchronized with the enum of the same name in |
| 444 // metrics/histograms/histograms.xml. | 454 // metrics/histograms/histograms.xml. |
| 445 enum NQEExternalEstimateProviderStatus { | 455 enum NQEExternalEstimateProviderStatus { |
| 446 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, | 456 EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE, |
| 447 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, | 457 EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE, |
| 448 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, | 458 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED, |
| 449 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, | 459 EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL, |
| 450 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, | 460 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, |
| 451 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE, | 461 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 462 const bool use_localhost_requests_; | 472 const bool use_localhost_requests_; |
| 463 | 473 |
| 464 // Determines if the responses smaller than |kMinTransferSizeInBytes| | 474 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
| 465 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the | 475 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
| 466 // network quality. Set to true only for tests. | 476 // network quality. Set to true only for tests. |
| 467 const bool use_small_responses_; | 477 const bool use_small_responses_; |
| 468 | 478 |
| 469 // The factor by which the weight of an observation reduces every second. | 479 // The factor by which the weight of an observation reduces every second. |
| 470 const double weight_multiplier_per_second_; | 480 const double weight_multiplier_per_second_; |
| 471 | 481 |
| 482 // Algorithm to use for computing effective connection type. The value is | |
| 483 // obtained from field trial parameters. If the value from field trial | |
| 484 // parameters is unavailable, it is set to default value of 0. | |
| 485 const int32_t algorithm_; | |
|
bengr
2016/06/02 22:59:43
Letters are more intuitive than numbers for experi
tbansal1
2016/06/03 00:50:10
Done.
| |
| 486 | |
| 472 // Tick clock used by the network quality estimator. | 487 // Tick clock used by the network quality estimator. |
| 473 std::unique_ptr<base::TickClock> tick_clock_; | 488 std::unique_ptr<base::TickClock> tick_clock_; |
| 474 | 489 |
| 475 // Minimum duration between two consecutive computations of effective | 490 // Minimum duration between two consecutive computations of effective |
| 476 // connection type. Set to non-zero value as a performance optimization. | 491 // connection type. Set to non-zero value as a performance optimization. |
| 477 const base::TimeDelta effective_connection_type_recomputation_interval_; | 492 const base::TimeDelta effective_connection_type_recomputation_interval_; |
| 478 | 493 |
| 479 // Time when the effective connection type was last computed. | 494 // Time when the effective connection type was last computed. |
| 480 base::TimeTicks last_effective_connection_type_computation_; | 495 base::TimeTicks last_effective_connection_type_computation_; |
| 481 | 496 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 base::ThreadChecker thread_checker_; | 563 base::ThreadChecker thread_checker_; |
| 549 | 564 |
| 550 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 565 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| 551 | 566 |
| 552 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 567 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 553 }; | 568 }; |
| 554 | 569 |
| 555 } // namespace net | 570 } // namespace net |
| 556 | 571 |
| 557 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 572 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |