| 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..c93708b693460ad90177e4c2c0a8ecc9cb4b6dc4 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,20 @@ 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));
|
| +
|
| + // Set to 1870 milliseconds which corresponds to 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),
|
| + nqe::internal::kInvalidThroughput);
|
| +
|
| + // Set to 1300 milliseconds which corresponds to 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 +402,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 +1471,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;
|
| }
|
|
|
|
|