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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // Adds |throughput_observer| to the list of throughput observers. Must be | 249 // Adds |throughput_observer| to the list of throughput observers. Must be |
250 // called on the IO thread. | 250 // called on the IO thread. |
251 void AddThroughputObserver(ThroughputObserver* throughput_observer); | 251 void AddThroughputObserver(ThroughputObserver* throughput_observer); |
252 | 252 |
253 // Removes |throughput_observer| from the list of throughput observers if it | 253 // Removes |throughput_observer| from the list of throughput observers if it |
254 // is on the list of observers. Must be called on the IO thread. | 254 // is on the list of observers. Must be called on the IO thread. |
255 void RemoveThroughputObserver(ThroughputObserver* throughput_observer); | 255 void RemoveThroughputObserver(ThroughputObserver* throughput_observer); |
256 | 256 |
257 SocketPerformanceWatcherFactory* GetSocketPerformanceWatcherFactory(); | 257 SocketPerformanceWatcherFactory* GetSocketPerformanceWatcherFactory(); |
258 | 258 |
| 259 // |use_local_host_requests_for_tests| should only be true when testing |
| 260 // against local HTTP server and allows the requests to local host to be |
| 261 // used for network quality estimation. |
| 262 void SetUseLocalHostRequestsForTesting( |
| 263 bool use_local_host_requests_for_tests); |
| 264 |
| 265 // |use_smaller_responses_for_tests| should only be true when testing. |
| 266 // Allows the responses smaller than |kMinTransferSizeInBits| to be used for |
| 267 // network quality estimation. |
| 268 void SetUseSmallResponsesForTesting(bool use_small_responses); |
| 269 |
259 protected: | 270 protected: |
260 // NetworkID is used to uniquely identify a network. | 271 // NetworkID is used to uniquely identify a network. |
261 // For the purpose of network quality estimation and caching, a network is | 272 // For the purpose of network quality estimation and caching, a network is |
262 // uniquely identified by a combination of |type| and | 273 // uniquely identified by a combination of |type| and |
263 // |id|. This approach is unable to distinguish networks with | 274 // |id|. This approach is unable to distinguish networks with |
264 // same name (e.g., different Wi-Fi networks with same SSID). | 275 // same name (e.g., different Wi-Fi networks with same SSID). |
265 // This is a protected member to expose it to tests. | 276 // This is a protected member to expose it to tests. |
266 struct NET_EXPORT_PRIVATE NetworkID { | 277 struct NET_EXPORT_PRIVATE NetworkID { |
267 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) | 278 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) |
268 : type(type), id(id) {} | 279 : type(type), id(id) {} |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE, | 463 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE, |
453 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY | 464 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY |
454 }; | 465 }; |
455 | 466 |
456 // Records the metrics related to external estimate provider. | 467 // Records the metrics related to external estimate provider. |
457 void RecordExternalEstimateProviderMetrics( | 468 void RecordExternalEstimateProviderMetrics( |
458 NQEExternalEstimateProviderStatus status) const; | 469 NQEExternalEstimateProviderStatus status) const; |
459 | 470 |
460 // Determines if the requests to local host can be used in estimating the | 471 // Determines if the requests to local host can be used in estimating the |
461 // network quality. Set to true only for tests. | 472 // network quality. Set to true only for tests. |
462 const bool use_localhost_requests_; | 473 bool use_localhost_requests_; |
463 | 474 |
464 // Determines if the responses smaller than |kMinTransferSizeInBytes| | 475 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
465 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the | 476 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
466 // network quality. Set to true only for tests. | 477 // network quality. Set to true only for tests. |
467 const bool use_small_responses_; | 478 bool use_small_responses_; |
468 | 479 |
469 // The factor by which the weight of an observation reduces every second. | 480 // The factor by which the weight of an observation reduces every second. |
470 const double weight_multiplier_per_second_; | 481 const double weight_multiplier_per_second_; |
471 | 482 |
472 // Tick clock used by the network quality estimator. | 483 // Tick clock used by the network quality estimator. |
473 std::unique_ptr<base::TickClock> tick_clock_; | 484 std::unique_ptr<base::TickClock> tick_clock_; |
474 | 485 |
475 // Minimum duration between two consecutive computations of effective | 486 // Minimum duration between two consecutive computations of effective |
476 // connection type. Set to non-zero value as a performance optimization. | 487 // connection type. Set to non-zero value as a performance optimization. |
477 const base::TimeDelta effective_connection_type_recomputation_interval_; | 488 const base::TimeDelta effective_connection_type_recomputation_interval_; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 base::ThreadChecker thread_checker_; | 559 base::ThreadChecker thread_checker_; |
549 | 560 |
550 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 561 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
551 | 562 |
552 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 563 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
553 }; | 564 }; |
554 | 565 |
555 } // namespace net | 566 } // namespace net |
556 | 567 |
557 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 568 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
OLD | NEW |