Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: net/nqe/socket_watcher_factory.h

Issue 2690113004: Throttle Socket watcher RTT notifications from QUIC (Closed)
Patch Set: Rebased, rch comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/nqe/socket_watcher.cc ('k') | net/nqe/socket_watcher_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_NQE_SOCKET_WATCHER_FACTORY_H_ 5 #ifndef NET_NQE_SOCKET_WATCHER_FACTORY_H_
6 #define NET_NQE_SOCKET_WATCHER_FACTORY_H_ 6 #define NET_NQE_SOCKET_WATCHER_FACTORY_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/time/time.h"
15 #include "net/socket/socket_performance_watcher.h" 16 #include "net/socket/socket_performance_watcher.h"
16 #include "net/socket/socket_performance_watcher_factory.h" 17 #include "net/socket/socket_performance_watcher_factory.h"
17 18
18 namespace base { 19 namespace base {
20 class TickClock;
19 class TimeDelta; 21 class TimeDelta;
20 } // namespace base 22 } // namespace base
21 23
22 namespace net { 24 namespace net {
23 25
24 namespace { 26 namespace {
25 typedef base::Callback<void(SocketPerformanceWatcherFactory::Protocol protocol, 27 typedef base::Callback<void(SocketPerformanceWatcherFactory::Protocol protocol,
26 const base::TimeDelta& rtt)> 28 const base::TimeDelta& rtt)>
27 OnUpdatedRTTAvailableCallback; 29 OnUpdatedRTTAvailableCallback;
28 } 30 }
29 31
30 namespace nqe { 32 namespace nqe {
31 33
32 namespace internal { 34 namespace internal {
33 35
34 // SocketWatcherFactory implements SocketPerformanceWatcherFactory. 36 // SocketWatcherFactory implements SocketPerformanceWatcherFactory.
35 // SocketWatcherFactory is thread safe. 37 // SocketWatcherFactory is thread safe.
36 class SocketWatcherFactory : public SocketPerformanceWatcherFactory { 38 class SocketWatcherFactory : public SocketPerformanceWatcherFactory {
37 public: 39 public:
38 // Creates a SocketWatcherFactory. All socket watchers created by 40 // Creates a SocketWatcherFactory. All socket watchers created by
39 // SocketWatcherFactory call |updated_rtt_observation_callback| on 41 // SocketWatcherFactory call |updated_rtt_observation_callback| on
40 // |task_runner| every time a new RTT observation is available. 42 // |task_runner| every time a new RTT observation is available.
43 // |min_notification_interval| is the minimum interval betweeen consecutive
44 // notifications to the socket watchers created by this factory. |tick_clock|
45 // is guaranteed to be non-null.
41 SocketWatcherFactory( 46 SocketWatcherFactory(
42 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 47 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
43 OnUpdatedRTTAvailableCallback updated_rtt_observation_callback); 48 base::TimeDelta min_notification_interval,
49 OnUpdatedRTTAvailableCallback updated_rtt_observation_callback,
50 base::TickClock* tick_clock);
44 51
45 ~SocketWatcherFactory() override; 52 ~SocketWatcherFactory() override;
46 53
47 // SocketPerformanceWatcherFactory implementation: 54 // SocketPerformanceWatcherFactory implementation:
48 std::unique_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher( 55 std::unique_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher(
49 const Protocol protocol) override; 56 const Protocol protocol) override;
50 57
51 private: 58 private:
52 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 59 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
53 60
61 // Minimum interval betweeen consecutive notifications to the socket watchers
62 // created by this factory.
63 const base::TimeDelta min_notification_interval_;
64
54 // Called every time a new RTT observation is available. 65 // Called every time a new RTT observation is available.
55 OnUpdatedRTTAvailableCallback updated_rtt_observation_callback_; 66 OnUpdatedRTTAvailableCallback updated_rtt_observation_callback_;
56 67
68 base::TickClock* tick_clock_;
69
57 DISALLOW_COPY_AND_ASSIGN(SocketWatcherFactory); 70 DISALLOW_COPY_AND_ASSIGN(SocketWatcherFactory);
58 }; 71 };
59 72
60 } // namespace internal 73 } // namespace internal
61 74
62 } // namespace nqe 75 } // namespace nqe
63 76
64 } // namespace net 77 } // namespace net
65 78
66 #endif // NET_NQE_SOCKET_WATCHER_FACTORY_H_ 79 #endif // NET_NQE_SOCKET_WATCHER_FACTORY_H_
OLDNEW
« no previous file with comments | « net/nqe/socket_watcher.cc ('k') | net/nqe/socket_watcher_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698