tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
tbansal | ca83c00 | 2016-04-28 20:56:28 | [diff] [blame] | 5 | #ifndef NET_SOCKET_SOCKET_PERFORMANCE_WATCHER_H_ |
| 6 | #define NET_SOCKET_SOCKET_PERFORMANCE_WATCHER_H_ |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 7 | |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 8 | #include "net/base/net_export.h" |
| 9 | |
| 10 | namespace base { |
| 11 | class TimeDelta; |
| 12 | } // namespace base |
| 13 | |
| 14 | namespace net { |
| 15 | |
| 16 | // SocketPerformanceWatcher is the base class for recording and aggregating |
tbansal | 0f56a39a | 2016-04-07 22:03:38 | [diff] [blame] | 17 | // per-socket statistics. SocketPerformanceWatcher must be used on a single |
| 18 | // thread. |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 19 | class NET_EXPORT_PRIVATE SocketPerformanceWatcher { |
| 20 | public: |
tbansal | 0f56a39a | 2016-04-07 22:03:38 | [diff] [blame] | 21 | virtual ~SocketPerformanceWatcher() {} |
tbansal | c8a94ea | 2015-11-02 23:58:51 | [diff] [blame] | 22 | |
tbansal | 0f56a39a | 2016-04-07 22:03:38 | [diff] [blame] | 23 | // Returns true if |this| SocketPerformanceWatcher is interested in receiving |
| 24 | // an updated RTT estimate (via OnUpdatedRTTAvailable). |
| 25 | virtual bool ShouldNotifyUpdatedRTT() const = 0; |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 26 | |
tbansal | 0f56a39a | 2016-04-07 22:03:38 | [diff] [blame] | 27 | // Notifies |this| SocketPerformanceWatcher of updated transport layer RTT |
| 28 | // from this device to the remote transport layer endpoint. This method is |
| 29 | // called immediately after the observation is made, hence no timestamp. |
| 30 | // There is no guarantee that OnUpdatedRTTAvailable will be called every time |
| 31 | // an updated RTT is available as the socket may throttle the |
| 32 | // OnUpdatedRTTAvailable call for various reasons, including performance. |
| 33 | virtual void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) = 0; |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 34 | |
tbansal | 0f56a39a | 2016-04-07 22:03:38 | [diff] [blame] | 35 | // Notifies that |this| watcher will be reused to watch a socket that belongs |
| 36 | // to a different transport layer connection. Note: The new connection shares |
| 37 | // the same protocol as the previously watched socket. |
| 38 | virtual void OnConnectionChanged() = 0; |
tbansal | ba8f411 | 2015-09-03 21:57:19 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | } // namespace net |
| 42 | |
tbansal | ca83c00 | 2016-04-28 20:56:28 | [diff] [blame] | 43 | #endif // NET_SOCKET_SOCKET_PERFORMANCE_WATCHER_H_ |