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

Unified Diff: net/base/network_quality_estimator.cc

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix SPW since different sockets may be created on different threads Created 4 years, 9 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 e0a10cfc44ba75d8b21ee95d0a5cb6fa7f4a27bc..8f621fc802e4a86011ff9e3a98ea999a7869dae6 100644
--- a/net/base/network_quality_estimator.cc
+++ b/net/base/network_quality_estimator.cc
@@ -15,6 +15,7 @@
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h"
#include "base/strings/string_number_conversions.h"
+#include "base/thread_task_runner_handle.h"
Ryan Sleevi 2016/03/25 01:45:34 It seems like a bug that you removed this, given l
#include "build/build_config.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
@@ -141,7 +142,8 @@ NetworkQualityEstimator::NetworkQualityEstimator(
downstream_throughput_kbps_observations_(
GetWeightMultiplierPerSecond(variation_params)),
rtt_msec_observations_(GetWeightMultiplierPerSecond(variation_params)),
- external_estimate_provider_(std::move(external_estimates_provider)) {
+ external_estimate_provider_(std::move(external_estimates_provider)),
+ weak_ptr_factory_(this) {
static_assert(kMinRequestDurationMicroseconds > 0,
"Minimum request duration must be > 0");
static_assert(kDefaultHalfLifeSeconds > 0,
@@ -891,8 +893,8 @@ NetworkQualityEstimator::CreateSocketPerformanceWatcher(
const Protocol protocol) {
DCHECK(thread_checker_.CalledOnValidThread());
- return scoped_ptr<SocketPerformanceWatcher>(
- new SocketPerformanceWatcher(protocol, this));
+ return scoped_ptr<SocketPerformanceWatcher>(new SocketPerformanceWatcher(
+ protocol, GetWeakPtr(), base::ThreadTaskRunnerHandle::Get()));
}
void NetworkQualityEstimator::OnUpdatedRTTAvailable(
@@ -912,6 +914,12 @@ void NetworkQualityEstimator::OnUpdatedRTTAvailable(
}
}
+void NetworkQualityEstimator::OnWatcherReset() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ // Nothing needs to be done for RTT observations since NetworkQualityEstimator
+ // does not maintain any watcher-specific state.
+}
+
void NetworkQualityEstimator::NotifyObserversOfRTT(
const RttObservation& observation) {
FOR_EACH_OBSERVER(
@@ -928,6 +936,12 @@ void NetworkQualityEstimator::NotifyObserversOfThroughput(
observation.source));
}
+base::WeakPtr<NetworkQualityEstimator> NetworkQualityEstimator::GetWeakPtr() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ return weak_ptr_factory_.GetWeakPtr();
+}
+
NetworkQualityEstimator::CachedNetworkQuality::CachedNetworkQuality(
const NetworkQuality& network_quality)
: last_update_time_(base::TimeTicks::Now()),

Powered by Google App Engine
This is Rietveld 408576698