Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: net/nqe/network_quality_estimator.cc

Issue 2266663002: NQE: Change GetEffectiveConnectionType to return last ECT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PS Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/nqe/network_quality_estimator.cc
diff --git a/net/nqe/network_quality_estimator.cc b/net/nqe/network_quality_estimator.cc
index 9511ee7594ef9954a4701ca0b5a8e410a11e8c11..d33ac8fbfa5d61a9077cfba98046064d1795a420 100644
--- a/net/nqe/network_quality_estimator.cc
+++ b/net/nqe/network_quality_estimator.cc
@@ -627,6 +627,8 @@ void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) {
estimated_quality_at_last_main_frame_ = nqe::internal::NetworkQuality(
estimated_http_rtt, estimated_transport_rtt,
downstream_throughput_kbps);
+
+ RecomputeEffectiveConnectionType();
effective_connection_type_at_last_main_frame_ =
GetEffectiveConnectionType();
@@ -1158,10 +1160,29 @@ void NetworkQualityEstimator::RecordMetricsOnMainFrameRequest() const {
effective_connection_type_histogram->Add(effective_connection_type);
}
+void NetworkQualityEstimator::RecomputeEffectiveConnectionType() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ const base::TimeTicks now = tick_clock_->NowTicks();
+
+ const EffectiveConnectionType past_type = effective_connection_type_;
+ last_effective_connection_type_computation_ = now;
+
+ effective_connection_type_ =
+ GetRecentEffectiveConnectionType(base::TimeTicks());
+
+ if (past_type != effective_connection_type_)
+ NotifyObserversOfEffectiveConnectionTypeChanged();
+
+ rtt_observations_size_at_last_ect_computation_ = rtt_observations_.Size();
+ throughput_observations_size_at_last_ect_computation_ =
+ downstream_throughput_kbps_observations_.Size();
+}
+
EffectiveConnectionType NetworkQualityEstimator::GetEffectiveConnectionType()
const {
DCHECK(thread_checker_.CalledOnValidThread());
- return GetRecentEffectiveConnectionType(base::TimeTicks());
+ return effective_connection_type_;
}
EffectiveConnectionType
@@ -1635,16 +1656,7 @@ void NetworkQualityEstimator::MaybeRecomputeEffectiveConnectionType() {
return;
}
- const EffectiveConnectionType past_type = effective_connection_type_;
- last_effective_connection_type_computation_ = now;
- effective_connection_type_ = GetEffectiveConnectionType();
-
- if (past_type != effective_connection_type_)
- NotifyObserversOfEffectiveConnectionTypeChanged();
-
- rtt_observations_size_at_last_ect_computation_ = rtt_observations_.Size();
- throughput_observations_size_at_last_ect_computation_ =
- downstream_throughput_kbps_observations_.Size();
+ RecomputeEffectiveConnectionType();
}
void NetworkQualityEstimator::

Powered by Google App Engine
This is Rietveld 408576698