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

Side by Side Diff: net/base/socket_performance_watcher.h

Issue 1831383002: Add SocketWatcherFactory as a helper class to NQE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, removed cyclic dependency between SPWF and SPW Created 4 years, 8 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/base/network_quality_estimator_unittest.cc ('k') | net/base/socket_performance_watcher.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_BASE_SOCKET_PERFORMANCE_WATCHER_H_ 5 #ifndef NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
6 #define NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_ 6 #define NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
7 7
8 #include <stddef.h>
9
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
8 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/threading/thread_checker.h"
9 #include "net/base/net_export.h" 14 #include "net/base/net_export.h"
10 #include "net/base/socket_performance_watcher_factory.h" 15 #include "net/base/socket_performance_watcher_factory.h"
11 16
12 namespace base { 17 namespace base {
13 class TimeDelta; 18 class TimeDelta;
14 } // namespace base 19 } // namespace base
15 20
16 namespace net { 21 namespace net {
17 22
18 // SocketPerformanceWatcher is the base class for recording and aggregating 23 // SocketPerformanceWatcher is the base class for recording and aggregating
19 // socket statistics. 24 // socket statistics.
20 class NET_EXPORT_PRIVATE SocketPerformanceWatcher { 25 class NET_EXPORT_PRIVATE SocketPerformanceWatcher {
21 public: 26 public:
22 // |socket_performance_watcher_factory| is the factory that constructed 27 typedef base::Callback<void(
23 // |this| watcher. 28 SocketPerformanceWatcherFactory::Protocol protocol,
24 SocketPerformanceWatcher( 29 const base::TimeDelta& rtt)>
25 const SocketPerformanceWatcherFactory::Protocol protocol, 30 RTTCallback;
26 SocketPerformanceWatcherFactory* socket_performance_watcher_factory); 31 typedef base::Callback<void()> ResetCallback;
27 32
28 virtual ~SocketPerformanceWatcher(); 33 // |protocol| is the transport layer protocol of the socket that |this|
34 // SocketPerformanceWatcher is going to watch. |rtt_callback| is invoked when
35 // an updated RTT value is available. |reset_callback| is invoked when the
36 // socket being watched resets.
37 SocketPerformanceWatcher(SocketPerformanceWatcherFactory::Protocol protocol,
38 const RTTCallback& rtt_callback,
39 const ResetCallback& reset_callback);
Ryan Sleevi 2016/04/01 01:38:55 When determining between delegates and callbacks,
40 ~SocketPerformanceWatcher();
29 41
30 // Called when updated transport layer RTT information is available. This 42 // Called when updated transport layer RTT information is available. This
31 // must be the transport layer RTT from this device to the remote transport 43 // must be the transport layer RTT from this device to the remote transport
32 // layer endpoint. This method is called immediately after the observation is 44 // layer endpoint. This method is called immediately after the observation is
33 // made, hence no timestamp. 45 // made, hence no timestamp.
34 void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) const; 46 void OnUpdatedRTTAvailable(const base::TimeDelta& rtt);
47
48 // Returns |true| if the current SocketPerformanceWatcher is interested
49 // in receiving a new RTT estimate (via OnUpdatedRTTAvailable).
50 // Callers may use this to avoid doing expensive work computing the
51 // RTT when the SocketPerformanceWatcher is not interested in such
52 // updates.
53 bool ShouldNotifyUpdatedRTT() const WARN_UNUSED_RESULT;
54
55 // Resets the internal state of this SocketPerformanceWatcher in preparation
56 // for observing a new socket.
57 // Note: The new socket must share the same protocol as the previously
58 // observed socket.
59 void Reset();
35 60
36 private: 61 private:
37 // Transport layer protocol used by the socket that |this| is watching. 62 // Transport layer protocol used by the socket that |this| is watching.
38 const SocketPerformanceWatcherFactory::Protocol protocol_; 63 const SocketPerformanceWatcherFactory::Protocol protocol_;
39 64
40 // |socket_performance_watcher_factory_| is the factory that created 65 // Number of RTT notifications received.
41 // |this| watcher. 66 size_t rtt_notification_received_count_;
42 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; 67
68 RTTCallback rtt_callback_;
69 ResetCallback reset_callback_;
70
71 base::ThreadChecker thread_checker_;
43 72
44 DISALLOW_COPY_AND_ASSIGN(SocketPerformanceWatcher); 73 DISALLOW_COPY_AND_ASSIGN(SocketPerformanceWatcher);
45 }; 74 };
46 75
47 } // namespace net 76 } // namespace net
48 77
49 #endif // NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_ 78 #endif // NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
OLDNEW
« no previous file with comments | « net/base/network_quality_estimator_unittest.cc ('k') | net/base/socket_performance_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698