| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 int32_t* kbps) const WARN_UNUSED_RESULT; | 342 int32_t* kbps) const WARN_UNUSED_RESULT; |
| 343 | 343 |
| 344 // Returns the list of intervals at which the accuracy of network quality | 344 // Returns the list of intervals at which the accuracy of network quality |
| 345 // prediction should be recorded. Virtualized for testing. | 345 // prediction should be recorded. Virtualized for testing. |
| 346 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() | 346 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() |
| 347 const; | 347 const; |
| 348 | 348 |
| 349 // Overrides the tick clock used by |this| for testing. | 349 // Overrides the tick clock used by |this| for testing. |
| 350 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 350 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| 351 | 351 |
| 352 // Returns a random double in the range [0.0, 1.0). Virtualized for testing. |
| 353 virtual double RandDouble() const; |
| 354 |
| 352 private: | 355 private: |
| 353 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 356 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 354 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); | 357 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| 355 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); | 358 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); |
| 356 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 359 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 357 ObtainAlgorithmToUseFromParams); | 360 ObtainAlgorithmToUseFromParams); |
| 358 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 361 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| 359 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); | 362 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); |
| 360 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); | 363 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching); |
| 361 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 364 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, | 539 EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK, |
| 537 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE, | 540 EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE, |
| 538 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE, | 541 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE, |
| 539 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY | 542 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY |
| 540 }; | 543 }; |
| 541 | 544 |
| 542 // Records the metrics related to external estimate provider. | 545 // Records the metrics related to external estimate provider. |
| 543 void RecordExternalEstimateProviderMetrics( | 546 void RecordExternalEstimateProviderMetrics( |
| 544 NQEExternalEstimateProviderStatus status) const; | 547 NQEExternalEstimateProviderStatus status) const; |
| 545 | 548 |
| 549 // Records a correlation metric that can be used for computing the correlation |
| 550 // between HTTP-layer RTT, transport-layer RTT, throughput and the time |
| 551 // taken to complete |request|. |
| 552 void RecordCorrelationMetric(const URLRequest& request) const; |
| 553 |
| 554 // Returns true if transport RTT should be used for computing the effective |
| 555 // connection type. |
| 556 bool UseTransportRTT() const; |
| 557 |
| 546 // Determines if the requests to local host can be used in estimating the | 558 // Determines if the requests to local host can be used in estimating the |
| 547 // network quality. Set to true only for tests. | 559 // network quality. Set to true only for tests. |
| 548 bool use_localhost_requests_; | 560 bool use_localhost_requests_; |
| 549 | 561 |
| 550 // Determines if the responses smaller than |kMinTransferSizeInBytes| | 562 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
| 551 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the | 563 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
| 552 // network quality. Set to true only for tests. | 564 // network quality. Set to true only for tests. |
| 553 bool use_small_responses_; | 565 bool use_small_responses_; |
| 554 | 566 |
| 555 // The factor by which the weight of an observation reduces every second. | 567 // The factor by which the weight of an observation reduces every second. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 // events. It is also updated every time there is network traffic (provided | 656 // events. It is also updated every time there is network traffic (provided |
| 645 // the last computation was more than | 657 // the last computation was more than |
| 646 // |effective_connection_type_recomputation_interval_| ago). | 658 // |effective_connection_type_recomputation_interval_| ago). |
| 647 EffectiveConnectionType effective_connection_type_; | 659 EffectiveConnectionType effective_connection_type_; |
| 648 | 660 |
| 649 // Minimum and Maximum signal strength (in dbM) observed since last connection | 661 // Minimum and Maximum signal strength (in dbM) observed since last connection |
| 650 // change. Updated on connection change and main frame requests. | 662 // change. Updated on connection change and main frame requests. |
| 651 int32_t min_signal_strength_since_connection_change_; | 663 int32_t min_signal_strength_since_connection_change_; |
| 652 int32_t max_signal_strength_since_connection_change_; | 664 int32_t max_signal_strength_since_connection_change_; |
| 653 | 665 |
| 666 // It is costlier to add values to a sparse histogram. So, the correlation UMA |
| 667 // is recorded with |correlation_uma_logging_probability_| since recording it |
| 668 // in a sparse histogram for each request is unnecessary and cost-prohibitive. |
| 669 // e.g., if it is 0.0, then the UMA will never be recorded. On the other hand, |
| 670 // if it is 1.0, then it will be recorded for all valid HTTP requests. |
| 671 const double correlation_uma_logging_probability_; |
| 672 |
| 654 base::ThreadChecker thread_checker_; | 673 base::ThreadChecker thread_checker_; |
| 655 | 674 |
| 656 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 675 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| 657 | 676 |
| 658 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 677 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 659 }; | 678 }; |
| 660 | 679 |
| 661 } // namespace net | 680 } // namespace net |
| 662 | 681 |
| 663 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 682 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |