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

Unified Diff: net/nqe/socket_watcher.cc

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.cc
diff --git a/net/nqe/socket_watcher.cc b/net/nqe/socket_watcher.cc
index d03b98ecf8193a91fefb449d766b7fa352e4b61b..2e35b59cd5255d536ecd6a18455f14a16b66f580 100644
--- a/net/nqe/socket_watcher.cc
+++ b/net/nqe/socket_watcher.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
+#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
namespace net {
@@ -17,23 +18,31 @@ namespace internal {
SocketWatcher::SocketWatcher(
SocketPerformanceWatcherFactory::Protocol protocol,
+ base::TimeDelta min_notification_interval,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
OnUpdatedRTTAvailableCallback updated_rtt_observation_callback)
: protocol_(protocol),
task_runner_(std::move(task_runner)),
- updated_rtt_observation_callback_(updated_rtt_observation_callback) {}
+ updated_rtt_observation_callback_(updated_rtt_observation_callback),
+ rtt_notifications_minimum_interval_(min_notification_interval),
+ tick_clock_(new base::DefaultTickClock()) {}
SocketWatcher::~SocketWatcher() {}
bool SocketWatcher::ShouldNotifyUpdatedRTT() const {
DCHECK(thread_checker_.CalledOnValidThread());
- return true;
+ // Do not allow incoming notifications if the last notification was recent
RyanSturm 2017/02/15 17:42:08 nit:s/was recent than/was more recent than/
tbansal1 2017/02/15 20:37:42 Done.
+ // than |rtt_notifications_minimum_interval_| ago. This helps in reducing the
+ // overhead of obtaining the RTT values.
+ return tick_clock_->NowTicks() - last_rtt_notification_ >=
+ rtt_notifications_minimum_interval_;
}
void SocketWatcher::OnUpdatedRTTAvailable(const base::TimeDelta& rtt) {
DCHECK(thread_checker_.CalledOnValidThread());
+ last_rtt_notification_ = tick_clock_->NowTicks();
task_runner_->PostTask(
FROM_HERE, base::Bind(updated_rtt_observation_callback_, protocol_, rtt));
}
@@ -42,6 +51,13 @@ void SocketWatcher::OnConnectionChanged() {
DCHECK(thread_checker_.CalledOnValidThread());
}
+void SocketWatcher::SetTickClockForTesting(
+ std::unique_ptr<base::TickClock> tick_clock) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ tick_clock_ = std::move(tick_clock);
+}
+
} // namespace internal
} // namespace nqe

Powered by Google App Engine
This is Rietveld 408576698