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