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

Unified 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, 9 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/socket_performance_watcher.h
diff --git a/net/base/socket_performance_watcher.h b/net/base/socket_performance_watcher.h
index e0e76327ce63541e8d0dc2ba23215d34f953df41..892f2c02ff0e0cc55cfc7f9f76ac7c3816b3922f 100644
--- a/net/base/socket_performance_watcher.h
+++ b/net/base/socket_performance_watcher.h
@@ -5,7 +5,12 @@
#ifndef NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
#define NET_BASE_SOCKET_PERFORMANCE_WATCHER_H_
+#include <stddef.h>
+
+#include "base/callback.h"
+#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/threading/thread_checker.h"
#include "net/base/net_export.h"
#include "net/base/socket_performance_watcher_factory.h"
@@ -19,27 +24,51 @@ namespace net {
// socket statistics.
class NET_EXPORT_PRIVATE SocketPerformanceWatcher {
public:
- // |socket_performance_watcher_factory| is the factory that constructed
- // |this| watcher.
- SocketPerformanceWatcher(
- const SocketPerformanceWatcherFactory::Protocol protocol,
- SocketPerformanceWatcherFactory* socket_performance_watcher_factory);
+ typedef base::Callback<void(
+ SocketPerformanceWatcherFactory::Protocol protocol,
+ const base::TimeDelta& rtt)>
+ RTTCallback;
+ typedef base::Callback<void()> ResetCallback;
- virtual ~SocketPerformanceWatcher();
+ // |protocol| is the transport layer protocol of the socket that |this|
+ // SocketPerformanceWatcher is going to watch. |rtt_callback| is invoked when
+ // an updated RTT value is available. |reset_callback| is invoked when the
+ // socket being watched resets.
+ SocketPerformanceWatcher(SocketPerformanceWatcherFactory::Protocol protocol,
+ const RTTCallback& rtt_callback,
+ const ResetCallback& reset_callback);
Ryan Sleevi 2016/04/01 01:38:55 When determining between delegates and callbacks,
+ ~SocketPerformanceWatcher();
// Called when updated transport layer RTT information is available. This
// must be the transport layer RTT from this device to the remote transport
// layer endpoint. This method is called immediately after the observation is
// made, hence no timestamp.
- void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) const;
+ void OnUpdatedRTTAvailable(const base::TimeDelta& rtt);
+
+ // Returns |true| if the current SocketPerformanceWatcher is interested
+ // in receiving a new RTT estimate (via OnUpdatedRTTAvailable).
+ // Callers may use this to avoid doing expensive work computing the
+ // RTT when the SocketPerformanceWatcher is not interested in such
+ // updates.
+ bool ShouldNotifyUpdatedRTT() const WARN_UNUSED_RESULT;
+
+ // Resets the internal state of this SocketPerformanceWatcher in preparation
+ // for observing a new socket.
+ // Note: The new socket must share the same protocol as the previously
+ // observed socket.
+ void Reset();
private:
// Transport layer protocol used by the socket that |this| is watching.
const SocketPerformanceWatcherFactory::Protocol protocol_;
- // |socket_performance_watcher_factory_| is the factory that created
- // |this| watcher.
- SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
+ // Number of RTT notifications received.
+ size_t rtt_notification_received_count_;
+
+ RTTCallback rtt_callback_;
+ ResetCallback reset_callback_;
+
+ base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(SocketPerformanceWatcher);
};
« 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