| 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..25f6a340e2d593f9043c928c30f5cb930940e394 100644
|
| --- a/net/base/network_quality_estimator.cc
|
| +++ b/net/base/network_quality_estimator.cc
|
| @@ -19,6 +19,7 @@
|
| #include "net/base/load_flags.h"
|
| #include "net/base/load_timing_info.h"
|
| #include "net/base/network_interfaces.h"
|
| +#include "net/base/network_quality_estimator_watcher_factory.h"
|
| #include "net/base/url_util.h"
|
| #include "net/url_request/url_request.h"
|
| #include "url/gurl.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,
|
| @@ -166,6 +168,10 @@ NetworkQualityEstimator::NetworkQualityEstimator(
|
| }
|
| current_network_id_ = GetCurrentNetworkID();
|
| AddDefaultEstimates();
|
| +
|
| + socket_performance_watcher_factory_.reset(
|
| + new NetworkQualityEstimatorWatcherFactory(
|
| + GetWeakPtr(), base::ThreadTaskRunnerHandle::Get()));
|
| }
|
|
|
| // static
|
| @@ -376,6 +382,13 @@ void NetworkQualityEstimator::RemoveThroughputObserver(
|
| throughput_observer_list_.RemoveObserver(throughput_observer);
|
| }
|
|
|
| +SocketPerformanceWatcherFactory*
|
| +NetworkQualityEstimator::GetSocketPerformanceWatcherFactory() {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| +
|
| + return socket_performance_watcher_factory_.get();
|
| +}
|
| +
|
| void NetworkQualityEstimator::RecordRTTUMA(int32_t estimated_value_msec,
|
| int32_t actual_value_msec) const {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| @@ -886,25 +899,16 @@ void NetworkQualityEstimator::CacheNetworkQualityEstimate() {
|
| static_cast<size_t>(kMaximumNetworkQualityCacheSize));
|
| }
|
|
|
| -scoped_ptr<SocketPerformanceWatcher>
|
| -NetworkQualityEstimator::CreateSocketPerformanceWatcher(
|
| - const Protocol protocol) {
|
| - DCHECK(thread_checker_.CalledOnValidThread());
|
| -
|
| - return scoped_ptr<SocketPerformanceWatcher>(
|
| - new SocketPerformanceWatcher(protocol, this));
|
| -}
|
| -
|
| void NetworkQualityEstimator::OnUpdatedRTTAvailable(
|
| - const Protocol protocol,
|
| + SocketPerformanceWatcherFactory::Protocol protocol,
|
| const base::TimeDelta& rtt) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| switch (protocol) {
|
| - case PROTOCOL_TCP:
|
| + case SocketPerformanceWatcherFactory::PROTOCOL_TCP:
|
| NotifyObserversOfRTT(RttObservation(rtt, base::TimeTicks::Now(), TCP));
|
| return;
|
| - case PROTOCOL_QUIC:
|
| + case SocketPerformanceWatcherFactory::PROTOCOL_QUIC:
|
| NotifyObserversOfRTT(RttObservation(rtt, base::TimeTicks::Now(), QUIC));
|
| return;
|
| default:
|
| @@ -912,6 +916,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 +938,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()),
|
|
|