| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 // Returns true if the cached network quality estimate was successfully read. | 260 // Returns true if the cached network quality estimate was successfully read. |
| 261 bool ReadCachedNetworkQualityEstimate(); | 261 bool ReadCachedNetworkQualityEstimate(); |
| 262 | 262 |
| 263 // NetworkChangeNotifier::ConnectionTypeObserver implementation: | 263 // NetworkChangeNotifier::ConnectionTypeObserver implementation: |
| 264 void OnConnectionTypeChanged( | 264 void OnConnectionTypeChanged( |
| 265 NetworkChangeNotifier::ConnectionType type) override; | 265 NetworkChangeNotifier::ConnectionType type) override; |
| 266 | 266 |
| 267 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. | 267 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. |
| 268 void OnUpdatedEstimateAvailable() override; | 268 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, |
| 269 int32_t downstream_throughput_kbps, |
| 270 int32_t upstream_throughput_kbps) override; |
| 269 | 271 |
| 270 // Return a string equivalent to |type|. | 272 // Return a string equivalent to |type|. |
| 271 const char* GetNameForEffectiveConnectionType( | 273 const char* GetNameForEffectiveConnectionType( |
| 272 EffectiveConnectionType type) const; | 274 EffectiveConnectionType type) const; |
| 273 | 275 |
| 274 private: | 276 private: |
| 275 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); | 277 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| 276 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); | 278 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| 277 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); | 279 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ObtainOperatingParams); |
| 278 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); | 280 FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 308 | 310 |
| 309 // Minimum valid value of the variation parameter that holds throughput (in | 311 // Minimum valid value of the variation parameter that holds throughput (in |
| 310 // kilobits per second) values. | 312 // kilobits per second) values. |
| 311 static const int kMinimumThroughputVariationParameterKbps = 1; | 313 static const int kMinimumThroughputVariationParameterKbps = 1; |
| 312 | 314 |
| 313 // Maximum size of the cache that holds network quality estimates. | 315 // Maximum size of the cache that holds network quality estimates. |
| 314 // Smaller size may reduce the cache hit rate due to frequent evictions. | 316 // Smaller size may reduce the cache hit rate due to frequent evictions. |
| 315 // Larger size may affect performance. | 317 // Larger size may affect performance. |
| 316 static const size_t kMaximumNetworkQualityCacheSize = 10; | 318 static const size_t kMaximumNetworkQualityCacheSize = 10; |
| 317 | 319 |
| 318 // Time duration (in milliseconds) after which the estimate provided by | |
| 319 // external estimate provider is considered stale. | |
| 320 static const int kExternalEstimateProviderFreshnessDurationMsec = | |
| 321 5 * 60 * 1000; | |
| 322 | |
| 323 // Returns the RTT value to be used when the valid RTT is unavailable. Readers | 320 // Returns the RTT value to be used when the valid RTT is unavailable. Readers |
| 324 // should discard RTT if it is set to the value returned by |InvalidRTT()|. | 321 // should discard RTT if it is set to the value returned by |InvalidRTT()|. |
| 325 static const base::TimeDelta InvalidRTT(); | 322 static const base::TimeDelta InvalidRTT(); |
| 326 | 323 |
| 327 // Records UMA when there is a change in connection type. | 324 // Records UMA when there is a change in connection type. |
| 328 void RecordMetricsOnConnectionTypeChanged() const; | 325 void RecordMetricsOnConnectionTypeChanged() const; |
| 329 | 326 |
| 330 // Records a downstream throughput observation to the observation buffer if | 327 // Records a downstream throughput observation to the observation buffer if |
| 331 // a valid observation is available. |downstream_kbps| is the downstream | 328 // a valid observation is available. |downstream_kbps| is the downstream |
| 332 // throughput in kilobits per second. | 329 // throughput in kilobits per second. |
| 333 void OnNewThroughputObservationAvailable(int32_t downstream_kbps); | 330 void OnNewThroughputObservationAvailable(int32_t downstream_kbps); |
| 334 | 331 |
| 335 // Notifies |this| of a new transport layer RTT. | 332 // Notifies |this| of a new transport layer RTT. |
| 336 void OnUpdatedRTTAvailable(SocketPerformanceWatcherFactory::Protocol protocol, | 333 void OnUpdatedRTTAvailable(SocketPerformanceWatcherFactory::Protocol protocol, |
| 337 const base::TimeDelta& rtt); | 334 const base::TimeDelta& rtt); |
| 338 | 335 |
| 339 // Queries the external estimate provider for the latest network quality | |
| 340 // estimates, and adds those estimates to the current observation buffer. | |
| 341 void QueryExternalEstimateProvider(); | |
| 342 | |
| 343 // Obtains operating parameters from the field trial parameters. | 336 // Obtains operating parameters from the field trial parameters. |
| 344 void ObtainOperatingParams( | 337 void ObtainOperatingParams( |
| 345 const std::map<std::string, std::string>& variation_params); | 338 const std::map<std::string, std::string>& variation_params); |
| 346 | 339 |
| 347 // Obtains the model parameters for different effective connection types from | 340 // Obtains the model parameters for different effective connection types from |
| 348 // the field trial parameters. For each effective connection type, a model | 341 // the field trial parameters. For each effective connection type, a model |
| 349 // (currently composed of a RTT threshold and a downlink throughput threshold) | 342 // (currently composed of a RTT threshold and a downlink throughput threshold) |
| 350 // is provided by the field trial. | 343 // is provided by the field trial. |
| 351 void ObtainEffectiveConnectionTypeModelParams( | 344 void ObtainEffectiveConnectionTypeModelParams( |
| 352 const std::map<std::string, std::string>& variation_params); | 345 const std::map<std::string, std::string>& variation_params); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 base::ThreadChecker thread_checker_; | 473 base::ThreadChecker thread_checker_; |
| 481 | 474 |
| 482 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 475 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| 483 | 476 |
| 484 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 477 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| 485 }; | 478 }; |
| 486 | 479 |
| 487 } // namespace net | 480 } // namespace net |
| 488 | 481 |
| 489 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 482 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
| OLD | NEW |