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..79d595fffa790d8b60d22ef6b66180519f20ecca 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( |
+ bool stop_reporting_effective_connection_type) { |
+ stop_reporting_effective_connection_type_ = |
tbansal1
2016/07/19 23:05:22
Add thread checker.
RyanSturm
2016/07/19 23:31:02
Done.
|
+ stop_reporting_effective_connection_type; |
+} |
+ |
+void NetworkQualityEstimator::ReportEffectiveConnectionTypeForTesting( |
+ EffectiveConnectionType effective_connection_type) { |
+ FOR_EACH_OBSERVER( |
tbansal1
2016/07/19 23:05:22
Add thread checker.
RyanSturm
2016/07/19 23:31:02
Done.
|
+ 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 |