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

Unified Diff: net/nqe/network_quality_estimator.cc

Issue 2010003002: Reduce the number of calls to external estimate provider (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 a4a469228d6be9853976cd7349d4227e6ff45d08..90f3c986715fc95b5136cbc1f083144cf5f7ba52 100644
--- a/net/nqe/network_quality_estimator.cc
+++ b/net/nqe/network_quality_estimator.cc
@@ -276,7 +276,6 @@ NetworkQualityEstimator::NetworkQualityEstimator(
RecordExternalEstimateProviderMetrics(
EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE);
external_estimate_provider_->SetUpdatedEstimateDelegate(this);
- QueryExternalEstimateProvider();
} else {
RecordExternalEstimateProviderMetrics(
EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE);
@@ -618,7 +617,18 @@ void NetworkQualityEstimator::OnConnectionTypeChanged(
rtt_observations_.Clear();
current_network_id_ = GetCurrentNetworkID();
- QueryExternalEstimateProvider();
+ // Query the external estimate provider on certain connection types. Once the
+ // updated estimates are available, OnUpdatedEstimateAvailable will be called
+ // by |external_estimate_provider_| with updated estimates.
+ if (external_estimate_provider_ &&
+ current_network_id_.type != NetworkChangeNotifier::CONNECTION_NONE &&
+ current_network_id_.type != NetworkChangeNotifier::CONNECTION_UNKNOWN &&
+ current_network_id_.type != NetworkChangeNotifier::CONNECTION_ETHERNET &&
+ current_network_id_.type != NetworkChangeNotifier::CONNECTION_BLUETOOTH) {
+ RecordExternalEstimateProviderMetrics(
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED);
+ external_estimate_provider_->Update();
+ }
// Read any cached estimates for the new network. If cached estimates are
// unavailable, add the default estimates.
@@ -966,13 +976,35 @@ bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() {
return read_cached_estimate;
}
-void NetworkQualityEstimator::OnUpdatedEstimateAvailable() {
+void NetworkQualityEstimator::OnUpdatedEstimateAvailable(
+ const base::TimeDelta& rtt,
+ int32_t downstream_throughput_kbps,
+ int32_t upstream_throughput_kbps) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(external_estimate_provider_);
RecordExternalEstimateProviderMetrics(
EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK);
- QueryExternalEstimateProvider();
+
+ if (rtt > base::TimeDelta()) {
+ RecordExternalEstimateProviderMetrics(
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE);
+ UMA_HISTOGRAM_TIMES("NQE.ExternalEstimateProvider.RTT", rtt);
+ rtt_observations_.AddObservation(
+ RttObservation(rtt, base::TimeTicks::Now(),
+ NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE));
+ }
+
+ if (downstream_throughput_kbps > 0) {
+ RecordExternalEstimateProviderMetrics(
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE);
+ UMA_HISTOGRAM_COUNTS("NQE.ExternalEstimateProvider.DownlinkBandwidth",
+ downstream_throughput_kbps);
+ downstream_throughput_kbps_observations_.AddObservation(
+ ThroughputObservation(
+ downstream_throughput_kbps, base::TimeTicks::Now(),
+ NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE));
+ }
}
const char* NetworkQualityEstimator::GetNameForEffectiveConnectionType(
@@ -999,56 +1031,6 @@ const char* NetworkQualityEstimator::GetNameForEffectiveConnectionType(
return "";
}
-void NetworkQualityEstimator::QueryExternalEstimateProvider() {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- if (!external_estimate_provider_)
- return;
- RecordExternalEstimateProviderMetrics(
- EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED);
-
- base::TimeDelta time_since_last_update;
-
- // Request a new estimate if estimate is not available, or if the available
- // estimate is not fresh.
- if (!external_estimate_provider_->GetTimeSinceLastUpdate(
- &time_since_last_update) ||
- time_since_last_update >
- base::TimeDelta::FromMilliseconds(
- kExternalEstimateProviderFreshnessDurationMsec)) {
- // Request the external estimate provider for updated estimates. When the
- // updates estimates are available, OnUpdatedEstimateAvailable() will be
- // called.
- external_estimate_provider_->Update();
- return;
- }
-
- RecordExternalEstimateProviderMetrics(
- EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL);
- base::TimeDelta rtt;
- if (external_estimate_provider_->GetRTT(&rtt)) {
- RecordExternalEstimateProviderMetrics(
- EXTERNAL_ESTIMATE_PROVIDER_STATUS_RTT_AVAILABLE);
- UMA_HISTOGRAM_TIMES("NQE.ExternalEstimateProvider.RTT", rtt);
- rtt_observations_.AddObservation(
- RttObservation(rtt, base::TimeTicks::Now(),
- NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE));
- }
-
- int32_t downstream_throughput_kbps;
- if (external_estimate_provider_->GetDownstreamThroughputKbps(
- &downstream_throughput_kbps)) {
- RecordExternalEstimateProviderMetrics(
- EXTERNAL_ESTIMATE_PROVIDER_STATUS_DOWNLINK_BANDWIDTH_AVAILABLE);
- UMA_HISTOGRAM_COUNTS("NQE.ExternalEstimateProvider.DownlinkBandwidth",
- downstream_throughput_kbps);
- downstream_throughput_kbps_observations_.AddObservation(
- ThroughputObservation(
- downstream_throughput_kbps, base::TimeTicks::Now(),
- NETWORK_QUALITY_OBSERVATION_SOURCE_EXTERNAL_ESTIMATE));
- }
-}
-
void NetworkQualityEstimator::CacheNetworkQualityEstimate() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_LE(cached_network_qualities_.size(),
« 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