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

Unified Diff: net/nqe/network_quality_estimator.cc

Issue 2003423005: Expose a method GetRecentEffectiveConnectionType in NQE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 7 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
« no previous file with comments | « net/nqe/network_quality_estimator.h ('k') | net/nqe/network_quality_estimator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/network_quality_estimator.cc
diff --git a/net/nqe/network_quality_estimator.cc b/net/nqe/network_quality_estimator.cc
index 700f091f1d61cf04296c8247c1622496bc1ab533..a42805fd529c5a25896cc0f26b4e894532a09fff 100644
--- a/net/nqe/network_quality_estimator.cc
+++ b/net/nqe/network_quality_estimator.cc
@@ -700,6 +700,13 @@ void NetworkQualityEstimator::RecordMetricsOnConnectionTypeChanged() const {
NetworkQualityEstimator::EffectiveConnectionType
NetworkQualityEstimator::GetEffectiveConnectionType() const {
DCHECK(thread_checker_.CalledOnValidThread());
+ return GetRecentEffectiveConnectionType(base::TimeTicks());
+}
+
+NetworkQualityEstimator::EffectiveConnectionType
+NetworkQualityEstimator::GetRecentEffectiveConnectionType(
+ const base::TimeTicks& start_time) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
// If the device is currently offline, then return
// EFFECTIVE_CONNECTION_TYPE_OFFLINE.
@@ -707,11 +714,11 @@ NetworkQualityEstimator::GetEffectiveConnectionType() const {
return EFFECTIVE_CONNECTION_TYPE_OFFLINE;
base::TimeDelta http_rtt = nqe::internal::InvalidRTT();
- if (!GetHttpRTTEstimate(&http_rtt))
+ if (!GetRecentHttpRTTMedian(start_time, &http_rtt))
http_rtt = nqe::internal::InvalidRTT();
int32_t kbps = nqe::internal::kInvalidThroughput;
- if (!GetDownlinkThroughputKbpsEstimate(&kbps))
+ if (!GetRecentMedianDownlinkThroughputKbps(start_time, &kbps))
kbps = nqe::internal::kInvalidThroughput;
if (http_rtt == nqe::internal::InvalidRTT() &&
@@ -736,6 +743,7 @@ NetworkQualityEstimator::GetEffectiveConnectionType() const {
connection_thresholds_[i].downstream_throughput_kbps() !=
nqe::internal::kInvalidThroughput &&
kbps <= connection_thresholds_[i].downstream_throughput_kbps();
+
// Return |type| as the effective connection type if the current network's
// RTT is worse than the threshold RTT for |type|, or if the current
// network's throughput is lower than the threshold throughput for |type|.
@@ -751,40 +759,19 @@ NetworkQualityEstimator::GetEffectiveConnectionType() const {
bool NetworkQualityEstimator::GetHttpRTTEstimate(base::TimeDelta* rtt) const {
DCHECK(thread_checker_.CalledOnValidThread());
- std::vector<NetworkQualityObservationSource> disallowed_observation_sources;
- disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_TCP);
- disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC);
- *rtt = GetRTTEstimateInternal(disallowed_observation_sources,
- base::TimeTicks(), 50);
- return (*rtt != nqe::internal::InvalidRTT());
+ return GetRecentHttpRTTMedian(base::TimeTicks(), rtt);
}
bool NetworkQualityEstimator::GetTransportRTTEstimate(
base::TimeDelta* rtt) const {
DCHECK(thread_checker_.CalledOnValidThread());
- std::vector<NetworkQualityObservationSource> disallowed_observation_sources;
- disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST);
- // Disallow external estimate provider since it provides RTT at HTTP layer.
- disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE);
- disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_CACHED_ESTIMATE);
- disallowed_observation_sources.push_back(
- NETWORK_QUALITY_OBSERVATION_SOURCE_DEFAULT_FROM_PLATFORM);
-
- *rtt = GetRTTEstimateInternal(disallowed_observation_sources,
- base::TimeTicks(), 50);
- return (*rtt != nqe::internal::InvalidRTT());
+ return GetRecentTransportRTTMedian(base::TimeTicks(), rtt);
}
bool NetworkQualityEstimator::GetDownlinkThroughputKbpsEstimate(
int32_t* kbps) const {
DCHECK(thread_checker_.CalledOnValidThread());
- *kbps = GetDownlinkThroughputKbpsEstimateInternal(base::TimeTicks(), 50);
- return (*kbps != nqe::internal::kInvalidThroughput);
+ return GetRecentMedianDownlinkThroughputKbps(base::TimeTicks(), kbps);
}
bool NetworkQualityEstimator::GetRecentHttpRTTMedian(
« no previous file with comments | « net/nqe/network_quality_estimator.h ('k') | net/nqe/network_quality_estimator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698