Index: net/base/network_quality_estimator_watcher_factory.h |
diff --git a/net/base/network_quality_estimator_watcher_factory.h b/net/base/network_quality_estimator_watcher_factory.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d0cf2fbf1a974cc2acb82937a2d33d2cfd7e9648 |
--- /dev/null |
+++ b/net/base/network_quality_estimator_watcher_factory.h |
@@ -0,0 +1,56 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_BASE_NETWORK_QUALITY_ESTIMATOR_WATCHER_FACTORY_H_ |
+#define NET_BASE_NETWORK_QUALITY_ESTIMATOR_WATCHER_FACTORY_H_ |
+ |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "net/base/net_export.h" |
+#include "net/base/socket_performance_watcher.h" |
+#include "net/base/socket_performance_watcher_factory.h" |
+ |
+namespace base { |
+class SingleThreadTaskRunner; |
+class TimeDelta; |
+} |
+ |
+namespace net { |
+ |
+class NetworkQualityEstimator; |
+ |
+// NetworkQualityEstimatorWatcherFactory implements |
+// SocketPerformanceWatcherFactory, and is owned by |NetworkQualityEstimator|. |
+// |NetworkQualityEstimatorWatcherFactory| is thread safe. |
+class NET_EXPORT_PRIVATE NetworkQualityEstimatorWatcherFactory |
Ryan Sleevi
2016/03/25 01:45:34
Why is this a separate class? That is, why isn't i
|
+ : public SocketPerformanceWatcherFactory { |
+ public: |
+ // |network_quality_estimator| owns |this|, and is notified on |task_runner| |
+ // every time |this| receives a notification from |SocketPerformanceWatcher|. |
+ NetworkQualityEstimatorWatcherFactory( |
+ const base::WeakPtr<NetworkQualityEstimator>& network_quality_estimator, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
+ |
+ ~NetworkQualityEstimatorWatcherFactory() override; |
+ |
+ // SocketPerformanceWatcherFactory implementation: |
+ scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher( |
+ const Protocol protocol) override; |
+ void OnUpdatedRTTAvailable(const Protocol protocol, |
+ const base::TimeDelta& rtt) override; |
+ void OnWatcherReset() override; |
+ |
+ private: |
+ // Guaranteed to be non-null since |network_quality_estimator_| owns |this|. |
+ base::WeakPtr<NetworkQualityEstimator> network_quality_estimator_; |
+ |
+ // TaskRunner on which |network_quality_estimator_| should be notified. |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorWatcherFactory); |
+}; |
+ |
+} // namespace net |
+ |
+#endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_WATCHER_FACTORY_H_ |