| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PARAMS_H_ | 5 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_PARAMS_H_ |
| 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_PARAMS_H_ | 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_PARAMS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/optional.h" |
| 12 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 13 #include "net/base/network_change_notifier.h" | 14 #include "net/base/network_change_notifier.h" |
| 14 #include "net/nqe/effective_connection_type.h" | 15 #include "net/nqe/effective_connection_type.h" |
| 15 #include "net/nqe/network_quality.h" | 16 #include "net/nqe/network_quality.h" |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| 19 namespace nqe { | 20 namespace nqe { |
| 20 | 21 |
| 21 namespace internal { | 22 namespace internal { |
| 22 | 23 |
| 23 // NetworkQualityEstimatorParams computes the configuration parameters for | 24 // NetworkQualityEstimatorParams computes the configuration parameters for |
| 24 // the network quality estimator. | 25 // the network quality estimator. |
| 25 class NetworkQualityEstimatorParams { | 26 class NET_EXPORT_PRIVATE NetworkQualityEstimatorParams { |
| 26 public: | 27 public: |
| 27 // |params| is the map containing all field trial parameters related to | 28 // |params| is the map containing all field trial parameters related to |
| 28 // NetworkQualityEstimator field trial. | 29 // NetworkQualityEstimator field trial. |
| 29 explicit NetworkQualityEstimatorParams( | 30 explicit NetworkQualityEstimatorParams( |
| 30 const std::map<std::string, std::string>& params); | 31 const std::map<std::string, std::string>& params); |
| 31 | 32 |
| 32 ~NetworkQualityEstimatorParams(); | 33 ~NetworkQualityEstimatorParams(); |
| 33 | 34 |
| 34 // Returns the algorithm that should be used for computing effective | 35 // Returns the algorithm that should be used for computing effective |
| 35 // connection type. Returns an empty string if a valid algorithm paramter is | 36 // connection type. Returns an empty string if a valid algorithm paramter is |
| 36 // not specified. | 37 // not specified. |
| 37 std::string GetEffectiveConnectionTypeAlgorithm() const; | 38 std::string GetEffectiveConnectionTypeAlgorithm() const; |
| 38 | 39 |
| 39 // Computes and returns the weight multiplier per second, which represents the | |
| 40 // factor by which the weight of an observation reduces every second. | |
| 41 double GetWeightMultiplierPerSecond() const; | |
| 42 | |
| 43 // Returns the factor by which the weight of an observation reduces for every | |
| 44 // dBm difference between the current signal strength (in dBm), and the signal | |
| 45 // strength at the time when the observation was taken. | |
| 46 double GetWeightMultiplierPerDbm() const; | |
| 47 | |
| 48 // Returns a descriptive name corresponding to |connection_type|. | 40 // Returns a descriptive name corresponding to |connection_type|. |
| 49 static const char* GetNameForConnectionType( | 41 static const char* GetNameForConnectionType( |
| 50 net::NetworkChangeNotifier::ConnectionType connection_type); | 42 net::NetworkChangeNotifier::ConnectionType connection_type); |
| 51 | 43 |
| 52 // Sets the default observation for different connection types in | 44 // Sets the default observation for different connection types in |
| 53 // |default_observations|. The default observations are different for | 45 // |default_observations|. The default observations are different for |
| 54 // different connection types (e.g., 2G, 3G, 4G, WiFi). The default | 46 // different connection types (e.g., 2G, 3G, 4G, WiFi). The default |
| 55 // observations may be used to determine the network quality in absence of any | 47 // observations may be used to determine the network quality in absence of any |
| 56 // other information. | 48 // other information. |
| 57 void ObtainDefaultObservations( | 49 void ObtainDefaultObservations( |
| 58 nqe::internal::NetworkQuality default_observations[]) const; | 50 nqe::internal::NetworkQuality default_observations[]) const; |
| 59 | 51 |
| 60 // Sets |typical_network_quality| to typical network quality for different | 52 // Sets |typical_network_quality| to typical network quality for different |
| 61 // effective connection types. | 53 // effective connection types. |
| 62 void ObtainTypicalNetworkQuality( | 54 void ObtainTypicalNetworkQuality( |
| 63 NetworkQuality typical_network_quality[]) const; | 55 NetworkQuality typical_network_quality[]) const; |
| 64 | 56 |
| 65 // Sets the thresholds for different effective connection types in | 57 // Sets the thresholds for different effective connection types in |
| 66 // |connection_thresholds|. | 58 // |connection_thresholds|. |
| 67 void ObtainEffectiveConnectionTypeModelParams( | 59 void ObtainEffectiveConnectionTypeModelParams( |
| 68 nqe::internal::NetworkQuality connection_thresholds[]) const; | 60 nqe::internal::NetworkQuality connection_thresholds[]) const; |
| 69 | 61 |
| 62 // Returns the weight multiplier per second, which represents the factor by |
| 63 // which the weight of an observation reduces every second. |
| 64 double weight_multiplier_per_second() const { |
| 65 return weight_multiplier_per_second_; |
| 66 } |
| 67 |
| 68 // Returns the factor by which the weight of an observation reduces for every |
| 69 // dBm difference between the current signal strength (in dBm), and the signal |
| 70 // strength at the time when the observation was taken. |
| 71 double weight_multiplier_per_dbm() const { |
| 72 return weight_multiplier_per_dbm_; |
| 73 } |
| 74 |
| 70 // Returns the fraction of URL requests that should record the correlation | 75 // Returns the fraction of URL requests that should record the correlation |
| 71 // UMA. | 76 // UMA. |
| 72 double correlation_uma_logging_probability() const; | 77 double correlation_uma_logging_probability() const { |
| 78 return correlation_uma_logging_probability_; |
| 79 } |
| 73 | 80 |
| 74 // Returns true if the effective connection type has been forced via field | 81 // Returns an unset value if the effective connection type has not been forced |
| 75 // trial parameters. | 82 // via the |params| provided to this class. Otherwise, returns a value set to |
| 76 bool forced_effective_connection_type_set() const; | 83 // the effective connection type that has been forced. |
| 77 | 84 base::Optional<EffectiveConnectionType> forced_effective_connection_type() |
| 78 // Returns the effective connection type if it has been forced via field trial | 85 const { |
| 79 // parameters. | 86 return forced_effective_connection_type_; |
| 80 EffectiveConnectionType forced_effective_connection_type() const; | 87 } |
| 81 | 88 |
| 82 // Returns true if reading from the persistent cache is enabled. | 89 // Returns true if reading from the persistent cache is enabled. |
| 83 bool persistent_cache_reading_enabled() const; | 90 bool persistent_cache_reading_enabled() const { |
| 91 return persistent_cache_reading_enabled_; |
| 92 } |
| 84 | 93 |
| 85 // Returns the the minimum interval betweeen consecutive notifications to a | 94 // Returns the the minimum interval betweeen consecutive notifications to a |
| 86 // single socket watcher. | 95 // single socket watcher. |
| 87 base::TimeDelta GetMinSocketWatcherNotificationInterval() const; | 96 base::TimeDelta min_socket_watcher_notification_interval() const { |
| 97 return min_socket_watcher_notification_interval_; |
| 98 } |
| 88 | 99 |
| 89 private: | 100 private: |
| 90 // Map containing all field trial parameters related to | 101 // Map containing all field trial parameters related to |
| 91 // NetworkQualityEstimator field trial. | 102 // NetworkQualityEstimator field trial. |
| 92 const std::map<std::string, std::string> params_; | 103 const std::map<std::string, std::string> params_; |
| 93 | 104 |
| 105 const double weight_multiplier_per_second_; |
| 106 const double weight_multiplier_per_dbm_; |
| 107 const double correlation_uma_logging_probability_; |
| 108 const base::Optional<EffectiveConnectionType> |
| 109 forced_effective_connection_type_; |
| 110 const bool persistent_cache_reading_enabled_; |
| 111 const base::TimeDelta min_socket_watcher_notification_interval_; |
| 112 |
| 94 base::ThreadChecker thread_checker_; | 113 base::ThreadChecker thread_checker_; |
| 95 | 114 |
| 96 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorParams); | 115 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorParams); |
| 97 }; | 116 }; |
| 98 | 117 |
| 99 } // namespace internal | 118 } // namespace internal |
| 100 | 119 |
| 101 } // namespace nqe | 120 } // namespace nqe |
| 102 | 121 |
| 103 } // namespace net | 122 } // namespace net |
| 104 | 123 |
| 105 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_PARAMS_H_ | 124 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_PARAMS_H_ |
| OLD | NEW |