| 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/optional.h" |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 #include "net/base/network_change_notifier.h" | 15 #include "net/base/network_change_notifier.h" |
| 16 #include "net/nqe/effective_connection_type.h" | 16 #include "net/nqe/effective_connection_type.h" |
| 17 #include "net/nqe/network_quality.h" | 17 #include "net/nqe/network_quality.h" |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 | 20 |
| 21 // Forces NQE to return a specific effective connection type. Set using the | 21 // Forces NQE to return a specific effective connection type. Set using the |
| 22 // |params| provided to the NetworkQualityEstimatorParams constructor. | 22 // |params| provided to the NetworkQualityEstimatorParams constructor. |
| 23 NET_EXPORT extern const char kForceEffectiveConnectionType[]; | 23 NET_EXPORT extern const char kForceEffectiveConnectionType[]; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // UMA. | 89 // UMA. |
| 90 double correlation_uma_logging_probability() const { | 90 double correlation_uma_logging_probability() const { |
| 91 return correlation_uma_logging_probability_; | 91 return correlation_uma_logging_probability_; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Returns an unset value if the effective connection type has not been forced | 94 // Returns an unset value if the effective connection type has not been forced |
| 95 // via the |params| provided to this class. Otherwise, returns a value set to | 95 // via the |params| provided to this class. Otherwise, returns a value set to |
| 96 // the effective connection type that has been forced. | 96 // the effective connection type that has been forced. |
| 97 base::Optional<EffectiveConnectionType> forced_effective_connection_type() | 97 base::Optional<EffectiveConnectionType> forced_effective_connection_type() |
| 98 const { | 98 const { |
| 99 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 99 return forced_effective_connection_type_; | 100 return forced_effective_connection_type_; |
| 100 } | 101 } |
| 101 | 102 |
| 103 void SetForcedEffectiveConnectionType( |
| 104 EffectiveConnectionType forced_effective_connection_type) { |
| 105 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 106 forced_effective_connection_type_ = forced_effective_connection_type; |
| 107 } |
| 108 |
| 102 // Returns true if reading from the persistent cache is enabled. | 109 // Returns true if reading from the persistent cache is enabled. |
| 103 bool persistent_cache_reading_enabled() const { | 110 bool persistent_cache_reading_enabled() const { |
| 111 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 104 return persistent_cache_reading_enabled_; | 112 return persistent_cache_reading_enabled_; |
| 105 } | 113 } |
| 106 | 114 |
| 115 void set_persistent_cache_reading_enabled( |
| 116 bool persistent_cache_reading_enabled) { |
| 117 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 118 persistent_cache_reading_enabled_ = persistent_cache_reading_enabled; |
| 119 } |
| 120 |
| 107 // Returns the the minimum interval betweeen consecutive notifications to a | 121 // Returns the the minimum interval betweeen consecutive notifications to a |
| 108 // single socket watcher. | 122 // single socket watcher. |
| 109 base::TimeDelta min_socket_watcher_notification_interval() const { | 123 base::TimeDelta min_socket_watcher_notification_interval() const { |
| 110 return min_socket_watcher_notification_interval_; | 124 return min_socket_watcher_notification_interval_; |
| 111 } | 125 } |
| 112 | 126 |
| 113 // Returns the algorithm that should be used for computing effective | 127 // Returns the algorithm that should be used for computing effective |
| 114 // connection type. Returns an empty string if a valid algorithm parameter is | 128 // connection type. Returns an empty string if a valid algorithm parameter is |
| 115 // not specified. | 129 // not specified. |
| 116 static EffectiveConnectionTypeAlgorithm | 130 static EffectiveConnectionTypeAlgorithm |
| 117 GetEffectiveConnectionTypeAlgorithmFromString( | 131 GetEffectiveConnectionTypeAlgorithmFromString( |
| 118 const std::string& algorithm_param_value); | 132 const std::string& algorithm_param_value); |
| 119 | 133 |
| 134 void SetEffectiveConnectionTypeAlgorithm( |
| 135 EffectiveConnectionTypeAlgorithm algorithm) { |
| 136 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 137 effective_connection_type_algorithm_ = algorithm; |
| 138 } |
| 139 |
| 120 private: | 140 private: |
| 121 // Map containing all field trial parameters related to | 141 // Map containing all field trial parameters related to |
| 122 // NetworkQualityEstimator field trial. | 142 // NetworkQualityEstimator field trial. |
| 123 const std::map<std::string, std::string> params_; | 143 const std::map<std::string, std::string> params_; |
| 124 | 144 |
| 125 const size_t throughput_min_requests_in_flight_; | 145 const size_t throughput_min_requests_in_flight_; |
| 126 const double weight_multiplier_per_second_; | 146 const double weight_multiplier_per_second_; |
| 127 const double weight_multiplier_per_signal_strength_level_; | 147 const double weight_multiplier_per_signal_strength_level_; |
| 128 const double correlation_uma_logging_probability_; | 148 const double correlation_uma_logging_probability_; |
| 129 const base::Optional<EffectiveConnectionType> | 149 base::Optional<EffectiveConnectionType> forced_effective_connection_type_; |
| 130 forced_effective_connection_type_; | 150 bool persistent_cache_reading_enabled_; |
| 131 const bool persistent_cache_reading_enabled_; | |
| 132 const base::TimeDelta min_socket_watcher_notification_interval_; | 151 const base::TimeDelta min_socket_watcher_notification_interval_; |
| 133 | 152 |
| 134 EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; | 153 EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; |
| 135 | 154 |
| 136 // Default network quality observations obtained from |params_|. | 155 // Default network quality observations obtained from |params_|. |
| 137 nqe::internal::NetworkQuality | 156 nqe::internal::NetworkQuality |
| 138 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; | 157 default_observations_[NetworkChangeNotifier::CONNECTION_LAST + 1]; |
| 139 | 158 |
| 140 // Typical network quality for different effective connection types obtained | 159 // Typical network quality for different effective connection types obtained |
| 141 // from |params_|. | 160 // from |params_|. |
| 142 nqe::internal::NetworkQuality typical_network_quality_ | 161 nqe::internal::NetworkQuality typical_network_quality_ |
| 143 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; | 162 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; |
| 144 | 163 |
| 145 // Thresholds for different effective connection types obtained from | 164 // Thresholds for different effective connection types obtained from |
| 146 // |params_|. These thresholds encode how different connection types behave | 165 // |params_|. These thresholds encode how different connection types behave |
| 147 // in general. | 166 // in general. |
| 148 nqe::internal::NetworkQuality connection_thresholds_ | 167 nqe::internal::NetworkQuality connection_thresholds_ |
| 149 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; | 168 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; |
| 150 | 169 |
| 151 base::ThreadChecker thread_checker_; | 170 SEQUENCE_CHECKER(sequence_checker_); |
| 152 | 171 |
| 153 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorParams); | 172 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorParams); |
| 154 }; | 173 }; |
| 155 | 174 |
| 156 } // namespace net | 175 } // namespace net |
| 157 | 176 |
| 158 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_PARAMS_H_ | 177 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_PARAMS_H_ |
| OLD | NEW |