Chromium Code Reviews| 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" | 8 #include "base/macros.h" |
| 9 #include "base/time/time.h" | |
| 9 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| 10 #include "net/base/socket_performance_watcher_factory.h" | 11 #include "net/base/socket_performance_watcher_factory.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class TimeDelta; | 14 class TimeDelta; |
| 14 } // namespace base | 15 } // namespace base |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 // SocketPerformanceWatcher is the base class for recording and aggregating | 19 // SocketPerformanceWatcher is the base class for recording and aggregating |
| 19 // socket statistics. | 20 // socket statistics. |
| 20 class NET_EXPORT_PRIVATE SocketPerformanceWatcher { | 21 class NET_EXPORT_PRIVATE SocketPerformanceWatcher { |
| 21 public: | 22 public: |
| 22 // |socket_performance_watcher_factory| is the factory that constructed | 23 // |socket_performance_watcher_factory| is the factory that constructed |
| 23 // |this| watcher. | 24 // |this| watcher. |
| 24 SocketPerformanceWatcher( | 25 SocketPerformanceWatcher( |
| 25 const SocketPerformanceWatcherFactory::Protocol protocol, | 26 const SocketPerformanceWatcherFactory::Protocol protocol, |
| 26 SocketPerformanceWatcherFactory* socket_performance_watcher_factory); | 27 SocketPerformanceWatcherFactory* socket_performance_watcher_factory); |
| 27 | 28 |
| 28 virtual ~SocketPerformanceWatcher(); | 29 virtual ~SocketPerformanceWatcher(); |
| 29 | 30 |
| 30 // Called when updated transport layer RTT information is available. This | 31 // Called when updated transport layer RTT information is available. This |
| 31 // must be the transport layer RTT from this device to the remote transport | 32 // 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 | 33 // layer endpoint. This method is called immediately after the observation is |
| 33 // made, hence no timestamp. | 34 // made, hence no timestamp. |
| 34 void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) const; | 35 void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) const; |
| 35 | 36 |
| 37 base::TimeDelta rtt_notification_interval() const { | |
| 38 // TODO(tbansal): TCP/QUIC start with a hard-coded RTT estimate, and | |
| 39 // converge to a more accurate value as more packets are received. This | |
| 40 // function should be changed to return 0 seconds until this connection | |
| 41 // has received 15 packets. Afterwards, it should return 2 seconds. | |
|
Ryan Sleevi
2016/02/25 22:48:46
Why not return this as a "const base::TimeDelta&"
tbansal1
2016/02/26 23:43:34
I think mmenke said at one point that it is okay t
| |
| 42 return rtt_notification_interval_; | |
| 43 } | |
| 44 | |
| 45 // Called when |this| socket performance watcher is reused for establishing a | |
| 46 // new transport layer connection. | |
| 47 void Reset() const; | |
| 48 | |
| 36 private: | 49 private: |
| 37 // Transport layer protocol used by the socket that |this| is watching. | 50 // Transport layer protocol used by the socket that |this| is watching. |
| 38 const SocketPerformanceWatcherFactory::Protocol protocol_; | 51 const SocketPerformanceWatcherFactory::Protocol protocol_; |
| 39 | 52 |
| 53 // Minimum time interval between two successive OnUpdatedRTTAvailable | |
| 54 // notifications to |this|. | |
| 55 const base::TimeDelta rtt_notification_interval_; | |
| 56 | |
| 40 // |socket_performance_watcher_factory_| is the factory that created | 57 // |socket_performance_watcher_factory_| is the factory that created |
| 41 // |this| watcher. | 58 // |this| watcher. |
| 42 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; | 59 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; |
| 43 | 60 |
| 44 DISALLOW_COPY_AND_ASSIGN(SocketPerformanceWatcher); | 61 DISALLOW_COPY_AND_ASSIGN(SocketPerformanceWatcher); |
| 45 }; | 62 }; |
| 46 | 63 |
| 47 } // namespace net | 64 } // namespace net |
| 48 | 65 |
| 49 #endif // NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_ | 66 #endif // NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_ |
| OLD | NEW |