| OLD | NEW |
| 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 "base/macros.h" | |
| 9 #include "net/base/net_export.h" | 8 #include "net/base/net_export.h" |
| 10 #include "net/base/socket_performance_watcher_factory.h" | |
| 11 | 9 |
| 12 namespace base { | 10 namespace base { |
| 13 class TimeDelta; | 11 class TimeDelta; |
| 14 } // namespace base | 12 } // namespace base |
| 15 | 13 |
| 16 namespace net { | 14 namespace net { |
| 17 | 15 |
| 18 // SocketPerformanceWatcher is the base class for recording and aggregating | 16 // SocketPerformanceWatcher is the base class for recording and aggregating |
| 19 // socket statistics. | 17 // per-socket statistics. SocketPerformanceWatcher must be used on a single |
| 18 // thread. |
| 20 class NET_EXPORT_PRIVATE SocketPerformanceWatcher { | 19 class NET_EXPORT_PRIVATE SocketPerformanceWatcher { |
| 21 public: | 20 public: |
| 22 // |socket_performance_watcher_factory| is the factory that constructed | 21 virtual ~SocketPerformanceWatcher() {} |
| 23 // |this| watcher. | |
| 24 SocketPerformanceWatcher( | |
| 25 const SocketPerformanceWatcherFactory::Protocol protocol, | |
| 26 SocketPerformanceWatcherFactory* socket_performance_watcher_factory); | |
| 27 | 22 |
| 28 virtual ~SocketPerformanceWatcher(); | 23 // Returns true if |this| SocketPerformanceWatcher is interested in receiving |
| 24 // an updated RTT estimate (via OnUpdatedRTTAvailable). |
| 25 virtual bool ShouldNotifyUpdatedRTT() const = 0; |
| 29 | 26 |
| 30 // Called when updated transport layer RTT information is available. This | 27 // Notifies |this| SocketPerformanceWatcher of updated transport layer RTT |
| 31 // must be the transport layer RTT from this device to the remote transport | 28 // from this device to the remote transport layer endpoint. This method is |
| 32 // layer endpoint. This method is called immediately after the observation is | 29 // called immediately after the observation is made, hence no timestamp. |
| 33 // made, hence no timestamp. | 30 // There is no guarantee that OnUpdatedRTTAvailable will be called every time |
| 34 void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) const; | 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; |
| 35 | 34 |
| 36 private: | 35 // Notifies that |this| watcher will be reused to watch a socket that belongs |
| 37 // Transport layer protocol used by the socket that |this| is watching. | 36 // to a different transport layer connection. Note: The new connection shares |
| 38 const SocketPerformanceWatcherFactory::Protocol protocol_; | 37 // the same protocol as the previously watched socket. |
| 39 | 38 virtual void OnConnectionChanged() = 0; |
| 40 // |socket_performance_watcher_factory_| is the factory that created | |
| 41 // |this| watcher. | |
| 42 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(SocketPerformanceWatcher); | |
| 45 }; | 39 }; |
| 46 | 40 |
| 47 } // namespace net | 41 } // namespace net |
| 48 | 42 |
| 49 #endif // NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_ | 43 #endif // NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_ |
| OLD | NEW |