Chromium Code Reviews| Index: net/base/network_quality_estimator.h |
| diff --git a/net/base/network_quality_estimator.h b/net/base/network_quality_estimator.h |
| index 9fa0ad1817604c0472f8e5bafb9f78b619cfe477..b847c95f6005c41c83f4edf5bac13fa402a66809 100644 |
| --- a/net/base/network_quality_estimator.h |
| +++ b/net/base/network_quality_estimator.h |
| @@ -17,6 +17,7 @@ |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/observer_list.h" |
| #include "base/threading/thread_checker.h" |
| #include "base/time/time.h" |
| @@ -28,6 +29,7 @@ |
| namespace net { |
| +class NetworkQualityEstimatorWatcherFactory; |
| class URLRequest; |
| // NetworkQualityEstimator provides network quality estimates (quality of the |
| @@ -40,8 +42,7 @@ class URLRequest; |
| // observed traffic characteristics. |
| class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| : public NetworkChangeNotifier::ConnectionTypeObserver, |
| - public ExternalEstimateProvider::UpdatedEstimateDelegate, |
| - public SocketPerformanceWatcherFactory { |
| + public ExternalEstimateProvider::UpdatedEstimateDelegate { |
| public: |
| // On Android, a Java counterpart will be generated for this enum. |
| // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net |
| @@ -161,12 +162,6 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| const base::TimeTicks& begin_timestamp, |
| int32_t* kbps) const; |
| - // SocketPerformanceWatcherFactory implementation: |
| - scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher( |
| - const Protocol protocol) override; |
| - void OnUpdatedRTTAvailable(const Protocol protocol, |
| - const base::TimeDelta& rtt) override; |
| - |
| // Adds |rtt_observer| to the list of round trip time observers. Must be |
| // called on the IO thread. |
| void AddRTTObserver(RTTObserver* rtt_observer); |
| @@ -183,6 +178,9 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| // is on the list of observers. Must be called on the IO thread. |
| void RemoveThroughputObserver(ThroughputObserver* throughput_observer); |
| + // Virtualized for testing. |
| + virtual SocketPerformanceWatcherFactory* GetSocketPerformanceWatcherFactory(); |
| + |
| protected: |
| // NetworkID is used to uniquely identify a network. |
| // For the purpose of network quality estimation and caching, a network is |
| @@ -231,7 +229,15 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| // ExternalEstimateProvider::UpdatedEstimateObserver implementation. |
| void OnUpdatedEstimateAvailable() override; |
| + // Called by |socket_performance_watcher_factory_| every time it receives a |
| + // notification from a socket performance watcher. |
|
Ryan Sleevi
2016/03/25 01:45:34
This comment is leaking the abstraction details in
|
| + void OnUpdatedRTTAvailable(SocketPerformanceWatcherFactory::Protocol protocol, |
| + const base::TimeDelta& rtt); |
| + void OnWatcherReset(); |
| + |
| private: |
| + // Allows |NetworkQualityEstimatorWatcherFactory| to call protected functions. |
|
Ryan Sleevi
2016/03/25 01:45:34
You can drop this comment. Per https://google.gith
|
| + friend class NetworkQualityEstimatorWatcherFactory; |
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations); |
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestKbpsRTTUpdates); |
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation); |
| @@ -252,6 +258,7 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, |
| TestExternalEstimateProviderMergeEstimates); |
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestObservers); |
| + FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestTcpSocketRtt); |
| // NetworkQuality is used to cache the quality of a network connection. |
| class NET_EXPORT_PRIVATE NetworkQuality { |
| @@ -520,6 +527,9 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| void NotifyObserversOfThroughput(const ThroughputObservation& observation); |
| + // For use by SocketPerformanceWatcher. |
| + base::WeakPtr<NetworkQualityEstimator> GetWeakPtr(); |
| + |
| // Records the UMA related to RTT. |
| void RecordRTTUMA(int32_t estimated_value_msec, |
| int32_t actual_value_msec) const; |
| @@ -595,8 +605,13 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| base::ObserverList<RTTObserver> rtt_observer_list_; |
| base::ObserverList<ThroughputObserver> throughput_observer_list_; |
| + scoped_ptr<SocketPerformanceWatcherFactory> |
| + socket_performance_watcher_factory_; |
| + |
| base::ThreadChecker thread_checker_; |
| + base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| }; |