Chromium Code Reviews| Index: net/nqe/network_quality_estimator.cc |
| diff --git a/net/nqe/network_quality_estimator.cc b/net/nqe/network_quality_estimator.cc |
| index f2247f048b1195104c95a750623e9433d1e09c92..5fabb8178bf4c14c6451e25245cfd1d23a9aa946 100644 |
| --- a/net/nqe/network_quality_estimator.cc |
| +++ b/net/nqe/network_quality_estimator.cc |
| @@ -140,6 +140,20 @@ bool GetValueForVariationParam( |
| base::StringToInt(it->second, variations_value); |
| } |
| +// Returns the value of the |parameter_name| in |variation_params|. If |
| +// |parameter_name| is not set in |variation_params|, then |default_value| is |
| +// returned. |
| +int32_t GetValueForVariationParamWithDefaultValue( |
| + const std::map<std::string, std::string>& variation_params, |
| + const std::string& parameter_name, |
| + int32_t default_value) { |
| + int32_t variations_value; |
| + return GetValueForVariationParam(variation_params, parameter_name, |
| + &variations_value) |
| + ? variations_value |
| + : default_value; |
| +} |
| + |
| net::NetworkQualityObservationSource ProtocolSourceToObservationSource( |
| net::SocketPerformanceWatcherFactory::Protocol protocol) { |
| switch (protocol) { |
| @@ -253,6 +267,9 @@ NetworkQualityEstimator::NetworkQualityEstimator( |
| use_small_responses_(use_smaller_responses_for_tests), |
| weight_multiplier_per_second_( |
| GetWeightMultiplierPerSecond(variation_params)), |
| + algorithm_(GetValueForVariationParamWithDefaultValue(variation_params, |
|
bengr
2016/06/02 22:59:43
You should add a comment somewhere that you defaul
tbansal1
2016/06/03 00:50:10
Done.
|
| + "algorithm", |
| + 0)), |
| tick_clock_(new base::DefaultTickClock()), |
| effective_connection_type_recomputation_interval_( |
| base::TimeDelta::FromSeconds(15)), |
| @@ -273,6 +290,7 @@ NetworkQualityEstimator::NetworkQualityEstimator( |
| // oldest cache entry is rewritten to use a doubly-linked-list LRU queue. |
| static_assert(kMaximumNetworkQualityCacheSize <= 10, |
| "Size of the network quality cache must <= 10"); |
| + DCHECK_GE(algorithm_, 0); |
|
bengr
2016/06/02 22:59:43
Shouldn't this be DCHECK_EQ? algorithm_ should be
tbansal1
2016/06/03 00:50:10
I removed it since with strings it does not really
|
| ObtainOperatingParams(variation_params); |
| ObtainEffectiveConnectionTypeModelParams(variation_params); |
| @@ -755,6 +773,21 @@ NetworkQualityEstimator::GetRecentEffectiveConnectionType( |
| const base::TimeTicks& start_time) const { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| + switch (algorithm_) { |
| + case 0: |
| + return GetRecentEffectiveConnectionTypeAlgorithm0(start_time); |
| + default: |
| + NOTREACHED(); |
| + } |
| + return GetRecentEffectiveConnectionTypeAlgorithm0(start_time); |
| +} |
| + |
| +NetworkQualityEstimator::EffectiveConnectionType |
| +NetworkQualityEstimator::GetRecentEffectiveConnectionTypeAlgorithm0( |
| + const base::TimeTicks& start_time) const { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + DCHECK_EQ(0, algorithm_); |
| + |
| // If the device is currently offline, then return |
| // EFFECTIVE_CONNECTION_TYPE_OFFLINE. |
| if (GetCurrentNetworkID().type == NetworkChangeNotifier::CONNECTION_NONE) |
| @@ -768,7 +801,7 @@ NetworkQualityEstimator::GetRecentEffectiveConnectionType( |
| if (!GetRecentMedianDownlinkThroughputKbps(start_time, &kbps)) |
| kbps = nqe::internal::kInvalidThroughput; |
| - if (http_rtt == nqe::internal::InvalidRTT() && |
| + if (http_rtt == nqe::internal::InvalidRTT() || |
| kbps == nqe::internal::kInvalidThroughput) { |
| // Quality of the current network is unknown. |
| return EFFECTIVE_CONNECTION_TYPE_UNKNOWN; |