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 the 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 421 |
420 void NotifyObserversOfRTT(const RttObservation& observation); | 422 void NotifyObserversOfRTT(const RttObservation& observation); |
421 | 423 |
422 void NotifyObserversOfThroughput(const ThroughputObservation& observation); | 424 void NotifyObserversOfThroughput(const ThroughputObservation& observation); |
423 | 425 |
424 // Returns true only if the |request| can be used for RTT estimation. | 426 // Returns true only if the |request| can be used for RTT estimation. |
425 bool RequestProvidesRTTObservation(const URLRequest& request) const; | 427 bool RequestProvidesRTTObservation(const URLRequest& request) const; |
426 | 428 |
427 // Recomputes effective connection type, if it was computed more than the | 429 // Recomputes effective connection type, if it was computed more than the |
428 // specified duration ago, or if there has been a connection change recently. | 430 // specified duration ago, or if there has been a connection change recently. |
429 void MaybeRecomputeEffectiveConnectionType(); | 431 void MaybeComputeEffectiveConnectionType(); |
430 | 432 |
431 // Notify observers of a change in effective connection type. | 433 // Notify observers of a change in effective connection type. |
432 void NotifyObserversOfEffectiveConnectionTypeChanged(); | 434 void NotifyObserversOfEffectiveConnectionTypeChanged(); |
433 | 435 |
434 // Records NQE accuracy metrics. |measuring_duration| should belong to the | 436 // Records NQE accuracy metrics. |measuring_duration| should belong to the |
435 // vector returned by AccuracyRecordingIntervals(). | 437 // vector returned by AccuracyRecordingIntervals(). |
436 // RecordAccuracyAfterMainFrame should be called |measuring_duration| after a | 438 // RecordAccuracyAfterMainFrame should be called |measuring_duration| after a |
437 // main frame request is observed. | 439 // main frame request is observed. |
438 void RecordAccuracyAfterMainFrame(base::TimeDelta measuring_duration) const; | 440 void RecordAccuracyAfterMainFrame(base::TimeDelta measuring_duration) const; |
439 | 441 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 478 |
477 // Records a correlation metric that can be used for computing the correlation | 479 // Records a correlation metric that can be used for computing the correlation |
478 // between HTTP-layer RTT, transport-layer RTT, throughput and the time | 480 // between HTTP-layer RTT, transport-layer RTT, throughput and the time |
479 // taken to complete |request|. | 481 // taken to complete |request|. |
480 void RecordCorrelationMetric(const URLRequest& request) const; | 482 void RecordCorrelationMetric(const URLRequest& request) const; |
481 | 483 |
482 // Returns true if transport RTT should be used for computing the effective | 484 // Returns true if transport RTT should be used for computing the effective |
483 // connection type. | 485 // connection type. |
484 bool UseTransportRTT() const; | 486 bool UseTransportRTT() const; |
485 | 487 |
| 488 // Forces computation of effective connection type, and notifies observers |
| 489 // if there is a change in its value. |
| 490 void ComputeEffectiveConnectionType(); |
| 491 |
486 // Determines if the requests to local host can be used in estimating the | 492 // Determines if the requests to local host can be used in estimating the |
487 // network quality. Set to true only for tests. | 493 // network quality. Set to true only for tests. |
488 bool use_localhost_requests_; | 494 bool use_localhost_requests_; |
489 | 495 |
490 // Determines if the responses smaller than |kMinTransferSizeInBytes| | 496 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
491 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the | 497 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
492 // network quality. Set to true only for tests. | 498 // network quality. Set to true only for tests. |
493 bool use_small_responses_; | 499 bool use_small_responses_; |
494 | 500 |
495 // The factor by which the weight of an observation reduces every second. | 501 // The factor by which the weight of an observation reduces every second. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 base::ThreadChecker thread_checker_; | 628 base::ThreadChecker thread_checker_; |
623 | 629 |
624 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 630 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
625 | 631 |
626 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 632 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
627 }; | 633 }; |
628 | 634 |
629 } // namespace net | 635 } // namespace net |
630 | 636 |
631 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 637 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
OLD | NEW |