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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() | 288 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() |
| 289 const; | 289 const; |
| 290 | 290 |
| 291 // Overrides the tick clock used by |this| for testing. | 291 // Overrides the tick clock used by |this| for testing. |
| 292 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 292 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| 293 | 293 |
| 294 // Returns a random double in the range [0.0, 1.0). Virtualized for testing. | 294 // Returns a random double in the range [0.0, 1.0). Virtualized for testing. |
| 295 virtual double RandDouble() const; | 295 virtual double RandDouble() const; |
| 296 | 296 |
| 297 private: | 297 private: |
| 298 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | |
| 299 AdaptiveRecomputationEffectiveConnectionType); | |
| 298 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 300 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 299 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); | 301 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| 300 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); | 302 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); |
| 301 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 303 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 302 ObtainAlgorithmToUseFromParams); | 304 ObtainAlgorithmToUseFromParams); |
| 303 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 305 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| 304 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); | 306 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); |
| 305 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince); | 307 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince); |
| 306 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 308 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 307 TestExternalEstimateProviderMergeEstimates); | 309 TestExternalEstimateProviderMergeEstimates); |
| 310 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | |
| 311 UnknownEffectiveConnectionType); | |
| 308 | 312 |
| 309 // Value of round trip time observations is in base::TimeDelta. | 313 // Value of round trip time observations is in base::TimeDelta. |
| 310 typedef nqe::internal::Observation<base::TimeDelta> RttObservation; | 314 typedef nqe::internal::Observation<base::TimeDelta> RttObservation; |
| 311 typedef nqe::internal::ObservationBuffer<base::TimeDelta> | 315 typedef nqe::internal::ObservationBuffer<base::TimeDelta> |
| 312 RttObservationBuffer; | 316 RttObservationBuffer; |
| 313 | 317 |
| 314 // Value of throughput observations is in kilobits per second. | 318 // Value of throughput observations is in kilobits per second. |
| 315 typedef nqe::internal::Observation<int32_t> ThroughputObservation; | 319 typedef nqe::internal::Observation<int32_t> ThroughputObservation; |
| 316 typedef nqe::internal::ObservationBuffer<int32_t> ThroughputObservationBuffer; | 320 typedef nqe::internal::ObservationBuffer<int32_t> ThroughputObservationBuffer; |
| 317 | 321 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 | 505 |
| 502 // Algorithm to use for computing effective connection type. The value is | 506 // Algorithm to use for computing effective connection type. The value is |
| 503 // obtained from field trial parameters. If the value from field trial | 507 // obtained from field trial parameters. If the value from field trial |
| 504 // parameters is unavailable, it is set to | 508 // parameters is unavailable, it is set to |
| 505 // kDefaultEffectiveConnectionTypeAlgorithm. | 509 // kDefaultEffectiveConnectionTypeAlgorithm. |
| 506 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; | 510 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; |
| 507 | 511 |
| 508 // Tick clock used by the network quality estimator. | 512 // Tick clock used by the network quality estimator. |
| 509 std::unique_ptr<base::TickClock> tick_clock_; | 513 std::unique_ptr<base::TickClock> tick_clock_; |
| 510 | 514 |
| 511 // Minimum duration between two consecutive computations of effective | |
| 512 // connection type. Set to non-zero value as a performance optimization. | |
| 513 const base::TimeDelta effective_connection_type_recomputation_interval_; | |
| 514 | |
| 515 // Time when the effective connection type was last computed. | |
| 516 base::TimeTicks last_effective_connection_type_computation_; | |
| 517 | |
| 518 // Intervals after the main frame request arrives at which accuracy of network | 515 // Intervals after the main frame request arrives at which accuracy of network |
| 519 // quality prediction is recorded. | 516 // quality prediction is recorded. |
| 520 std::vector<base::TimeDelta> accuracy_recording_intervals_; | 517 std::vector<base::TimeDelta> accuracy_recording_intervals_; |
| 521 | 518 |
| 522 // Time when last connection change was observed. | 519 // Time when last connection change was observed. |
| 523 base::TimeTicks last_connection_change_; | 520 base::TimeTicks last_connection_change_; |
| 524 | 521 |
| 525 // ID of the current network. | 522 // ID of the current network. |
| 526 nqe::internal::NetworkID current_network_id_; | 523 nqe::internal::NetworkID current_network_id_; |
| 527 | 524 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 base::ObserverList<ThroughputObserver> throughput_observer_list_; | 581 base::ObserverList<ThroughputObserver> throughput_observer_list_; |
| 585 | 582 |
| 586 std::unique_ptr<SocketPerformanceWatcherFactory> watcher_factory_; | 583 std::unique_ptr<SocketPerformanceWatcherFactory> watcher_factory_; |
| 587 | 584 |
| 588 // Takes throughput measurements, and passes them back to |this| through the | 585 // Takes throughput measurements, and passes them back to |this| through the |
| 589 // provided callback. |this| stores the throughput observations in | 586 // provided callback. |this| stores the throughput observations in |
| 590 // |downstream_throughput_kbps_observations_|, which are later used for | 587 // |downstream_throughput_kbps_observations_|, which are later used for |
| 591 // estimating the throughput. | 588 // estimating the throughput. |
| 592 std::unique_ptr<nqe::internal::ThroughputAnalyzer> throughput_analyzer_; | 589 std::unique_ptr<nqe::internal::ThroughputAnalyzer> throughput_analyzer_; |
| 593 | 590 |
| 591 // Minimum duration between two consecutive computations of effective | |
| 592 // connection type. Set to non-zero value as a performance optimization. | |
| 593 const base::TimeDelta effective_connection_type_recomputation_interval_; | |
| 594 | |
| 595 // Time when the effective connection type was last computed. | |
| 596 base::TimeTicks last_effective_connection_type_computation_; | |
| 597 | |
| 598 // Number of RTT and bandwidth samples available when effective connection | |
| 599 // type was last recomputed. | |
| 600 size_t number_of_rtt_samples_at_last_ect_computation_; | |
| 601 size_t number_of_bandwidth_samples_at_last_ect_computation_; | |
|
RyanSturm
2016/08/08 23:57:01
nit: The naming of this variable is mouthful and h
tbansal1
2016/08/09 18:00:56
Done.
| |
| 602 | |
| 594 // Current effective connection type. It is updated on connection change | 603 // Current effective connection type. It is updated on connection change |
| 595 // events. It is also updated every time there is network traffic (provided | 604 // events. It is also updated every time there is network traffic (provided |
| 596 // the last computation was more than | 605 // the last computation was more than |
| 597 // |effective_connection_type_recomputation_interval_| ago). | 606 // |effective_connection_type_recomputation_interval_| ago). |
| 598 EffectiveConnectionType effective_connection_type_; | 607 EffectiveConnectionType effective_connection_type_; |
| 599 | 608 |
| 600 // Minimum and Maximum signal strength (in dbM) observed since last connection | 609 // Minimum and Maximum signal strength (in dbM) observed since last connection |
| 601 // change. Updated on connection change and main frame requests. | 610 // change. Updated on connection change and main frame requests. |
| 602 int32_t min_signal_strength_since_connection_change_; | 611 int32_t min_signal_strength_since_connection_change_; |
| 603 int32_t max_signal_strength_since_connection_change_; | 612 int32_t max_signal_strength_since_connection_change_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 615 base::ThreadChecker thread_checker_; | 624 base::ThreadChecker thread_checker_; |
| 616 | 625 |
| 617 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 626 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| 618 | 627 |
| 619 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 628 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 620 }; | 629 }; |
| 621 | 630 |
| 622 } // namespace net | 631 } // namespace net |
| 623 | 632 |
| 624 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 633 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |