socket_performance_watcher.h 1.7 KB

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