| 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..e42fb96a0b244da1073f7ff744f6774fb307ef01 100644
|
| --- a/net/nqe/network_quality_estimator.cc
|
| +++ b/net/nqe/network_quality_estimator.cc
|
| @@ -258,20 +258,21 @@ NetworkQualityEstimator::NetworkQualityEstimator(
|
| NetworkID(NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN,
|
| std::string())),
|
| downstream_throughput_kbps_observations_(weight_multiplier_per_second_),
|
| rtt_observations_(weight_multiplier_per_second_),
|
| effective_connection_type_at_last_main_frame_(
|
| EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
|
| external_estimate_provider_(std::move(external_estimates_provider)),
|
| effective_connection_type_(EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
|
| min_signal_strength_since_connection_change_(INT32_MAX),
|
| max_signal_strength_since_connection_change_(INT32_MIN),
|
| + stop_reporting_effective_connection_type_(false),
|
| weak_ptr_factory_(this) {
|
| static_assert(kDefaultHalfLifeSeconds > 0,
|
| "Default half life duration must be > 0");
|
| static_assert(kMaximumNetworkQualityCacheSize > 0,
|
| "Size of the network quality cache must be > 0");
|
| // This limit should not be increased unless the logic for removing the
|
| // 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");
|
| // None of the algorithms can have an empty name.
|
| @@ -730,20 +731,33 @@ void NetworkQualityEstimator::SetUseLocalHostRequestsForTesting(
|
| use_localhost_requests_);
|
| }
|
|
|
| void NetworkQualityEstimator::SetUseSmallResponsesForTesting(
|
| bool use_small_responses) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| use_small_responses_ = use_small_responses;
|
| throughput_analyzer_->SetUseSmallResponsesForTesting(use_small_responses_);
|
| }
|
|
|
| +void NetworkQualityEstimator::StopReportingEffectiveConnectionTypeForTesting() {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + stop_reporting_effective_connection_type_ = true;
|
| +}
|
| +
|
| +void NetworkQualityEstimator::ReportEffectiveConnectionTypeForTesting(
|
| + EffectiveConnectionType effective_connection_type) {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + FOR_EACH_OBSERVER(
|
| + EffectiveConnectionTypeObserver, effective_connection_type_observer_list_,
|
| + OnEffectiveConnectionTypeChanged(effective_connection_type));
|
| +}
|
| +
|
| bool NetworkQualityEstimator::RequestProvidesRTTObservation(
|
| const URLRequest& request) const {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| return (use_localhost_requests_ || !IsLocalhost(request.url().host())) &&
|
| // Verify that response headers are received, so it can be ensured that
|
| // response is not cached.
|
| !request.response_info().response_time.is_null() &&
|
| !request.was_cached() &&
|
| request.creation_time() >= last_connection_change_;
|
| @@ -1464,18 +1478,19 @@ void NetworkQualityEstimator::MaybeRecomputeEffectiveConnectionType() {
|
| last_effective_connection_type_computation_ = now;
|
| effective_connection_type_ = GetEffectiveConnectionType();
|
|
|
| if (past_type != effective_connection_type_)
|
| NotifyObserversOfEffectiveConnectionTypeChanged();
|
| }
|
|
|
| void NetworkQualityEstimator::
|
| NotifyObserversOfEffectiveConnectionTypeChanged() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| -
|
| + if (stop_reporting_effective_connection_type_)
|
| + return;
|
| // TODO(tbansal): Add hysteresis in the notification.
|
| FOR_EACH_OBSERVER(
|
| EffectiveConnectionTypeObserver, effective_connection_type_observer_list_,
|
| OnEffectiveConnectionTypeChanged(effective_connection_type_));
|
| }
|
|
|
| } // namespace net
|
|
|