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

Unified Diff: net/nqe/socket_watcher.h

Issue 2690113004: Throttle Socket watcher RTT notifications from QUIC (Closed)
Patch Set: ps Created 3 years, 10 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
Index: net/nqe/socket_watcher.h
diff --git a/net/nqe/socket_watcher.h b/net/nqe/socket_watcher.h
index 09b8a39379e7b74c0a2a4a45c63d1b5968cf547c..991f5eef79518d2870ae5dfe861e502c90b1c817 100644
--- a/net/nqe/socket_watcher.h
+++ b/net/nqe/socket_watcher.h
@@ -5,10 +5,15 @@
#ifndef NET_NQE_SOCKET_WATCHER_H_
#define NET_NQE_SOCKET_WATCHER_H_
+#include <memory>
+
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
+#include "base/time/tick_clock.h"
+#include "base/time/time.h"
+#include "net/base/net_export.h"
#include "net/socket/socket_performance_watcher.h"
#include "net/socket/socket_performance_watcher_factory.h"
@@ -30,13 +35,15 @@ namespace nqe {
namespace internal {
// SocketWatcher implements SocketPerformanceWatcher, and is not thread-safe.
-class SocketWatcher : public SocketPerformanceWatcher {
+class NET_EXPORT_PRIVATE SocketWatcher : public SocketPerformanceWatcher {
public:
// Creates a SocketWatcher which can be used to watch a socket that uses
// |protocol| as the transport layer protocol. The socket watcher will call
// |updated_rtt_observation_callback| on |task_runner| every time a new RTT
- // observation is available.
+ // observation is available. |min_notification_interval| is the minimum
+ // interval betweeen consecutive notifications to this socket watcher.
SocketWatcher(SocketPerformanceWatcherFactory::Protocol protocol,
+ base::TimeDelta min_notification_interval,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
OnUpdatedRTTAvailableCallback updated_rtt_observation_callback);
@@ -47,6 +54,8 @@ class SocketWatcher : public SocketPerformanceWatcher {
void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) override;
void OnConnectionChanged() override;
+ void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
+
private:
// Transport layer protocol used by the socket that |this| is watching.
const SocketPerformanceWatcherFactory::Protocol protocol_;
@@ -56,6 +65,14 @@ class SocketWatcher : public SocketPerformanceWatcher {
// Called every time a new RTT observation is available.
OnUpdatedRTTAvailableCallback updated_rtt_observation_callback_;
+ // Minimum interval betweeen consecutive incoming notifications.
+ const base::TimeDelta rtt_notifications_minimum_interval_;
+
+ // Time when this was last notified of updated RTT.
+ base::TimeTicks last_rtt_notification_;
+
+ std::unique_ptr<base::TickClock> tick_clock_;
+
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(SocketWatcher);

Powered by Google App Engine
This is Rietveld 408576698