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()), |