| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 nqe::internal::NetworkQualityStore::NetworkQualitiesCacheObserver* | 291 nqe::internal::NetworkQualityStore::NetworkQualitiesCacheObserver* |
| 292 observer); | 292 observer); |
| 293 | 293 |
| 294 // Called when the persistent prefs have been read. |read_prefs| contains the | 294 // Called when the persistent prefs have been read. |read_prefs| contains the |
| 295 // parsed prefs as a map between NetworkIDs and CachedNetworkQualities. | 295 // parsed prefs as a map between NetworkIDs and CachedNetworkQualities. |
| 296 void OnPrefsRead( | 296 void OnPrefsRead( |
| 297 const std::map<nqe::internal::NetworkID, | 297 const std::map<nqe::internal::NetworkID, |
| 298 nqe::internal::CachedNetworkQuality> read_prefs); | 298 nqe::internal::CachedNetworkQuality> read_prefs); |
| 299 | 299 |
| 300 protected: | 300 protected: |
| 301 // A protected constructor for testing that allows setting the value of |
| 302 // |add_default_platform_observations_|. |
| 303 NetworkQualityEstimator( |
| 304 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, |
| 305 const std::map<std::string, std::string>& variation_params, |
| 306 bool use_local_host_requests_for_tests, |
| 307 bool use_smaller_responses_for_tests, |
| 308 bool add_default_platform_observations); |
| 309 |
| 301 // NetworkChangeNotifier::ConnectionTypeObserver implementation: | 310 // NetworkChangeNotifier::ConnectionTypeObserver implementation: |
| 302 void OnConnectionTypeChanged( | 311 void OnConnectionTypeChanged( |
| 303 NetworkChangeNotifier::ConnectionType type) override; | 312 NetworkChangeNotifier::ConnectionType type) override; |
| 304 | 313 |
| 305 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. | 314 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. |
| 306 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, | 315 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, |
| 307 int32_t downstream_throughput_kbps, | 316 int32_t downstream_throughput_kbps, |
| 308 int32_t upstream_throughput_kbps) override; | 317 int32_t upstream_throughput_kbps) override; |
| 309 | 318 |
| 310 // Returns true if median RTT at the HTTP layer is available and sets |rtt| | 319 // Returns true if median RTT at the HTTP layer is available and sets |rtt| |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 const base::TimeTicks& start_time, | 365 const base::TimeTicks& start_time, |
| 357 base::TimeDelta* http_rtt, | 366 base::TimeDelta* http_rtt, |
| 358 base::TimeDelta* transport_rtt, | 367 base::TimeDelta* transport_rtt, |
| 359 int32_t* downstream_throughput_kbps) const; | 368 int32_t* downstream_throughput_kbps) const; |
| 360 | 369 |
| 361 private: | 370 private: |
| 362 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 371 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 363 AdaptiveRecomputationEffectiveConnectionType); | 372 AdaptiveRecomputationEffectiveConnectionType); |
| 364 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 373 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 365 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); | 374 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| 366 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); | 375 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 376 DefaultObservationsOverridden); |
| 367 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 377 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 368 ObtainAlgorithmToUseFromParams); | 378 ObtainAlgorithmToUseFromParams); |
| 369 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 379 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| 370 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); | 380 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); |
| 371 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince); | 381 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince); |
| 372 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 382 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 373 TestExternalEstimateProviderMergeEstimates); | 383 TestExternalEstimateProviderMergeEstimates); |
| 374 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 384 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 375 UnknownEffectiveConnectionType); | 385 UnknownEffectiveConnectionType); |
| 376 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 386 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 581 |
| 572 // Determines if the requests to local host can be used in estimating the | 582 // Determines if the requests to local host can be used in estimating the |
| 573 // network quality. Set to true only for tests. | 583 // network quality. Set to true only for tests. |
| 574 bool use_localhost_requests_; | 584 bool use_localhost_requests_; |
| 575 | 585 |
| 576 // Determines if the responses smaller than |kMinTransferSizeInBytes| | 586 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
| 577 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the | 587 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
| 578 // network quality. Set to true only for tests. | 588 // network quality. Set to true only for tests. |
| 579 bool use_small_responses_; | 589 bool use_small_responses_; |
| 580 | 590 |
| 591 // If true, default values provided by the platform are used for estimation. |
| 592 const bool add_default_platform_observations_; |
| 593 |
| 581 // The factor by which the weight of an observation reduces every second. | 594 // The factor by which the weight of an observation reduces every second. |
| 582 const double weight_multiplier_per_second_; | 595 const double weight_multiplier_per_second_; |
| 583 | 596 |
| 584 // Algorithm to use for computing effective connection type. The value is | 597 // Algorithm to use for computing effective connection type. The value is |
| 585 // obtained from field trial parameters. If the value from field trial | 598 // obtained from field trial parameters. If the value from field trial |
| 586 // parameters is unavailable, it is set to | 599 // parameters is unavailable, it is set to |
| 587 // kDefaultEffectiveConnectionTypeAlgorithm. | 600 // kDefaultEffectiveConnectionTypeAlgorithm. |
| 588 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; | 601 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; |
| 589 | 602 |
| 590 // Tick clock used by the network quality estimator. | 603 // Tick clock used by the network quality estimator. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 612 // by timestamp. | 625 // by timestamp. |
| 613 ThroughputObservationBuffer downstream_throughput_kbps_observations_; | 626 ThroughputObservationBuffer downstream_throughput_kbps_observations_; |
| 614 | 627 |
| 615 // Buffer that holds RTT observations sorted by timestamp. | 628 // Buffer that holds RTT observations sorted by timestamp. |
| 616 RttObservationBuffer rtt_observations_; | 629 RttObservationBuffer rtt_observations_; |
| 617 | 630 |
| 618 // Default network quality observations obtained from the network quality | 631 // Default network quality observations obtained from the network quality |
| 619 // estimator field trial parameters. The observations are indexed by | 632 // estimator field trial parameters. The observations are indexed by |
| 620 // ConnectionType. | 633 // ConnectionType. |
| 621 nqe::internal::NetworkQuality | 634 nqe::internal::NetworkQuality |
| 622 default_observations_[NetworkChangeNotifier::CONNECTION_LAST]; | 635 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; |
| 623 | 636 |
| 624 // Thresholds for different effective connection types obtained from field | 637 // Thresholds for different effective connection types obtained from field |
| 625 // trial variation params. These thresholds encode how different connection | 638 // trial variation params. These thresholds encode how different connection |
| 626 // types behave in general. In future, complex encodings (e.g., curve | 639 // types behave in general. In future, complex encodings (e.g., curve |
| 627 // fitting) may be used. | 640 // fitting) may be used. |
| 628 nqe::internal::NetworkQuality connection_thresholds_ | 641 nqe::internal::NetworkQuality connection_thresholds_ |
| 629 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; | 642 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; |
| 630 | 643 |
| 631 // Typical network quality for different effective connection types. | 644 // Typical network quality for different effective connection types. |
| 632 nqe::internal::NetworkQuality typical_network_quality_ | 645 nqe::internal::NetworkQuality typical_network_quality_ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 base::ThreadChecker thread_checker_; | 726 base::ThreadChecker thread_checker_; |
| 714 | 727 |
| 715 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 728 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| 716 | 729 |
| 717 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 730 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 718 }; | 731 }; |
| 719 | 732 |
| 720 } // namespace net | 733 } // namespace net |
| 721 | 734 |
| 722 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 735 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |