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

Unified Diff: net/base/network_quality_estimator.cc

Issue 1316863006: Populate EEP estimate in NQE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix Created 5 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/base/network_quality_estimator.cc
diff --git a/net/base/network_quality_estimator.cc b/net/base/network_quality_estimator.cc
index fdd2212adfb1b4c4853d6be76456ce0e990ef8a7..c5cc320e94e5f9c9b630c0bbf9cbc91d22729c09 100644
--- a/net/base/network_quality_estimator.cc
+++ b/net/base/network_quality_estimator.cc
@@ -10,10 +10,13 @@
#include <limits>
#include <vector>
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h"
#include "base/strings/string_number_conversions.h"
+#include "base/task_runner.h"
#include "build/build_config.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
@@ -140,7 +143,10 @@ NetworkQualityEstimator::NetworkQualityEstimator(
downstream_throughput_kbps_observations_(
GetWeightMultiplierPerSecond(variation_params)),
rtt_msec_observations_(GetWeightMultiplierPerSecond(variation_params)),
- external_estimates_provider_(external_estimates_provider.Pass()) {
+ external_estimates_provider_(external_estimates_provider.Pass()),
+ eep_queried_(base::TimeTicks()),
bengr 2015/09/02 20:27:56 Don't use eep.
tbansal1 2015/09/03 00:22:40 Done.
+ eep_delayed_task_posted_(false),
+ weak_factory_(this) {
static_assert(kMinRequestDurationMicroseconds > 0,
"Minimum request duration must be > 0");
static_assert(kDefaultHalfLifeSeconds > 0,
@@ -154,8 +160,17 @@ NetworkQualityEstimator::NetworkQualityEstimator(
ObtainOperatingParams(variation_params);
NetworkChangeNotifier::AddConnectionTypeObserver(this);
- if (external_estimates_provider_)
+ if (external_estimates_provider_) {
+ UMA_HISTOGRAM_ENUMERATION("NQE.ExternalEstimateProviderStatus",
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_AVAILABLE,
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY);
external_estimates_provider_->SetUpdatedEstimateDelegate(this);
+ QueryExternalEstimateProvider();
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("NQE.ExternalEstimateProviderStatus",
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_NOT_AVAILABLE,
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY);
+ }
current_network_id_ = GetCurrentNetworkID();
AddDefaultEstimates();
}
@@ -774,8 +789,66 @@ bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() {
void NetworkQualityEstimator::OnUpdatedEstimateAvailable() {
DCHECK(thread_checker_.CalledOnValidThread());
+
+ UMA_HISTOGRAM_ENUMERATION("NQE.ExternalEstimateProviderStatus",
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_CALLBACK,
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY);
+
+ QueryExternalEstimateProvider();
+}
+
+void NetworkQualityEstimator::QueryExternalEstimateProvider() {
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(external_estimates_provider_);
- // TODO(tbansal): Query provider for the recent value.
+
+ UMA_HISTOGRAM_ENUMERATION("NQE.ExternalEstimateProviderStatus",
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERIED,
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY);
+
+ base::TimeDelta time_since_last_update;
+ if (!external_estimates_provider_->GetTimeSinceLastUpdate(
bengr 2015/09/02 20:27:56 external_estimate_provider_?
tbansal1 2015/09/03 00:22:40 Done.
+ &time_since_last_update)) {
+ external_estimates_provider_->RequestUpdate();
+ return;
+ }
+
+ eep_queried_ = base::TimeTicks::Now();
bengr 2015/09/02 20:27:56 external_estimate_request_time_. Also, is this use
tbansal1 2015/09/03 00:22:40 It is used now.
+
+ UMA_HISTOGRAM_ENUMERATION("NQE.ExternalEstimateProviderStatus",
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_QUERY_SUCCESSFUL,
+ EXTERNAL_ESTIMATE_PROVIDER_STATUS_BOUNDARY);
+
+ base::TimeDelta rtt;
+ if (external_estimates_provider_->GetRTT(&rtt)) {
+ rtt_msec_observations_.AddObservation(Observation(
+ rtt.InMilliseconds(), base::TimeTicks::Now() - time_since_last_update));
+ }
+
+ int32_t downstream_throughput_kbps;
+ if (external_estimates_provider_->GetDownstreamThroughputKbps(
+ &downstream_throughput_kbps)) {
+ downstream_throughput_kbps_observations_.AddObservation(
+ Observation(downstream_throughput_kbps,
+ base::TimeTicks::Now() - time_since_last_update));
+ }
+
+ if (!eep_delayed_task_posted_ && base::MessageLoop::current()) {
bengr 2015/09/02 20:27:56 eep_delayed_task_posted_ -> external_estimate_pend
tbansal1 2015/09/03 00:22:40 Done.
+ base::MessageLoop::current()->task_runner()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(
+ &NetworkQualityEstimator::RunExternalEstimateProviderDelayedTask,
+ weak_factory_.GetWeakPtr()),
+ base::TimeDelta::FromMilliseconds(
+ kExternalEstimateProviderQueryIntervalMsec));
+ eep_delayed_task_posted_ = true;
+ }
+}
+
+void NetworkQualityEstimator::RunExternalEstimateProviderDelayedTask() {
bengr 2015/09/02 20:27:56 I don't understand the flow. Here's what I underst
tbansal1 2015/09/03 00:22:40 Updated to make it synchronous call. No posting of
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(eep_delayed_task_posted_);
+ eep_delayed_task_posted_ = false;
+ QueryExternalEstimateProvider();
}
void NetworkQualityEstimator::CacheNetworkQualityEstimate() {

Powered by Google App Engine
This is Rietveld 408576698