OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_BASE_NETWORK_QUALITY_ESTIMATOR_WATCHER_FACTORY_H_ | |
6 #define NET_BASE_NETWORK_QUALITY_ESTIMATOR_WATCHER_FACTORY_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "net/base/net_export.h" | |
11 #include "net/base/socket_performance_watcher.h" | |
12 #include "net/base/socket_performance_watcher_factory.h" | |
13 | |
14 namespace base { | |
15 class SingleThreadTaskRunner; | |
16 class TimeDelta; | |
17 } | |
18 | |
19 namespace net { | |
20 | |
21 class NetworkQualityEstimator; | |
22 | |
23 // NetworkQualityEstimatorWatcherFactory implements | |
24 // SocketPerformanceWatcherFactory, and is owned by |NetworkQualityEstimator|. | |
25 // |NetworkQualityEstimatorWatcherFactory| is thread safe. | |
26 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
| |
27 : public SocketPerformanceWatcherFactory { | |
28 public: | |
29 // |network_quality_estimator| owns |this|, and is notified on |task_runner| | |
30 // every time |this| receives a notification from |SocketPerformanceWatcher|. | |
31 NetworkQualityEstimatorWatcherFactory( | |
32 const base::WeakPtr<NetworkQualityEstimator>& network_quality_estimator, | |
33 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | |
34 | |
35 ~NetworkQualityEstimatorWatcherFactory() override; | |
36 | |
37 // SocketPerformanceWatcherFactory implementation: | |
38 scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher( | |
39 const Protocol protocol) override; | |
40 void OnUpdatedRTTAvailable(const Protocol protocol, | |
41 const base::TimeDelta& rtt) override; | |
42 void OnWatcherReset() override; | |
43 | |
44 private: | |
45 // Guaranteed to be non-null since |network_quality_estimator_| owns |this|. | |
46 base::WeakPtr<NetworkQualityEstimator> network_quality_estimator_; | |
47 | |
48 // TaskRunner on which |network_quality_estimator_| should be notified. | |
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorWatcherFactory); | |
52 }; | |
53 | |
54 } // namespace net | |
55 | |
56 #endif // NET_BASE_NETWORK_QUALITY_ESTIMATOR_WATCHER_FACTORY_H_ | |
OLD | NEW |