| 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 #include "net/nqe/network_quality_estimator_params.h" | 5 #include "net/nqe/network_quality_estimator_params.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Minimum valid value of the variation parameter that holds RTT (in | 14 // Minimum valid value of the variation parameter that holds RTT (in |
| 15 // milliseconds) values. | 15 // milliseconds) values. |
| 16 static const int kMinimumRTTVariationParameterMsec = 1; | 16 static const int kMinimumRTTVariationParameterMsec = 1; |
| 17 | 17 |
| 18 // Minimum valid value of the variation parameter that holds throughput (in | 18 // Minimum valid value of the variation parameter that holds throughput (in |
| 19 // kilobits per second) values. | 19 // kilobits per second) values. |
| 20 static const int kMinimumThroughputVariationParameterKbps = 1; | 20 static const int kMinimumThroughputVariationParameterKbps = 1; |
| 21 | 21 |
| 22 // Returns the value of |parameter_name| read from |variation_params|. If the | 22 // Returns the value of |parameter_name| read from |params|. If the |
| 23 // value is unavailable from |variation_params|, then |default_value| is | 23 // value is unavailable from |params|, then |default_value| is returned. |
| 24 // returned. | |
| 25 int64_t GetValueForVariationParam( | 24 int64_t GetValueForVariationParam( |
| 26 const std::map<std::string, std::string>& variation_params, | 25 const std::map<std::string, std::string>& params, |
| 27 const std::string& parameter_name, | 26 const std::string& parameter_name, |
| 28 int64_t default_value) { | 27 int64_t default_value) { |
| 29 const auto it = variation_params.find(parameter_name); | 28 const auto it = params.find(parameter_name); |
| 30 int64_t variations_value = default_value; | 29 int64_t variations_value = default_value; |
| 31 if (it != variation_params.end() && | 30 if (it != params.end() && |
| 32 base::StringToInt64(it->second, &variations_value)) { | 31 base::StringToInt64(it->second, &variations_value)) { |
| 33 return variations_value; | 32 return variations_value; |
| 34 } | 33 } |
| 35 return default_value; | 34 return default_value; |
| 36 } | 35 } |
| 37 | 36 |
| 38 // Returns the variation value for |parameter_name|. If the value is | 37 // Returns the variation value for |parameter_name|. If the value is |
| 39 // unavailable, |default_value| is returned. | 38 // unavailable, |default_value| is returned. |
| 40 double GetDoubleValueForVariationParamWithDefaultValue( | 39 double GetDoubleValueForVariationParamWithDefaultValue( |
| 41 const std::map<std::string, std::string>& variation_params, | 40 const std::map<std::string, std::string>& params, |
| 42 const std::string& parameter_name, | 41 const std::string& parameter_name, |
| 43 double default_value) { | 42 double default_value) { |
| 44 const auto it = variation_params.find(parameter_name); | 43 const auto it = params.find(parameter_name); |
| 45 if (it == variation_params.end()) | 44 if (it == params.end()) |
| 46 return default_value; | 45 return default_value; |
| 47 | 46 |
| 48 double variations_value = default_value; | 47 double variations_value = default_value; |
| 49 if (!base::StringToDouble(it->second, &variations_value)) | 48 if (!base::StringToDouble(it->second, &variations_value)) |
| 50 return default_value; | 49 return default_value; |
| 51 return variations_value; | 50 return variations_value; |
| 52 } | 51 } |
| 53 | 52 |
| 54 // Returns the variation value for |parameter_name|. If the value is | 53 // Returns the variation value for |parameter_name|. If the value is |
| 55 // unavailable, |default_value| is returned. | 54 // unavailable, |default_value| is returned. |
| 56 std::string GetStringValueForVariationParamWithDefaultValue( | 55 std::string GetStringValueForVariationParamWithDefaultValue( |
| 57 const std::map<std::string, std::string>& variation_params, | 56 const std::map<std::string, std::string>& params, |
| 58 const std::string& parameter_name, | 57 const std::string& parameter_name, |
| 59 const std::string& default_value) { | 58 const std::string& default_value) { |
| 60 const auto it = variation_params.find(parameter_name); | 59 const auto it = params.find(parameter_name); |
| 61 if (it == variation_params.end()) | 60 if (it == params.end()) |
| 62 return default_value; | 61 return default_value; |
| 63 return it->second; | 62 return it->second; |
| 64 } | 63 } |
| 65 | 64 |
| 66 } // namespace | 65 } // namespace |
| 67 | 66 |
| 68 namespace net { | 67 namespace net { |
| 69 | 68 |
| 70 namespace nqe { | 69 namespace nqe { |
| 71 | 70 |
| 72 namespace internal { | 71 namespace internal { |
| 73 | 72 |
| 74 std::string GetEffectiveConnectionTypeAlgorithm( | 73 NetworkQualityEstimatorParams::NetworkQualityEstimatorParams( |
| 75 const std::map<std::string, std::string>& variation_params) { | 74 const std::map<std::string, std::string>& params) |
| 76 const auto it = variation_params.find("effective_connection_type_algorithm"); | 75 : params_(params) {} |
| 77 if (it == variation_params.end()) | 76 |
| 77 NetworkQualityEstimatorParams::~NetworkQualityEstimatorParams() { |
| 78 DCHECK(thread_checker_.CalledOnValidThread()); |
| 79 } |
| 80 |
| 81 std::string NetworkQualityEstimatorParams::GetEffectiveConnectionTypeAlgorithm() |
| 82 const { |
| 83 DCHECK(thread_checker_.CalledOnValidThread()); |
| 84 |
| 85 const auto it = params_.find("effective_connection_type_algorithm"); |
| 86 if (it == params_.end()) |
| 78 return std::string(); | 87 return std::string(); |
| 79 return it->second; | 88 return it->second; |
| 80 } | 89 } |
| 81 | 90 |
| 82 double GetWeightMultiplierPerSecond( | 91 double NetworkQualityEstimatorParams::GetWeightMultiplierPerSecond() const { |
| 83 const std::map<std::string, std::string>& variation_params) { | 92 DCHECK(thread_checker_.CalledOnValidThread()); |
| 93 |
| 84 // Default value of the half life (in seconds) for computing time weighted | 94 // Default value of the half life (in seconds) for computing time weighted |
| 85 // percentiles. Every half life, the weight of all observations reduces by | 95 // percentiles. Every half life, the weight of all observations reduces by |
| 86 // half. Lowering the half life would reduce the weight of older values | 96 // half. Lowering the half life would reduce the weight of older values |
| 87 // faster. | 97 // faster. |
| 88 int half_life_seconds = 60; | 98 int half_life_seconds = 60; |
| 89 int32_t variations_value = 0; | 99 int32_t variations_value = 0; |
| 90 auto it = variation_params.find("HalfLifeSeconds"); | 100 auto it = params_.find("HalfLifeSeconds"); |
| 91 if (it != variation_params.end() && | 101 if (it != params_.end() && base::StringToInt(it->second, &variations_value) && |
| 92 base::StringToInt(it->second, &variations_value) && | |
| 93 variations_value >= 1) { | 102 variations_value >= 1) { |
| 94 half_life_seconds = variations_value; | 103 half_life_seconds = variations_value; |
| 95 } | 104 } |
| 96 DCHECK_GT(half_life_seconds, 0); | 105 DCHECK_GT(half_life_seconds, 0); |
| 97 return pow(0.5, 1.0 / half_life_seconds); | 106 return pow(0.5, 1.0 / half_life_seconds); |
| 98 } | 107 } |
| 99 | 108 |
| 100 double GetWeightMultiplierPerDbm( | 109 double NetworkQualityEstimatorParams::GetWeightMultiplierPerDbm() const { |
| 101 const std::map<std::string, std::string>& variation_params) { | 110 DCHECK(thread_checker_.CalledOnValidThread()); |
| 111 |
| 102 // The default weight is set to 1.0, so by default, RSSI has no effect on the | 112 // The default weight is set to 1.0, so by default, RSSI has no effect on the |
| 103 // observation's weight. | 113 // observation's weight. |
| 104 return GetDoubleValueForVariationParamWithDefaultValue( | 114 return GetDoubleValueForVariationParamWithDefaultValue( |
| 105 variation_params, "rssi_weight_per_dbm", 1.0); | 115 params_, "rssi_weight_per_dbm", 1.0); |
| 106 } | 116 } |
| 107 | 117 |
| 108 const char* GetNameForConnectionType( | 118 // static |
| 119 const char* NetworkQualityEstimatorParams::GetNameForConnectionType( |
| 109 net::NetworkChangeNotifier::ConnectionType connection_type) { | 120 net::NetworkChangeNotifier::ConnectionType connection_type) { |
| 110 switch (connection_type) { | 121 switch (connection_type) { |
| 111 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: | 122 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: |
| 112 return "Unknown"; | 123 return "Unknown"; |
| 113 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: | 124 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: |
| 114 return "Ethernet"; | 125 return "Ethernet"; |
| 115 case net::NetworkChangeNotifier::CONNECTION_WIFI: | 126 case net::NetworkChangeNotifier::CONNECTION_WIFI: |
| 116 return "WiFi"; | 127 return "WiFi"; |
| 117 case net::NetworkChangeNotifier::CONNECTION_2G: | 128 case net::NetworkChangeNotifier::CONNECTION_2G: |
| 118 return "2G"; | 129 return "2G"; |
| 119 case net::NetworkChangeNotifier::CONNECTION_3G: | 130 case net::NetworkChangeNotifier::CONNECTION_3G: |
| 120 return "3G"; | 131 return "3G"; |
| 121 case net::NetworkChangeNotifier::CONNECTION_4G: | 132 case net::NetworkChangeNotifier::CONNECTION_4G: |
| 122 return "4G"; | 133 return "4G"; |
| 123 case net::NetworkChangeNotifier::CONNECTION_NONE: | 134 case net::NetworkChangeNotifier::CONNECTION_NONE: |
| 124 return "None"; | 135 return "None"; |
| 125 case net::NetworkChangeNotifier::CONNECTION_BLUETOOTH: | 136 case net::NetworkChangeNotifier::CONNECTION_BLUETOOTH: |
| 126 return "Bluetooth"; | 137 return "Bluetooth"; |
| 127 default: | 138 default: |
| 128 NOTREACHED(); | 139 NOTREACHED(); |
| 129 break; | 140 break; |
| 130 } | 141 } |
| 131 return ""; | 142 return ""; |
| 132 } | 143 } |
| 133 | 144 |
| 134 void ObtainDefaultObservations( | 145 void NetworkQualityEstimatorParams::ObtainDefaultObservations( |
| 135 const std::map<std::string, std::string>& variation_params, | 146 NetworkQuality default_observations[]) const { |
| 136 NetworkQuality default_observations[]) { | 147 DCHECK(thread_checker_.CalledOnValidThread()); |
| 148 |
| 137 for (size_t i = 0; i < NetworkChangeNotifier::CONNECTION_LAST; ++i) { | 149 for (size_t i = 0; i < NetworkChangeNotifier::CONNECTION_LAST; ++i) { |
| 138 DCHECK_EQ(InvalidRTT(), default_observations[i].http_rtt()); | 150 DCHECK_EQ(InvalidRTT(), default_observations[i].http_rtt()); |
| 139 DCHECK_EQ(InvalidRTT(), default_observations[i].transport_rtt()); | 151 DCHECK_EQ(InvalidRTT(), default_observations[i].transport_rtt()); |
| 140 DCHECK_EQ(kInvalidThroughput, | 152 DCHECK_EQ(kInvalidThroughput, |
| 141 default_observations[i].downstream_throughput_kbps()); | 153 default_observations[i].downstream_throughput_kbps()); |
| 142 } | 154 } |
| 143 | 155 |
| 144 // Default observations for HTTP RTT, transport RTT, and downstream throughput | 156 // Default observations for HTTP RTT, transport RTT, and downstream throughput |
| 145 // Kbps for the various connection types. These may be overridden by | 157 // Kbps for the various connection types. These may be overridden by |
| 146 // variations params. The default observation for a connection type | 158 // variations params. The default observation for a connection type |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 base::TimeDelta::FromMilliseconds(318), 476); | 190 base::TimeDelta::FromMilliseconds(318), 476); |
| 179 | 191 |
| 180 // Override using the values provided via variation params. | 192 // Override using the values provided via variation params. |
| 181 for (size_t i = 0; i <= NetworkChangeNotifier::CONNECTION_LAST; ++i) { | 193 for (size_t i = 0; i <= NetworkChangeNotifier::CONNECTION_LAST; ++i) { |
| 182 NetworkChangeNotifier::ConnectionType type = | 194 NetworkChangeNotifier::ConnectionType type = |
| 183 static_cast<NetworkChangeNotifier::ConnectionType>(i); | 195 static_cast<NetworkChangeNotifier::ConnectionType>(i); |
| 184 | 196 |
| 185 int32_t variations_value = kMinimumRTTVariationParameterMsec - 1; | 197 int32_t variations_value = kMinimumRTTVariationParameterMsec - 1; |
| 186 std::string parameter_name = std::string(GetNameForConnectionType(type)) | 198 std::string parameter_name = std::string(GetNameForConnectionType(type)) |
| 187 .append(".DefaultMedianRTTMsec"); | 199 .append(".DefaultMedianRTTMsec"); |
| 188 auto it = variation_params.find(parameter_name); | 200 auto it = params_.find(parameter_name); |
| 189 if (it != variation_params.end() && | 201 if (it != params_.end() && |
| 190 base::StringToInt(it->second, &variations_value) && | 202 base::StringToInt(it->second, &variations_value) && |
| 191 variations_value >= kMinimumRTTVariationParameterMsec) { | 203 variations_value >= kMinimumRTTVariationParameterMsec) { |
| 192 default_observations[i] = | 204 default_observations[i] = |
| 193 NetworkQuality(base::TimeDelta::FromMilliseconds(variations_value), | 205 NetworkQuality(base::TimeDelta::FromMilliseconds(variations_value), |
| 194 default_observations[i].transport_rtt(), | 206 default_observations[i].transport_rtt(), |
| 195 default_observations[i].downstream_throughput_kbps()); | 207 default_observations[i].downstream_throughput_kbps()); |
| 196 } | 208 } |
| 197 | 209 |
| 198 variations_value = kMinimumRTTVariationParameterMsec - 1; | 210 variations_value = kMinimumRTTVariationParameterMsec - 1; |
| 199 parameter_name = std::string(GetNameForConnectionType(type)) | 211 parameter_name = std::string(GetNameForConnectionType(type)) |
| 200 .append(".DefaultMedianTransportRTTMsec"); | 212 .append(".DefaultMedianTransportRTTMsec"); |
| 201 it = variation_params.find(parameter_name); | 213 it = params_.find(parameter_name); |
| 202 if (it != variation_params.end() && | 214 if (it != params_.end() && |
| 203 base::StringToInt(it->second, &variations_value) && | 215 base::StringToInt(it->second, &variations_value) && |
| 204 variations_value >= kMinimumRTTVariationParameterMsec) { | 216 variations_value >= kMinimumRTTVariationParameterMsec) { |
| 205 default_observations[i] = | 217 default_observations[i] = |
| 206 NetworkQuality(default_observations[i].http_rtt(), | 218 NetworkQuality(default_observations[i].http_rtt(), |
| 207 base::TimeDelta::FromMilliseconds(variations_value), | 219 base::TimeDelta::FromMilliseconds(variations_value), |
| 208 default_observations[i].downstream_throughput_kbps()); | 220 default_observations[i].downstream_throughput_kbps()); |
| 209 } | 221 } |
| 210 | 222 |
| 211 variations_value = kMinimumThroughputVariationParameterKbps - 1; | 223 variations_value = kMinimumThroughputVariationParameterKbps - 1; |
| 212 parameter_name = std::string(GetNameForConnectionType(type)) | 224 parameter_name = std::string(GetNameForConnectionType(type)) |
| 213 .append(".DefaultMedianKbps"); | 225 .append(".DefaultMedianKbps"); |
| 214 it = variation_params.find(parameter_name); | 226 it = params_.find(parameter_name); |
| 215 | 227 |
| 216 if (it != variation_params.end() && | 228 if (it != params_.end() && |
| 217 base::StringToInt(it->second, &variations_value) && | 229 base::StringToInt(it->second, &variations_value) && |
| 218 variations_value >= kMinimumThroughputVariationParameterKbps) { | 230 variations_value >= kMinimumThroughputVariationParameterKbps) { |
| 219 default_observations[i] = NetworkQuality( | 231 default_observations[i] = NetworkQuality( |
| 220 default_observations[i].http_rtt(), | 232 default_observations[i].http_rtt(), |
| 221 default_observations[i].transport_rtt(), variations_value); | 233 default_observations[i].transport_rtt(), variations_value); |
| 222 } | 234 } |
| 223 } | 235 } |
| 224 } | 236 } |
| 225 | 237 |
| 226 void ObtainTypicalNetworkQuality(NetworkQuality typical_network_quality[]) { | 238 void NetworkQualityEstimatorParams::ObtainTypicalNetworkQuality( |
| 239 NetworkQuality typical_network_quality[]) const { |
| 240 DCHECK(thread_checker_.CalledOnValidThread()); |
| 241 |
| 227 for (size_t i = 0; i < EFFECTIVE_CONNECTION_TYPE_LAST; ++i) { | 242 for (size_t i = 0; i < EFFECTIVE_CONNECTION_TYPE_LAST; ++i) { |
| 228 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].http_rtt()); | 243 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].http_rtt()); |
| 229 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].transport_rtt()); | 244 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].transport_rtt()); |
| 230 DCHECK_EQ(kInvalidThroughput, | 245 DCHECK_EQ(kInvalidThroughput, |
| 231 typical_network_quality[i].downstream_throughput_kbps()); | 246 typical_network_quality[i].downstream_throughput_kbps()); |
| 232 } | 247 } |
| 233 | 248 |
| 234 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality( | 249 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality( |
| 235 // Set to the 77.5th percentile of 2G RTT observations on Android. This | 250 // Set to the 77.5th percentile of 2G RTT observations on Android. This |
| 236 // corresponds to the median RTT observation when effective connection | 251 // corresponds to the median RTT observation when effective connection |
| (...skipping 18 matching lines...) Expand all Loading... |
| 255 // Set to the 25th percentile of 3G RTT observations on Android. | 270 // Set to the 25th percentile of 3G RTT observations on Android. |
| 256 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_4G] = | 271 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_4G] = |
| 257 NetworkQuality(base::TimeDelta::FromMilliseconds(175), | 272 NetworkQuality(base::TimeDelta::FromMilliseconds(175), |
| 258 base::TimeDelta::FromMilliseconds(125), 1600); | 273 base::TimeDelta::FromMilliseconds(125), 1600); |
| 259 | 274 |
| 260 static_assert( | 275 static_assert( |
| 261 EFFECTIVE_CONNECTION_TYPE_4G + 1 == EFFECTIVE_CONNECTION_TYPE_LAST, | 276 EFFECTIVE_CONNECTION_TYPE_4G + 1 == EFFECTIVE_CONNECTION_TYPE_LAST, |
| 262 "Missing effective connection type"); | 277 "Missing effective connection type"); |
| 263 } | 278 } |
| 264 | 279 |
| 265 void ObtainEffectiveConnectionTypeModelParams( | 280 void NetworkQualityEstimatorParams::ObtainEffectiveConnectionTypeModelParams( |
| 266 const std::map<std::string, std::string>& variation_params, | 281 NetworkQuality connection_thresholds[]) const { |
| 267 NetworkQuality connection_thresholds[]) { | 282 DCHECK(thread_checker_.CalledOnValidThread()); |
| 283 |
| 268 // First set the default thresholds. | 284 // First set the default thresholds. |
| 269 NetworkQuality default_effective_connection_type_thresholds | 285 NetworkQuality default_effective_connection_type_thresholds |
| 270 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; | 286 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; |
| 271 | 287 |
| 272 default_effective_connection_type_thresholds | 288 default_effective_connection_type_thresholds |
| 273 [EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality( | 289 [EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality( |
| 274 // Set to the 66th percentile of 2G RTT observations on Android. | 290 // Set to the 66th percentile of 2G RTT observations on Android. |
| 275 base::TimeDelta::FromMilliseconds(2010), | 291 base::TimeDelta::FromMilliseconds(2010), |
| 276 base::TimeDelta::FromMilliseconds(1870), kInvalidThroughput); | 292 base::TimeDelta::FromMilliseconds(1870), kInvalidThroughput); |
| 277 | 293 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 303 DCHECK_EQ(kInvalidThroughput, | 319 DCHECK_EQ(kInvalidThroughput, |
| 304 connection_thresholds[i].downstream_throughput_kbps()); | 320 connection_thresholds[i].downstream_throughput_kbps()); |
| 305 if (effective_connection_type == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) | 321 if (effective_connection_type == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) |
| 306 continue; | 322 continue; |
| 307 | 323 |
| 308 std::string connection_type_name = std::string( | 324 std::string connection_type_name = std::string( |
| 309 DeprecatedGetNameForEffectiveConnectionType(effective_connection_type)); | 325 DeprecatedGetNameForEffectiveConnectionType(effective_connection_type)); |
| 310 | 326 |
| 311 connection_thresholds[i].set_http_rtt( | 327 connection_thresholds[i].set_http_rtt( |
| 312 base::TimeDelta::FromMilliseconds(GetValueForVariationParam( | 328 base::TimeDelta::FromMilliseconds(GetValueForVariationParam( |
| 313 variation_params, | 329 params_, connection_type_name + ".ThresholdMedianHttpRTTMsec", |
| 314 connection_type_name + ".ThresholdMedianHttpRTTMsec", | |
| 315 default_effective_connection_type_thresholds[i] | 330 default_effective_connection_type_thresholds[i] |
| 316 .http_rtt() | 331 .http_rtt() |
| 317 .InMilliseconds()))); | 332 .InMilliseconds()))); |
| 318 | 333 |
| 319 connection_thresholds[i].set_transport_rtt( | 334 connection_thresholds[i].set_transport_rtt( |
| 320 base::TimeDelta::FromMilliseconds(GetValueForVariationParam( | 335 base::TimeDelta::FromMilliseconds(GetValueForVariationParam( |
| 321 variation_params, | 336 params_, connection_type_name + ".ThresholdMedianTransportRTTMsec", |
| 322 connection_type_name + ".ThresholdMedianTransportRTTMsec", | |
| 323 default_effective_connection_type_thresholds[i] | 337 default_effective_connection_type_thresholds[i] |
| 324 .transport_rtt() | 338 .transport_rtt() |
| 325 .InMilliseconds()))); | 339 .InMilliseconds()))); |
| 326 | 340 |
| 327 connection_thresholds[i].set_downstream_throughput_kbps( | 341 connection_thresholds[i].set_downstream_throughput_kbps( |
| 328 GetValueForVariationParam( | 342 GetValueForVariationParam( |
| 329 variation_params, connection_type_name + ".ThresholdMedianKbps", | 343 params_, connection_type_name + ".ThresholdMedianKbps", |
| 330 default_effective_connection_type_thresholds[i] | 344 default_effective_connection_type_thresholds[i] |
| 331 .downstream_throughput_kbps())); | 345 .downstream_throughput_kbps())); |
| 332 DCHECK(i == 0 || | 346 DCHECK(i == 0 || |
| 333 connection_thresholds[i].IsFaster(connection_thresholds[i - 1])); | 347 connection_thresholds[i].IsFaster(connection_thresholds[i - 1])); |
| 334 } | 348 } |
| 335 } | 349 } |
| 336 | 350 |
| 337 double correlation_uma_logging_probability( | 351 double NetworkQualityEstimatorParams::correlation_uma_logging_probability() |
| 338 const std::map<std::string, std::string>& variation_params) { | 352 const { |
| 353 DCHECK(thread_checker_.CalledOnValidThread()); |
| 354 |
| 339 double correlation_uma_logging_probability = | 355 double correlation_uma_logging_probability = |
| 340 GetDoubleValueForVariationParamWithDefaultValue( | 356 GetDoubleValueForVariationParamWithDefaultValue( |
| 341 variation_params, "correlation_logging_probability", 0.01); | 357 params_, "correlation_logging_probability", 0.01); |
| 342 DCHECK_LE(0.0, correlation_uma_logging_probability); | 358 DCHECK_LE(0.0, correlation_uma_logging_probability); |
| 343 DCHECK_GE(1.0, correlation_uma_logging_probability); | 359 DCHECK_GE(1.0, correlation_uma_logging_probability); |
| 344 return correlation_uma_logging_probability; | 360 return correlation_uma_logging_probability; |
| 345 } | 361 } |
| 346 | 362 |
| 347 bool forced_effective_connection_type_set( | 363 bool NetworkQualityEstimatorParams::forced_effective_connection_type_set() |
| 348 const std::map<std::string, std::string>& variation_params) { | 364 const { |
| 349 return !GetStringValueForVariationParamWithDefaultValue( | 365 return !GetStringValueForVariationParamWithDefaultValue( |
| 350 variation_params, "force_effective_connection_type", "") | 366 params_, "force_effective_connection_type", "") |
| 351 .empty(); | 367 .empty(); |
| 352 } | 368 } |
| 353 | 369 |
| 354 EffectiveConnectionType forced_effective_connection_type( | 370 EffectiveConnectionType |
| 355 const std::map<std::string, std::string>& variation_params) { | 371 NetworkQualityEstimatorParams::forced_effective_connection_type() const { |
| 356 EffectiveConnectionType forced_effective_connection_type = | 372 EffectiveConnectionType forced_effective_connection_type = |
| 357 EFFECTIVE_CONNECTION_TYPE_UNKNOWN; | 373 EFFECTIVE_CONNECTION_TYPE_UNKNOWN; |
| 358 std::string forced_value = GetStringValueForVariationParamWithDefaultValue( | 374 std::string forced_value = GetStringValueForVariationParamWithDefaultValue( |
| 359 variation_params, "force_effective_connection_type", | 375 params_, "force_effective_connection_type", |
| 360 GetNameForEffectiveConnectionType(EFFECTIVE_CONNECTION_TYPE_UNKNOWN)); | 376 GetNameForEffectiveConnectionType(EFFECTIVE_CONNECTION_TYPE_UNKNOWN)); |
| 361 DCHECK(!forced_value.empty()); | 377 DCHECK(!forced_value.empty()); |
| 362 bool effective_connection_type_available = GetEffectiveConnectionTypeForName( | 378 bool effective_connection_type_available = GetEffectiveConnectionTypeForName( |
| 363 forced_value, &forced_effective_connection_type); | 379 forced_value, &forced_effective_connection_type); |
| 364 DCHECK(effective_connection_type_available); | 380 DCHECK(effective_connection_type_available); |
| 365 | 381 |
| 366 // Silence unused variable warning in release builds. | 382 // Silence unused variable warning in release builds. |
| 367 (void)effective_connection_type_available; | 383 (void)effective_connection_type_available; |
| 368 | 384 |
| 369 return forced_effective_connection_type; | 385 return forced_effective_connection_type; |
| 370 } | 386 } |
| 371 | 387 |
| 372 bool persistent_cache_reading_enabled( | 388 bool NetworkQualityEstimatorParams::persistent_cache_reading_enabled() const { |
| 373 const std::map<std::string, std::string>& variation_params) { | 389 DCHECK(thread_checker_.CalledOnValidThread()); |
| 390 |
| 374 if (GetStringValueForVariationParamWithDefaultValue( | 391 if (GetStringValueForVariationParamWithDefaultValue( |
| 375 variation_params, "persistent_cache_reading_enabled", "false") != | 392 params_, "persistent_cache_reading_enabled", "false") != "true") { |
| 376 "true") { | |
| 377 return false; | 393 return false; |
| 378 } | 394 } |
| 379 return true; | 395 return true; |
| 380 } | 396 } |
| 381 | 397 |
| 382 base::TimeDelta GetMinSocketWatcherNotificationInterval( | 398 base::TimeDelta |
| 383 const std::map<std::string, std::string>& variation_params) { | 399 NetworkQualityEstimatorParams::GetMinSocketWatcherNotificationInterval() const { |
| 400 DCHECK(thread_checker_.CalledOnValidThread()); |
| 401 |
| 384 // Use 1000 milliseconds as the default value. | 402 // Use 1000 milliseconds as the default value. |
| 385 return base::TimeDelta::FromMilliseconds(GetValueForVariationParam( | 403 return base::TimeDelta::FromMilliseconds(GetValueForVariationParam( |
| 386 variation_params, "min_socket_watcher_notification_interval_msec", 1000)); | 404 params_, "min_socket_watcher_notification_interval_msec", 1000)); |
| 387 } | 405 } |
| 388 | 406 |
| 389 } // namespace internal | 407 } // namespace internal |
| 390 | 408 |
| 391 } // namespace nqe | 409 } // namespace nqe |
| 392 | 410 |
| 393 } // namespace net | 411 } // namespace net |
| OLD | NEW |