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

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

Issue 2850003002: Add flag to override Effective Connection Type (Closed)
Patch Set: ryansturm nits 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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const auto it = params.find(parameter_name); 59 const auto it = params.find(parameter_name);
60 if (it == params.end()) 60 if (it == params.end())
61 return default_value; 61 return default_value;
62 return it->second; 62 return it->second;
63 } 63 }
64 64
65 } // namespace 65 } // namespace
66 66
67 namespace net { 67 namespace net {
68 68
69 const char kForceEffectiveConnectionType[] = "force_effective_connection_type";
70
69 namespace nqe { 71 namespace nqe {
70 72
71 namespace internal { 73 namespace internal {
72 74
73 NetworkQualityEstimatorParams::NetworkQualityEstimatorParams( 75 NetworkQualityEstimatorParams::NetworkQualityEstimatorParams(
74 const std::map<std::string, std::string>& params) 76 const std::map<std::string, std::string>& params)
75 : params_(params) {} 77 : params_(params) {}
76 78
77 NetworkQualityEstimatorParams::~NetworkQualityEstimatorParams() { 79 NetworkQualityEstimatorParams::~NetworkQualityEstimatorParams() {
78 DCHECK(thread_checker_.CalledOnValidThread()); 80 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 GetDoubleValueForVariationParamWithDefaultValue( 358 GetDoubleValueForVariationParamWithDefaultValue(
357 params_, "correlation_logging_probability", 0.01); 359 params_, "correlation_logging_probability", 0.01);
358 DCHECK_LE(0.0, correlation_uma_logging_probability); 360 DCHECK_LE(0.0, correlation_uma_logging_probability);
359 DCHECK_GE(1.0, correlation_uma_logging_probability); 361 DCHECK_GE(1.0, correlation_uma_logging_probability);
360 return correlation_uma_logging_probability; 362 return correlation_uma_logging_probability;
361 } 363 }
362 364
363 bool NetworkQualityEstimatorParams::forced_effective_connection_type_set() 365 bool NetworkQualityEstimatorParams::forced_effective_connection_type_set()
364 const { 366 const {
365 return !GetStringValueForVariationParamWithDefaultValue( 367 return !GetStringValueForVariationParamWithDefaultValue(
366 params_, "force_effective_connection_type", "") 368 params_, kForceEffectiveConnectionType, "")
367 .empty(); 369 .empty();
368 } 370 }
369 371
370 EffectiveConnectionType 372 EffectiveConnectionType
371 NetworkQualityEstimatorParams::forced_effective_connection_type() const { 373 NetworkQualityEstimatorParams::forced_effective_connection_type() const {
372 EffectiveConnectionType forced_effective_connection_type = 374 EffectiveConnectionType forced_effective_connection_type =
373 EFFECTIVE_CONNECTION_TYPE_UNKNOWN; 375 EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
374 std::string forced_value = GetStringValueForVariationParamWithDefaultValue( 376 std::string forced_value = GetStringValueForVariationParamWithDefaultValue(
375 params_, "force_effective_connection_type", 377 params_, kForceEffectiveConnectionType,
376 GetNameForEffectiveConnectionType(EFFECTIVE_CONNECTION_TYPE_UNKNOWN)); 378 GetNameForEffectiveConnectionType(EFFECTIVE_CONNECTION_TYPE_UNKNOWN));
377 DCHECK(!forced_value.empty()); 379 DCHECK(!forced_value.empty());
378 bool effective_connection_type_available = GetEffectiveConnectionTypeForName( 380 bool effective_connection_type_available = GetEffectiveConnectionTypeForName(
379 forced_value, &forced_effective_connection_type); 381 forced_value, &forced_effective_connection_type);
380 DCHECK(effective_connection_type_available); 382 DCHECK(effective_connection_type_available);
381 383
382 // Silence unused variable warning in release builds. 384 // Silence unused variable warning in release builds.
383 (void)effective_connection_type_available; 385 (void)effective_connection_type_available;
384 386
385 return forced_effective_connection_type; 387 return forced_effective_connection_type;
(...skipping 16 matching lines...) Expand all
402 // Use 1000 milliseconds as the default value. 404 // Use 1000 milliseconds as the default value.
403 return base::TimeDelta::FromMilliseconds(GetValueForVariationParam( 405 return base::TimeDelta::FromMilliseconds(GetValueForVariationParam(
404 params_, "min_socket_watcher_notification_interval_msec", 1000)); 406 params_, "min_socket_watcher_notification_interval_msec", 1000));
405 } 407 }
406 408
407 } // namespace internal 409 } // namespace internal
408 410
409 } // namespace nqe 411 } // namespace nqe
410 412
411 } // namespace net 413 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698