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 7750e2faff832b75c6063e3551e24aa924905d94..0b0449a43fdbc239c851c6e3033691c2ee942e35 100644 |
| --- a/net/nqe/network_quality_estimator.cc |
| +++ b/net/nqe/network_quality_estimator.cc |
| @@ -140,13 +140,20 @@ base::HistogramBase* GetHistogram( |
| max_limit, kBucketCount, base::HistogramBase::kUmaTargetedHistogramFlag); |
| } |
| -bool GetValueForVariationParam( |
| +// Sets |variations_value| to the value of |parameter_name| read from |
| +// |variation_params|. If the value is unavailable from |variation_params|, then |
| +// |variations_value| is set to |default_value|. |
| +void GetValueForVariationParam( |
| const std::map<std::string, std::string>& variation_params, |
| const std::string& parameter_name, |
| + int32_t default_value, |
| int32_t* variations_value) { |
| const auto it = variation_params.find(parameter_name); |
| - return it != variation_params.end() && |
| - base::StringToInt(it->second, variations_value); |
| + if (it != variation_params.end() && |
| + base::StringToInt(it->second, variations_value)) { |
| + return; |
| + } |
| + *variations_value = default_value; |
| } |
| // Returns the algorithm that should be used for computing effective connection |
| @@ -316,6 +323,18 @@ NetworkQualityEstimator::NetworkQualityEstimator( |
| accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(15)); |
| accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(30)); |
| accuracy_recording_intervals_.push_back(base::TimeDelta::FromSeconds(60)); |
| + |
| + // Below 33rd percentile of 2G transport RTT observations. |
| + default_connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_SLOW_2G] = |
| + nqe::internal::NetworkQuality(nqe::internal::InvalidRTT(), |
| + base::TimeDelta::FromMilliseconds(1870), |
|
RyanSturm
2016/07/12 19:57:55
nit: Can you move the 1870 and 1300 to a static co
tbansal1
2016/07/12 20:32:25
I would prefer to keep them here instead of using
RyanSturm
2016/07/12 20:44:47
I think it would be more clear like:
// 1.87 seco
tbansal1
2016/07/13 05:52:03
I updated the comments.
|
| + nqe::internal::kInvalidThroughput); |
| + |
| + // 50th percentile of 2G transport RTT observations. |
| + default_connection_thresholds_[EFFECTIVE_CONNECTION_TYPE_2G] = |
| + nqe::internal::NetworkQuality(nqe::internal::InvalidRTT(), |
| + base::TimeDelta::FromMilliseconds(1300), |
| + nqe::internal::kInvalidThroughput); |
| } |
| void NetworkQualityEstimator::ObtainOperatingParams( |
| @@ -381,57 +400,54 @@ void NetworkQualityEstimator::ObtainEffectiveConnectionTypeModelParams( |
| std::string connection_type_name = std::string( |
| GetNameForEffectiveConnectionType(effective_connection_type)); |
| - int32_t variations_value = kMinimumRTTVariationParameterMsec - 1; |
| - if (GetValueForVariationParam( |
| - variation_params, connection_type_name + kThresholdURLRTTMsecSuffix, |
| - &variations_value) && |
| - variations_value >= kMinimumRTTVariationParameterMsec) { |
| - connection_thresholds_[i].set_http_rtt( |
| - base::TimeDelta(base::TimeDelta::FromMilliseconds(variations_value))); |
| - |
| - // Verify that the RTT values are in decreasing order as the network |
| - // quality improves. |
| - DCHECK(i == 0 || |
| - connection_thresholds_[i - 1].http_rtt() == |
| - nqe::internal::InvalidRTT() || |
| - connection_thresholds_[i].http_rtt() <= |
| - connection_thresholds_[i - 1].http_rtt()); |
| - } |
| - |
| - variations_value = kMinimumRTTVariationParameterMsec - 1; |
| - if (GetValueForVariationParam( |
| - variation_params, |
| - connection_type_name + kThresholdTransportRTTMsecSuffix, |
| - &variations_value) && |
| - variations_value >= kMinimumRTTVariationParameterMsec) { |
| - connection_thresholds_[i].set_transport_rtt( |
| - base::TimeDelta(base::TimeDelta::FromMilliseconds(variations_value))); |
| - |
| - // Verify that the transport RTT values are in decreasing order as the |
| - // network quality improves. |
| - DCHECK(i == 0 || |
| - connection_thresholds_[i - 1].transport_rtt() == |
| - nqe::internal::InvalidRTT() || |
| - connection_thresholds_[i].transport_rtt() <= |
| - connection_thresholds_[i - 1].transport_rtt()); |
| - } |
| - |
| - variations_value = kMinimumThroughputVariationParameterKbps - 1; |
| - if (GetValueForVariationParam(variation_params, |
| - connection_type_name + kThresholdKbpsSuffix, |
| - &variations_value) && |
| - variations_value >= kMinimumThroughputVariationParameterKbps) { |
| - connection_thresholds_[i].set_downstream_throughput_kbps( |
| - variations_value); |
| - |
| - // Verify that the throughput values are in increasing order as the |
| - // network quality improves. |
| - DCHECK(i == 0 || |
| - connection_thresholds_[i - 1].downstream_throughput_kbps() == |
| - kMinimumThroughputVariationParameterKbps || |
| - connection_thresholds_[i].downstream_throughput_kbps() >= |
| - connection_thresholds_[i - 1].downstream_throughput_kbps()); |
| - } |
| + int32_t variations_value; |
| + GetValueForVariationParam( |
| + variation_params, connection_type_name + kThresholdURLRTTMsecSuffix, |
| + default_connection_thresholds_[i].http_rtt().InMilliseconds(), |
| + &variations_value); |
| + connection_thresholds_[i].set_http_rtt( |
| + base::TimeDelta(base::TimeDelta::FromMilliseconds(variations_value))); |
| + // Verify that the RTT values are in decreasing order as the network |
| + // quality improves. |
| + DCHECK(i == 0 || |
| + connection_thresholds_[i].http_rtt() == |
| + nqe::internal::InvalidRTT() || |
| + connection_thresholds_[i - 1].http_rtt() == |
| + nqe::internal::InvalidRTT() || |
| + connection_thresholds_[i].http_rtt() <= |
| + connection_thresholds_[i - 1].http_rtt()); |
| + |
| + GetValueForVariationParam( |
| + variation_params, |
| + connection_type_name + kThresholdTransportRTTMsecSuffix, |
| + default_connection_thresholds_[i].transport_rtt().InMilliseconds(), |
| + &variations_value); |
| + connection_thresholds_[i].set_transport_rtt( |
| + base::TimeDelta(base::TimeDelta::FromMilliseconds(variations_value))); |
| + // Verify that the transport RTT values are in decreasing order as the |
| + // network quality improves. |
| + DCHECK(i == 0 || |
| + connection_thresholds_[i].transport_rtt() == |
| + nqe::internal::InvalidRTT() || |
| + connection_thresholds_[i - 1].transport_rtt() == |
| + nqe::internal::InvalidRTT() || |
| + connection_thresholds_[i].transport_rtt() <= |
| + connection_thresholds_[i - 1].transport_rtt()); |
| + |
| + GetValueForVariationParam( |
| + variation_params, connection_type_name + kThresholdKbpsSuffix, |
| + default_connection_thresholds_[i].downstream_throughput_kbps(), |
| + &variations_value); |
| + connection_thresholds_[i].set_downstream_throughput_kbps(variations_value); |
| + // Verify that the throughput values are in increasing order as the |
| + // network quality improves. |
| + DCHECK(i == 0 || |
| + connection_thresholds_[i].downstream_throughput_kbps() == |
| + kMinimumThroughputVariationParameterKbps || |
| + connection_thresholds_[i - 1].downstream_throughput_kbps() == |
| + kMinimumThroughputVariationParameterKbps || |
| + connection_thresholds_[i].downstream_throughput_kbps() >= |
| + connection_thresholds_[i - 1].downstream_throughput_kbps()); |
| } |
| } |
| @@ -1453,10 +1469,18 @@ void NetworkQualityEstimator::MaybeRecomputeEffectiveConnectionType() { |
| // last computed or a connection change event was observed since the last |
| // computation. Strict inequalities are used to ensure that effective |
| // connection type is recomputed on connection change events even if the clock |
| - // has not updated. |
| + // has not updated. If the algorithm uses transport RTT, then recompute the |
| + // effective connection type if the effective connection type was previously |
| + // unavailable. This is because the transport RTT observations are voluminous, |
| + // so it may now be possible to compute the effective connection type. |
| if (now - last_effective_connection_type_computation_ < |
| effective_connection_type_recomputation_interval_ && |
| - last_connection_change_ < last_effective_connection_type_computation_) { |
| + last_connection_change_ < last_effective_connection_type_computation_ && |
| + (effective_connection_type_ != |
| + NetworkQualityEstimator::EFFECTIVE_CONNECTION_TYPE_UNKNOWN || |
| + effective_connection_type_algorithm_ != |
| + EffectiveConnectionTypeAlgorithm:: |
| + TRANSPORT_RTT_OR_DOWNSTREAM_THROUGHOUT)) { |
| return; |
| } |