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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 SocketPerformanceWatcherFactory* GetSocketPerformanceWatcherFactory(); | 262 SocketPerformanceWatcherFactory* GetSocketPerformanceWatcherFactory(); |
263 | 263 |
264 // Returns a string equivalent to |type|. | 264 // Returns a string equivalent to |type|. |
265 static const char* GetNameForEffectiveConnectionType( | 265 static const char* GetNameForEffectiveConnectionType( |
266 EffectiveConnectionType type); | 266 EffectiveConnectionType type); |
267 | 267 |
268 // Returns an EffectiveConnectionType equivalent to |connection_type_name|. | 268 // Returns an EffectiveConnectionType equivalent to |connection_type_name|. |
269 static EffectiveConnectionType GetEffectiveConnectionTypeForName( | 269 static EffectiveConnectionType GetEffectiveConnectionTypeForName( |
270 const std::string& connection_type_name); | 270 const std::string& connection_type_name); |
271 | 271 |
| 272 // |use_localhost_requests| should only be true when testing against local |
| 273 // HTTP server and allows the requests to local host to be used for network |
| 274 // quality estimation. |
| 275 void SetUseLocalHostRequestsForTesting(bool use_localhost_requests); |
| 276 |
| 277 // |use_smaller_responses_for_tests| should only be true when testing. |
| 278 // Allows the responses smaller than |kMinTransferSizeInBits| to be used for |
| 279 // network quality estimation. |
| 280 void SetUseSmallResponsesForTesting(bool use_small_responses); |
| 281 |
272 protected: | 282 protected: |
273 // NetworkID is used to uniquely identify a network. | 283 // NetworkID is used to uniquely identify a network. |
274 // For the purpose of network quality estimation and caching, a network is | 284 // For the purpose of network quality estimation and caching, a network is |
275 // uniquely identified by a combination of |type| and | 285 // uniquely identified by a combination of |type| and |
276 // |id|. This approach is unable to distinguish networks with | 286 // |id|. This approach is unable to distinguish networks with |
277 // same name (e.g., different Wi-Fi networks with same SSID). | 287 // same name (e.g., different Wi-Fi networks with same SSID). |
278 // This is a protected member to expose it to tests. | 288 // This is a protected member to expose it to tests. |
279 struct NET_EXPORT_PRIVATE NetworkID { | 289 struct NET_EXPORT_PRIVATE NetworkID { |
280 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) | 290 NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) |
281 : type(type), id(id) {} | 291 : type(type), id(id) {} |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE, | 497 EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE, |
488 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY | 498 EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY |
489 }; | 499 }; |
490 | 500 |
491 // Records the metrics related to external estimate provider. | 501 // Records the metrics related to external estimate provider. |
492 void RecordExternalEstimateProviderMetrics( | 502 void RecordExternalEstimateProviderMetrics( |
493 NQEExternalEstimateProviderStatus status) const; | 503 NQEExternalEstimateProviderStatus status) const; |
494 | 504 |
495 // Determines if the requests to local host can be used in estimating the | 505 // Determines if the requests to local host can be used in estimating the |
496 // network quality. Set to true only for tests. | 506 // network quality. Set to true only for tests. |
497 const bool use_localhost_requests_; | 507 bool use_localhost_requests_; |
498 | 508 |
499 // Determines if the responses smaller than |kMinTransferSizeInBytes| | 509 // Determines if the responses smaller than |kMinTransferSizeInBytes| |
500 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the | 510 // or shorter than |kMinTransferSizeInBytes| can be used in estimating the |
501 // network quality. Set to true only for tests. | 511 // network quality. Set to true only for tests. |
502 const bool use_small_responses_; | 512 bool use_small_responses_; |
503 | 513 |
504 // The factor by which the weight of an observation reduces every second. | 514 // The factor by which the weight of an observation reduces every second. |
505 const double weight_multiplier_per_second_; | 515 const double weight_multiplier_per_second_; |
506 | 516 |
507 // Algorithm to use for computing effective connection type. The value is | 517 // Algorithm to use for computing effective connection type. The value is |
508 // obtained from field trial parameters. If the value from field trial | 518 // obtained from field trial parameters. If the value from field trial |
509 // parameters is unavailable, it is set to | 519 // parameters is unavailable, it is set to |
510 // kDefaultEffectiveConnectionTypeAlgorithm. | 520 // kDefaultEffectiveConnectionTypeAlgorithm. |
511 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; | 521 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; |
512 | 522 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 base::ThreadChecker thread_checker_; | 607 base::ThreadChecker thread_checker_; |
598 | 608 |
599 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 609 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
600 | 610 |
601 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 611 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
602 }; | 612 }; |
603 | 613 |
604 } // namespace net | 614 } // namespace net |
605 | 615 |
606 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 616 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
OLD | NEW |