| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Adds |observer| to the list of effective connection type observers. Must be | 178 // Adds |observer| to the list of effective connection type observers. Must be |
| 179 // called on the IO thread. | 179 // called on the IO thread. |
| 180 void AddEffectiveConnectionTypeObserver( | 180 void AddEffectiveConnectionTypeObserver( |
| 181 EffectiveConnectionTypeObserver* observer); | 181 EffectiveConnectionTypeObserver* observer); |
| 182 | 182 |
| 183 // Removes |observer| from the list of effective connection type observers. | 183 // Removes |observer| from the list of effective connection type observers. |
| 184 // Must be called on the IO thread. | 184 // Must be called on the IO thread. |
| 185 void RemoveEffectiveConnectionTypeObserver( | 185 void RemoveEffectiveConnectionTypeObserver( |
| 186 EffectiveConnectionTypeObserver* observer); | 186 EffectiveConnectionTypeObserver* observer); |
| 187 | 187 |
| 188 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at | |
| 189 // the HTTP layer. Virtualized for testing. |rtt| should not be null. The RTT | |
| 190 // at the HTTP layer measures the time from when the request was sent (this | |
| 191 // happens after the connection is established) to the time when the response | |
| 192 // headers were received. | |
| 193 virtual bool GetHttpRTTEstimate(base::TimeDelta* rtt) const | |
| 194 WARN_UNUSED_RESULT; | |
| 195 | |
| 196 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at | |
| 197 // the transport layer. |rtt| should not be null. Virtualized for testing. | |
| 198 virtual bool GetTransportRTTEstimate(base::TimeDelta* rtt) const | |
| 199 WARN_UNUSED_RESULT; | |
| 200 | |
| 201 // Returns true if downlink throughput is available and sets |kbps| to | |
| 202 // estimated downlink throughput (in kilobits per second). | |
| 203 // Virtualized for testing. |kbps| should not be null. | |
| 204 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const; | |
| 205 | |
| 206 // Notifies NetworkQualityEstimator that the response header of |request| has | 188 // Notifies NetworkQualityEstimator that the response header of |request| has |
| 207 // been received. | 189 // been received. |
| 208 void NotifyHeadersReceived(const URLRequest& request); | 190 void NotifyHeadersReceived(const URLRequest& request); |
| 209 | 191 |
| 210 // Notifies NetworkQualityEstimator that the headers of |request| are about to | 192 // Notifies NetworkQualityEstimator that the headers of |request| are about to |
| 211 // be sent. | 193 // be sent. |
| 212 void NotifyStartTransaction(const URLRequest& request); | 194 void NotifyStartTransaction(const URLRequest& request); |
| 213 | 195 |
| 214 // Notifies NetworkQualityEstimator that the response body of |request| has | 196 // Notifies NetworkQualityEstimator that the response body of |request| has |
| 215 // been received. | 197 // been received. |
| 216 void NotifyRequestCompleted(const URLRequest& request); | 198 void NotifyRequestCompleted(const URLRequest& request); |
| 217 | 199 |
| 218 // Notifies NetworkQualityEstimator that |request| will be destroyed. | 200 // Notifies NetworkQualityEstimator that |request| will be destroyed. |
| 219 void NotifyURLRequestDestroyed(const URLRequest& request); | 201 void NotifyURLRequestDestroyed(const URLRequest& request); |
| 220 | 202 |
| 221 // Returns true if median RTT at the HTTP layer is available and sets |rtt| | |
| 222 // to the median of RTT observations since |start_time|. | |
| 223 // Virtualized for testing. |rtt| should not be null. The RTT at the HTTP | |
| 224 // layer measures the time from when the request was sent (this happens after | |
| 225 // the connection is established) to the time when the response headers were | |
| 226 // received. | |
| 227 virtual bool GetRecentHttpRTTMedian(const base::TimeTicks& start_time, | |
| 228 base::TimeDelta* rtt) const | |
| 229 WARN_UNUSED_RESULT; | |
| 230 | |
| 231 // Returns true if the median RTT at the transport layer is available and sets | |
| 232 // |rtt| to the median of transport layer RTT observations since | |
| 233 // |start_time|. |rtt| should not be null. Virtualized for testing. | |
| 234 virtual bool GetRecentTransportRTTMedian(const base::TimeTicks& start_time, | |
| 235 base::TimeDelta* rtt) const | |
| 236 WARN_UNUSED_RESULT; | |
| 237 | |
| 238 // Returns true if median downstream throughput is available and sets |kbps| | |
| 239 // to the median of downstream throughput (in kilobits per second) | |
| 240 // observations since |start_time|. Virtualized for testing. |kbps| | |
| 241 // should not be null. Virtualized for testing. | |
| 242 virtual bool GetRecentMedianDownlinkThroughputKbps( | |
| 243 const base::TimeTicks& start_time, | |
| 244 int32_t* kbps) const WARN_UNUSED_RESULT; | |
| 245 | |
| 246 // Adds |rtt_observer| to the list of round trip time observers. Must be | 203 // Adds |rtt_observer| to the list of round trip time observers. Must be |
| 247 // called on the IO thread. | 204 // called on the IO thread. |
| 248 void AddRTTObserver(RTTObserver* rtt_observer); | 205 void AddRTTObserver(RTTObserver* rtt_observer); |
| 249 | 206 |
| 250 // Removes |rtt_observer| from the list of round trip time observers if it | 207 // Removes |rtt_observer| from the list of round trip time observers if it |
| 251 // is on the list of observers. Must be called on the IO thread. | 208 // is on the list of observers. Must be called on the IO thread. |
| 252 void RemoveRTTObserver(RTTObserver* rtt_observer); | 209 void RemoveRTTObserver(RTTObserver* rtt_observer); |
| 253 | 210 |
| 254 // Adds |throughput_observer| to the list of throughput observers. Must be | 211 // Adds |throughput_observer| to the list of throughput observers. Must be |
| 255 // called on the IO thread. | 212 // called on the IO thread. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 269 |
| 313 // NetworkChangeNotifier::ConnectionTypeObserver implementation: | 270 // NetworkChangeNotifier::ConnectionTypeObserver implementation: |
| 314 void OnConnectionTypeChanged( | 271 void OnConnectionTypeChanged( |
| 315 NetworkChangeNotifier::ConnectionType type) override; | 272 NetworkChangeNotifier::ConnectionType type) override; |
| 316 | 273 |
| 317 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. | 274 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. |
| 318 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, | 275 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, |
| 319 int32_t downstream_throughput_kbps, | 276 int32_t downstream_throughput_kbps, |
| 320 int32_t upstream_throughput_kbps) override; | 277 int32_t upstream_throughput_kbps) override; |
| 321 | 278 |
| 279 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at |
| 280 // the HTTP layer. Virtualized for testing. |rtt| should not be null. The RTT |
| 281 // at the HTTP layer measures the time from when the request was sent (this |
| 282 // happens after the connection is established) to the time when the response |
| 283 // headers were received. |
| 284 virtual bool GetHttpRTTEstimate(base::TimeDelta* rtt) const |
| 285 WARN_UNUSED_RESULT; |
| 286 |
| 287 // Returns true if the RTT is available and sets |rtt| to the RTT estimated at |
| 288 // the transport layer. |rtt| should not be null. Virtualized for testing. |
| 289 virtual bool GetTransportRTTEstimate(base::TimeDelta* rtt) const |
| 290 WARN_UNUSED_RESULT; |
| 291 |
| 292 // Returns true if downlink throughput is available and sets |kbps| to |
| 293 // estimated downlink throughput (in kilobits per second). |
| 294 // Virtualized for testing. |kbps| should not be null. |
| 295 virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const; |
| 296 |
| 297 // Returns true if median RTT at the HTTP layer is available and sets |rtt| |
| 298 // to the median of RTT observations since |start_time|. |
| 299 // Virtualized for testing. |rtt| should not be null. The RTT at the HTTP |
| 300 // layer measures the time from when the request was sent (this happens after |
| 301 // the connection is established) to the time when the response headers were |
| 302 // received. |
| 303 virtual bool GetRecentHttpRTTMedian(const base::TimeTicks& start_time, |
| 304 base::TimeDelta* rtt) const |
| 305 WARN_UNUSED_RESULT; |
| 306 |
| 307 // Returns true if the median RTT at the transport layer is available and sets |
| 308 // |rtt| to the median of transport layer RTT observations since |
| 309 // |start_time|. |rtt| should not be null. Virtualized for testing. |
| 310 virtual bool GetRecentTransportRTTMedian(const base::TimeTicks& start_time, |
| 311 base::TimeDelta* rtt) const |
| 312 WARN_UNUSED_RESULT; |
| 313 |
| 314 // Returns true if median downstream throughput is available and sets |kbps| |
| 315 // to the median of downstream throughput (in kilobits per second) |
| 316 // observations since |start_time|. Virtualized for testing. |kbps| |
| 317 // should not be null. Virtualized for testing. |
| 318 virtual bool GetRecentMedianDownlinkThroughputKbps( |
| 319 const base::TimeTicks& start_time, |
| 320 int32_t* kbps) const WARN_UNUSED_RESULT; |
| 321 |
| 322 // Returns the list of intervals at which the accuracy of network quality | 322 // Returns the list of intervals at which the accuracy of network quality |
| 323 // prediction should be recorded. Virtualized for testing. | 323 // prediction should be recorded. Virtualized for testing. |
| 324 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() | 324 virtual const std::vector<base::TimeDelta>& GetAccuracyRecordingIntervals() |
| 325 const; | 325 const; |
| 326 | 326 |
| 327 // Overrides the tick clock used by |this| for testing. | 327 // Overrides the tick clock used by |this| for testing. |
| 328 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 328 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| 329 | 329 |
| 330 private: | 330 private: |
| 331 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 331 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 base::ThreadChecker thread_checker_; | 597 base::ThreadChecker thread_checker_; |
| 598 | 598 |
| 599 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 599 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| 600 | 600 |
| 601 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 601 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 602 }; | 602 }; |
| 603 | 603 |
| 604 } // namespace net | 604 } // namespace net |
| 605 | 605 |
| 606 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 606 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |