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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 // Allows the responses smaller than |kMinTransferSizeInBits| to be used for | 141 // Allows the responses smaller than |kMinTransferSizeInBits| to be used for |
| 142 // network quality estimation. | 142 // network quality estimation. |
| 143 NetworkQualityEstimator( | 143 NetworkQualityEstimator( |
| 144 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, | 144 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, |
| 145 const std::map<std::string, std::string>& variation_params, | 145 const std::map<std::string, std::string>& variation_params, |
| 146 bool use_local_host_requests_for_tests, | 146 bool use_local_host_requests_for_tests, |
| 147 bool use_smaller_responses_for_tests); | 147 bool use_smaller_responses_for_tests); |
| 148 | 148 |
| 149 ~NetworkQualityEstimator() override; | 149 ~NetworkQualityEstimator() override; |
| 150 | 150 |
| 151 // Returns the effective type of the current connection. Virtualized for | 151 // Returns the last computed effective type of the current connection. The |
| 152 // testing. | 152 // effective connection type is computed by network quality estimator at |
| 153 // regular intervals and at certain events (e.g., connection change). | |
| 154 // Virtualized for testing. | |
| 153 virtual EffectiveConnectionType GetEffectiveConnectionType() const; | 155 virtual EffectiveConnectionType GetEffectiveConnectionType() const; |
| 154 | 156 |
| 155 // Returns the effective type of the current connection based on only the | 157 // Returns the effective type of the current connection based on only the |
| 156 // samples observed after |start_time|. This should only be used for | 158 // samples observed after |start_time|. This should only be used for |
| 157 // recording the metrics. Virtualized for testing. | 159 // recording the metrics. Virtualized for testing. |
| 158 virtual EffectiveConnectionType GetRecentEffectiveConnectionType( | 160 virtual EffectiveConnectionType GetRecentEffectiveConnectionType( |
| 159 const base::TimeTicks& start_time) const; | 161 const base::TimeTicks& start_time) const; |
| 160 | 162 |
| 161 // Adds |observer| to the list of effective connection type observers. Must be | 163 // Adds |observer| to the list of effective connection type observers. Must be |
| 162 // called on the IO thread. | 164 // called on the IO thread. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 // prediction should be recorded. Virtualized for testing. | 281 // prediction should be recorded. Virtualized for testing. |
| 280 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() | 282 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() |
| 281 const; | 283 const; |
| 282 | 284 |
| 283 // Overrides the tick clock used by |this| for testing. | 285 // Overrides the tick clock used by |this| for testing. |
| 284 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 286 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| 285 | 287 |
| 286 // Returns a random double in the range [0.0, 1.0). Virtualized for testing. | 288 // Returns a random double in the range [0.0, 1.0). Virtualized for testing. |
| 287 virtual double RandDouble() const; | 289 virtual double RandDouble() const; |
| 288 | 290 |
| 291 // Forces recomputtion of effective connection type, and notifies observers if | |
|
RyanSturm
2016/08/22 18:01:52
s/recomputtion/recomputation
tbansal1
2016/08/22 18:17:41
Done.
| |
| 292 // there is a change in its value. | |
| 293 void RecomputeEffectiveConnectionType(); | |
| 294 | |
| 289 private: | 295 private: |
| 290 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 296 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 291 AdaptiveRecomputationEffectiveConnectionType); | 297 AdaptiveRecomputationEffectiveConnectionType); |
| 292 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 298 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 293 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); | 299 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| 294 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); | 300 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); |
| 295 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, | 301 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| 296 ObtainAlgorithmToUseFromParams); | 302 ObtainAlgorithmToUseFromParams); |
| 297 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 303 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| 298 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); | 304 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 base::ThreadChecker thread_checker_; | 622 base::ThreadChecker thread_checker_; |
| 617 | 623 |
| 618 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 624 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| 619 | 625 |
| 620 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 626 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 621 }; | 627 }; |
| 622 | 628 |
| 623 } // namespace net | 629 } // namespace net |
| 624 | 630 |
| 625 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 631 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |