Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: net/nqe/network_quality_estimator_params.cc

Issue 2875073004: Move more variables to NQE params class (Closed)
Patch Set: ryansturm comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 net {
13
14 const char kForceEffectiveConnectionType[] = "force_effective_connection_type";
15
16 namespace nqe {
17
18 namespace internal {
19
12 namespace { 20 namespace {
13 21
14 // Minimum valid value of the variation parameter that holds RTT (in 22 // Minimum valid value of the variation parameter that holds RTT (in
15 // milliseconds) values. 23 // milliseconds) values.
16 static const int kMinimumRTTVariationParameterMsec = 1; 24 static const int kMinimumRTTVariationParameterMsec = 1;
17 25
18 // Minimum valid value of the variation parameter that holds throughput (in 26 // Minimum valid value of the variation parameter that holds throughput (in
19 // kilobits per second) values. 27 // kilobits per second) values.
20 static const int kMinimumThroughputVariationParameterKbps = 1; 28 static const int kMinimumThroughputVariationParameterKbps = 1;
21 29
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return true; 96 return true;
89 } 97 }
90 98
91 base::TimeDelta GetMinSocketWatcherNotificationInterval( 99 base::TimeDelta GetMinSocketWatcherNotificationInterval(
92 const std::map<std::string, std::string>& params) { 100 const std::map<std::string, std::string>& params) {
93 // Use 1000 milliseconds as the default value. 101 // Use 1000 milliseconds as the default value.
94 return base::TimeDelta::FromMilliseconds(GetValueForVariationParam( 102 return base::TimeDelta::FromMilliseconds(GetValueForVariationParam(
95 params, "min_socket_watcher_notification_interval_msec", 1000)); 103 params, "min_socket_watcher_notification_interval_msec", 1000));
96 } 104 }
97 105
98 } // namespace
99
100 namespace net {
101
102 const char kForceEffectiveConnectionType[] = "force_effective_connection_type";
103
104 namespace {
105
106 base::Optional<EffectiveConnectionType> GetForcedEffectiveConnectionType(
107 const std::map<std::string, std::string>& params) {
108 std::string forced_value = GetStringValueForVariationParamWithDefaultValue(
109 params, kForceEffectiveConnectionType, "");
110 if (forced_value.empty())
111 return base::Optional<EffectiveConnectionType>();
112
113 EffectiveConnectionType forced_effective_connection_type =
114 EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
115
116 bool effective_connection_type_available = GetEffectiveConnectionTypeForName(
117 forced_value, &forced_effective_connection_type);
118
119 DCHECK(effective_connection_type_available);
120
121 // Silence unused variable warning in release builds.
122 (void)effective_connection_type_available;
123
124 return forced_effective_connection_type;
125 }
126
127 } // namespace
128
129 namespace nqe {
130
131 namespace internal {
132
133 NetworkQualityEstimatorParams::NetworkQualityEstimatorParams(
134 const std::map<std::string, std::string>& params)
135 : params_(params),
136 weight_multiplier_per_second_(GetWeightMultiplierPerSecond(params_)),
137 weight_multiplier_per_dbm_(
138 GetDoubleValueForVariationParamWithDefaultValue(params_,
139 "rssi_weight_per_dbm",
140 1.0)),
141 correlation_uma_logging_probability_(
142 GetDoubleValueForVariationParamWithDefaultValue(
143 params_,
144 "correlation_logging_probability",
145 0.01)),
146 forced_effective_connection_type_(
147 GetForcedEffectiveConnectionType(params_)),
148 persistent_cache_reading_enabled_(
149 GetPersistentCacheReadingEnabled(params_)),
150 min_socket_watcher_notification_interval_(
151 GetMinSocketWatcherNotificationInterval(params_)) {
152 DCHECK_LE(0.0, correlation_uma_logging_probability_);
153 DCHECK_GE(1.0, correlation_uma_logging_probability_);
154 }
155
156 NetworkQualityEstimatorParams::~NetworkQualityEstimatorParams() {
157 DCHECK(thread_checker_.CalledOnValidThread());
158 }
159
160 std::string NetworkQualityEstimatorParams::GetEffectiveConnectionTypeAlgorithm()
161 const {
162 DCHECK(thread_checker_.CalledOnValidThread());
163
164 const auto it = params_.find("effective_connection_type_algorithm");
165 if (it == params_.end())
166 return std::string();
167 return it->second;
168 }
169
170 // static 106 // static
171 const char* NetworkQualityEstimatorParams::GetNameForConnectionType( 107 const char* GetNameForConnectionTypeInternal(
172 net::NetworkChangeNotifier::ConnectionType connection_type) { 108 NetworkChangeNotifier::ConnectionType connection_type) {
173 switch (connection_type) { 109 switch (connection_type) {
174 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: 110 case NetworkChangeNotifier::CONNECTION_UNKNOWN:
175 return "Unknown"; 111 return "Unknown";
176 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: 112 case NetworkChangeNotifier::CONNECTION_ETHERNET:
177 return "Ethernet"; 113 return "Ethernet";
178 case net::NetworkChangeNotifier::CONNECTION_WIFI: 114 case NetworkChangeNotifier::CONNECTION_WIFI:
179 return "WiFi"; 115 return "WiFi";
180 case net::NetworkChangeNotifier::CONNECTION_2G: 116 case NetworkChangeNotifier::CONNECTION_2G:
181 return "2G"; 117 return "2G";
182 case net::NetworkChangeNotifier::CONNECTION_3G: 118 case NetworkChangeNotifier::CONNECTION_3G:
183 return "3G"; 119 return "3G";
184 case net::NetworkChangeNotifier::CONNECTION_4G: 120 case NetworkChangeNotifier::CONNECTION_4G:
185 return "4G"; 121 return "4G";
186 case net::NetworkChangeNotifier::CONNECTION_NONE: 122 case NetworkChangeNotifier::CONNECTION_NONE:
187 return "None"; 123 return "None";
188 case net::NetworkChangeNotifier::CONNECTION_BLUETOOTH: 124 case NetworkChangeNotifier::CONNECTION_BLUETOOTH:
189 return "Bluetooth"; 125 return "Bluetooth";
190 default: 126 default:
191 NOTREACHED(); 127 NOTREACHED();
192 break; 128 break;
193 } 129 }
194 return ""; 130 return "";
195 } 131 }
196 132
197 void NetworkQualityEstimatorParams::ObtainDefaultObservations( 133 // Sets the default observation for different connection types in
198 NetworkQuality default_observations[]) const { 134 // |default_observations|. The default observations are different for
199 DCHECK(thread_checker_.CalledOnValidThread()); 135 // different connection types (e.g., 2G, 3G, 4G, WiFi). The default
200 136 // observations may be used to determine the network quality in absence of any
137 // other information.
138 void ObtainDefaultObservations(const std::map<std::string, std::string>& params,
139 NetworkQuality default_observations[]) {
201 for (size_t i = 0; i < NetworkChangeNotifier::CONNECTION_LAST; ++i) { 140 for (size_t i = 0; i < NetworkChangeNotifier::CONNECTION_LAST; ++i) {
202 DCHECK_EQ(InvalidRTT(), default_observations[i].http_rtt()); 141 DCHECK_EQ(InvalidRTT(), default_observations[i].http_rtt());
203 DCHECK_EQ(InvalidRTT(), default_observations[i].transport_rtt()); 142 DCHECK_EQ(InvalidRTT(), default_observations[i].transport_rtt());
204 DCHECK_EQ(kInvalidThroughput, 143 DCHECK_EQ(kInvalidThroughput,
205 default_observations[i].downstream_throughput_kbps()); 144 default_observations[i].downstream_throughput_kbps());
206 } 145 }
207 146
208 // Default observations for HTTP RTT, transport RTT, and downstream throughput 147 // Default observations for HTTP RTT, transport RTT, and downstream throughput
209 // Kbps for the various connection types. These may be overridden by 148 // Kbps for the various connection types. These may be overridden by
210 // variations params. The default observation for a connection type 149 // variations params. The default observation for a connection type
(...skipping 29 matching lines...) Expand all
240 default_observations[NetworkChangeNotifier::CONNECTION_BLUETOOTH] = 179 default_observations[NetworkChangeNotifier::CONNECTION_BLUETOOTH] =
241 NetworkQuality(base::TimeDelta::FromMilliseconds(385), 180 NetworkQuality(base::TimeDelta::FromMilliseconds(385),
242 base::TimeDelta::FromMilliseconds(318), 476); 181 base::TimeDelta::FromMilliseconds(318), 476);
243 182
244 // Override using the values provided via variation params. 183 // Override using the values provided via variation params.
245 for (size_t i = 0; i <= NetworkChangeNotifier::CONNECTION_LAST; ++i) { 184 for (size_t i = 0; i <= NetworkChangeNotifier::CONNECTION_LAST; ++i) {
246 NetworkChangeNotifier::ConnectionType type = 185 NetworkChangeNotifier::ConnectionType type =
247 static_cast<NetworkChangeNotifier::ConnectionType>(i); 186 static_cast<NetworkChangeNotifier::ConnectionType>(i);
248 187
249 int32_t variations_value = kMinimumRTTVariationParameterMsec - 1; 188 int32_t variations_value = kMinimumRTTVariationParameterMsec - 1;
250 std::string parameter_name = std::string(GetNameForConnectionType(type)) 189 std::string parameter_name =
251 .append(".DefaultMedianRTTMsec"); 190 std::string(GetNameForConnectionTypeInternal(type))
252 auto it = params_.find(parameter_name); 191 .append(".DefaultMedianRTTMsec");
253 if (it != params_.end() && 192 auto it = params.find(parameter_name);
193 if (it != params.end() &&
254 base::StringToInt(it->second, &variations_value) && 194 base::StringToInt(it->second, &variations_value) &&
255 variations_value >= kMinimumRTTVariationParameterMsec) { 195 variations_value >= kMinimumRTTVariationParameterMsec) {
256 default_observations[i] = 196 default_observations[i] =
257 NetworkQuality(base::TimeDelta::FromMilliseconds(variations_value), 197 NetworkQuality(base::TimeDelta::FromMilliseconds(variations_value),
258 default_observations[i].transport_rtt(), 198 default_observations[i].transport_rtt(),
259 default_observations[i].downstream_throughput_kbps()); 199 default_observations[i].downstream_throughput_kbps());
260 } 200 }
261 201
262 variations_value = kMinimumRTTVariationParameterMsec - 1; 202 variations_value = kMinimumRTTVariationParameterMsec - 1;
263 parameter_name = std::string(GetNameForConnectionType(type)) 203 parameter_name = std::string(GetNameForConnectionTypeInternal(type))
264 .append(".DefaultMedianTransportRTTMsec"); 204 .append(".DefaultMedianTransportRTTMsec");
265 it = params_.find(parameter_name); 205 it = params.find(parameter_name);
266 if (it != params_.end() && 206 if (it != params.end() &&
267 base::StringToInt(it->second, &variations_value) && 207 base::StringToInt(it->second, &variations_value) &&
268 variations_value >= kMinimumRTTVariationParameterMsec) { 208 variations_value >= kMinimumRTTVariationParameterMsec) {
269 default_observations[i] = 209 default_observations[i] =
270 NetworkQuality(default_observations[i].http_rtt(), 210 NetworkQuality(default_observations[i].http_rtt(),
271 base::TimeDelta::FromMilliseconds(variations_value), 211 base::TimeDelta::FromMilliseconds(variations_value),
272 default_observations[i].downstream_throughput_kbps()); 212 default_observations[i].downstream_throughput_kbps());
273 } 213 }
274 214
275 variations_value = kMinimumThroughputVariationParameterKbps - 1; 215 variations_value = kMinimumThroughputVariationParameterKbps - 1;
276 parameter_name = std::string(GetNameForConnectionType(type)) 216 parameter_name = std::string(GetNameForConnectionTypeInternal(type))
277 .append(".DefaultMedianKbps"); 217 .append(".DefaultMedianKbps");
278 it = params_.find(parameter_name); 218 it = params.find(parameter_name);
279 219
280 if (it != params_.end() && 220 if (it != params.end() &&
281 base::StringToInt(it->second, &variations_value) && 221 base::StringToInt(it->second, &variations_value) &&
282 variations_value >= kMinimumThroughputVariationParameterKbps) { 222 variations_value >= kMinimumThroughputVariationParameterKbps) {
283 default_observations[i] = NetworkQuality( 223 default_observations[i] = NetworkQuality(
284 default_observations[i].http_rtt(), 224 default_observations[i].http_rtt(),
285 default_observations[i].transport_rtt(), variations_value); 225 default_observations[i].transport_rtt(), variations_value);
286 } 226 }
287 } 227 }
288 } 228 }
289 229
290 void NetworkQualityEstimatorParams::ObtainTypicalNetworkQuality( 230 // Sets |typical_network_quality| to typical network quality for different
291 NetworkQuality typical_network_quality[]) const { 231 // effective connection types.
292 DCHECK(thread_checker_.CalledOnValidThread()); 232 void ObtainTypicalNetworkQualities(
293 233 const std::map<std::string, std::string>& params,
234 NetworkQuality typical_network_quality[]) {
294 for (size_t i = 0; i < EFFECTIVE_CONNECTION_TYPE_LAST; ++i) { 235 for (size_t i = 0; i < EFFECTIVE_CONNECTION_TYPE_LAST; ++i) {
295 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].http_rtt()); 236 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].http_rtt());
296 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].transport_rtt()); 237 DCHECK_EQ(InvalidRTT(), typical_network_quality[i].transport_rtt());
297 DCHECK_EQ(kInvalidThroughput, 238 DCHECK_EQ(kInvalidThroughput,
298 typical_network_quality[i].downstream_throughput_kbps()); 239 typical_network_quality[i].downstream_throughput_kbps());
299 } 240 }
300 241
301 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality( 242 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality(
302 // Set to the 77.5th percentile of 2G RTT observations on Android. This 243 // Set to the 77.5th percentile of 2G RTT observations on Android.
303 // corresponds to the median RTT observation when effective connection 244 // This corresponds to the median RTT observation when effective
304 // type is Slow 2G. 245 // connection type is Slow 2G.
305 base::TimeDelta::FromMilliseconds(3600), 246 base::TimeDelta::FromMilliseconds(3600),
306 base::TimeDelta::FromMilliseconds(3000), 40); 247 base::TimeDelta::FromMilliseconds(3000), 40);
307 248
308 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_2G] = NetworkQuality( 249 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_2G] = NetworkQuality(
309 // Set to the 58th percentile of 2G RTT observations on Android. This 250 // Set to the 58th percentile of 2G RTT observations on Android. This
310 // corresponds to the median RTT observation when effective connection 251 // corresponds to the median RTT observation when effective connection
311 // type is 2G. 252 // type is 2G.
312 base::TimeDelta::FromMilliseconds(1800), 253 base::TimeDelta::FromMilliseconds(1800),
313 base::TimeDelta::FromMilliseconds(1500), 75); 254 base::TimeDelta::FromMilliseconds(1500), 75);
314 255
315 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_3G] = NetworkQuality( 256 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_3G] = NetworkQuality(
316 // Set to the 75th percentile of 3G RTT observations on Android. This 257 // Set to the 75th percentile of 3G RTT observations on Android. This
317 // corresponds to the median RTT observation when effective connection 258 // corresponds to the median RTT observation when effective connection
318 // type is 3G. 259 // type is 3G.
319 base::TimeDelta::FromMilliseconds(450), 260 base::TimeDelta::FromMilliseconds(450),
320 base::TimeDelta::FromMilliseconds(400), 400); 261 base::TimeDelta::FromMilliseconds(400), 400);
321 262
322 // Set to the 25th percentile of 3G RTT observations on Android. 263 // Set to the 25th percentile of 3G RTT observations on Android.
323 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_4G] = 264 typical_network_quality[EFFECTIVE_CONNECTION_TYPE_4G] =
324 NetworkQuality(base::TimeDelta::FromMilliseconds(175), 265 NetworkQuality(base::TimeDelta::FromMilliseconds(175),
325 base::TimeDelta::FromMilliseconds(125), 1600); 266 base::TimeDelta::FromMilliseconds(125), 1600);
326 267
327 static_assert( 268 static_assert(
328 EFFECTIVE_CONNECTION_TYPE_4G + 1 == EFFECTIVE_CONNECTION_TYPE_LAST, 269 EFFECTIVE_CONNECTION_TYPE_4G + 1 == EFFECTIVE_CONNECTION_TYPE_LAST,
329 "Missing effective connection type"); 270 "Missing effective connection type");
330 } 271 }
331 272
332 void NetworkQualityEstimatorParams::ObtainEffectiveConnectionTypeModelParams( 273 // Sets the thresholds for different effective connection types in
333 NetworkQuality connection_thresholds[]) const { 274 // |connection_thresholds|.
334 DCHECK(thread_checker_.CalledOnValidThread()); 275 void ObtainConnectionThresholds(
335 276 const std::map<std::string, std::string>& params,
277 NetworkQuality connection_thresholds[]) {
336 // First set the default thresholds. 278 // First set the default thresholds.
337 NetworkQuality default_effective_connection_type_thresholds 279 NetworkQuality default_effective_connection_type_thresholds
338 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST]; 280 [EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_LAST];
339 281
340 default_effective_connection_type_thresholds 282 default_effective_connection_type_thresholds
341 [EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality( 283 [EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = NetworkQuality(
342 // Set to the 66th percentile of 2G RTT observations on Android. 284 // Set to the 66th percentile of 2G RTT observations on Android.
343 base::TimeDelta::FromMilliseconds(2010), 285 base::TimeDelta::FromMilliseconds(2010),
344 base::TimeDelta::FromMilliseconds(1870), kInvalidThroughput); 286 base::TimeDelta::FromMilliseconds(1870), kInvalidThroughput);
345 287
(...skipping 25 matching lines...) Expand all
371 DCHECK_EQ(kInvalidThroughput, 313 DCHECK_EQ(kInvalidThroughput,
372 connection_thresholds[i].downstream_throughput_kbps()); 314 connection_thresholds[i].downstream_throughput_kbps());
373 if (effective_connection_type == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) 315 if (effective_connection_type == EFFECTIVE_CONNECTION_TYPE_UNKNOWN)
374 continue; 316 continue;
375 317
376 std::string connection_type_name = std::string( 318 std::string connection_type_name = std::string(
377 DeprecatedGetNameForEffectiveConnectionType(effective_connection_type)); 319 DeprecatedGetNameForEffectiveConnectionType(effective_connection_type));
378 320
379 connection_thresholds[i].set_http_rtt( 321 connection_thresholds[i].set_http_rtt(
380 base::TimeDelta::FromMilliseconds(GetValueForVariationParam( 322 base::TimeDelta::FromMilliseconds(GetValueForVariationParam(
381 params_, connection_type_name + ".ThresholdMedianHttpRTTMsec", 323 params, connection_type_name + ".ThresholdMedianHttpRTTMsec",
382 default_effective_connection_type_thresholds[i] 324 default_effective_connection_type_thresholds[i]
383 .http_rtt() 325 .http_rtt()
384 .InMilliseconds()))); 326 .InMilliseconds())));
385 327
386 connection_thresholds[i].set_transport_rtt( 328 connection_thresholds[i].set_transport_rtt(
387 base::TimeDelta::FromMilliseconds(GetValueForVariationParam( 329 base::TimeDelta::FromMilliseconds(GetValueForVariationParam(
388 params_, connection_type_name + ".ThresholdMedianTransportRTTMsec", 330 params, connection_type_name + ".ThresholdMedianTransportRTTMsec",
389 default_effective_connection_type_thresholds[i] 331 default_effective_connection_type_thresholds[i]
390 .transport_rtt() 332 .transport_rtt()
391 .InMilliseconds()))); 333 .InMilliseconds())));
392 334
393 connection_thresholds[i].set_downstream_throughput_kbps( 335 connection_thresholds[i].set_downstream_throughput_kbps(
394 GetValueForVariationParam( 336 GetValueForVariationParam(
395 params_, connection_type_name + ".ThresholdMedianKbps", 337 params, connection_type_name + ".ThresholdMedianKbps",
396 default_effective_connection_type_thresholds[i] 338 default_effective_connection_type_thresholds[i]
397 .downstream_throughput_kbps())); 339 .downstream_throughput_kbps()));
398 DCHECK(i == 0 || 340 DCHECK(i == 0 ||
399 connection_thresholds[i].IsFaster(connection_thresholds[i - 1])); 341 connection_thresholds[i].IsFaster(connection_thresholds[i - 1]));
400 } 342 }
401 } 343 }
402 344
345 base::Optional<EffectiveConnectionType> GetForcedEffectiveConnectionType(
346 const std::map<std::string, std::string>& params) {
347 std::string forced_value = GetStringValueForVariationParamWithDefaultValue(
348 params, kForceEffectiveConnectionType, "");
349 if (forced_value.empty())
350 return base::Optional<EffectiveConnectionType>();
351
352 EffectiveConnectionType forced_effective_connection_type =
353 EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
354
355 bool effective_connection_type_available = GetEffectiveConnectionTypeForName(
356 forced_value, &forced_effective_connection_type);
357
358 DCHECK(effective_connection_type_available);
359
360 // Silence unused variable warning in release builds.
361 (void)effective_connection_type_available;
362
363 return forced_effective_connection_type;
364 }
365
366 } // namespace
367
368 NetworkQualityEstimatorParams::NetworkQualityEstimatorParams(
369 const std::map<std::string, std::string>& params)
370 : params_(params),
371 weight_multiplier_per_second_(GetWeightMultiplierPerSecond(params_)),
372 weight_multiplier_per_dbm_(
373 GetDoubleValueForVariationParamWithDefaultValue(params_,
374 "rssi_weight_per_dbm",
375 1.0)),
376 correlation_uma_logging_probability_(
377 GetDoubleValueForVariationParamWithDefaultValue(
378 params_,
379 "correlation_logging_probability",
380 0.01)),
381 forced_effective_connection_type_(
382 GetForcedEffectiveConnectionType(params_)),
383 persistent_cache_reading_enabled_(
384 GetPersistentCacheReadingEnabled(params_)),
385 min_socket_watcher_notification_interval_(
386 GetMinSocketWatcherNotificationInterval(params_)) {
387 DCHECK_LE(0.0, correlation_uma_logging_probability_);
388 DCHECK_GE(1.0, correlation_uma_logging_probability_);
389
390 ObtainDefaultObservations(params_, default_observations_);
391 ObtainTypicalNetworkQualities(params_, typical_network_quality_);
392 ObtainConnectionThresholds(params_, connection_thresholds_);
393 }
394
395 NetworkQualityEstimatorParams::~NetworkQualityEstimatorParams() {
396 DCHECK(thread_checker_.CalledOnValidThread());
397 }
398
399 std::string NetworkQualityEstimatorParams::GetEffectiveConnectionTypeAlgorithm()
400 const {
401 DCHECK(thread_checker_.CalledOnValidThread());
402
403 const auto it = params_.find("effective_connection_type_algorithm");
404 if (it == params_.end())
405 return std::string();
406 return it->second;
407 }
408
409 // static
410 const char* NetworkQualityEstimatorParams::GetNameForConnectionType(
411 NetworkChangeNotifier::ConnectionType connection_type) {
412 return GetNameForConnectionTypeInternal(connection_type);
413 }
414
415 const NetworkQuality& NetworkQualityEstimatorParams::DefaultObservation(
416 NetworkChangeNotifier::ConnectionType type) const {
417 DCHECK(thread_checker_.CalledOnValidThread());
418 return default_observations_[type];
419 }
420
421 const NetworkQuality& NetworkQualityEstimatorParams::TypicalNetworkQuality(
422 EffectiveConnectionType type) const {
423 DCHECK(thread_checker_.CalledOnValidThread());
424 return typical_network_quality_[type];
425 }
426
427 const NetworkQuality& NetworkQualityEstimatorParams::ConnectionThreshold(
428 EffectiveConnectionType type) const {
429 DCHECK(thread_checker_.CalledOnValidThread());
430 return connection_thresholds_[type];
431 }
432
403 } // namespace internal 433 } // namespace internal
404 434
405 } // namespace nqe 435 } // namespace nqe
406 436
407 } // namespace net 437 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator_params.h ('k') | net/nqe/network_quality_estimator_params_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698