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

Unified Diff: net/base/socket_performance_watcher.cc

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
Index: net/base/socket_performance_watcher.cc
diff --git a/net/base/socket_performance_watcher.cc b/net/base/socket_performance_watcher.cc
index aa0dab3b03c9476a8d099bde13e15e9b65668850..82f34c7f04f9689d6f8ca5a870981fe5bcd423d4 100644
--- a/net/base/socket_performance_watcher.cc
+++ b/net/base/socket_performance_watcher.cc
@@ -9,12 +9,13 @@
namespace net {
SocketPerformanceWatcher::SocketPerformanceWatcher(
- const SocketPerformanceWatcherFactory::Protocol protocol,
- SocketPerformanceWatcherFactory* socket_performance_watcher_factory)
+ SocketPerformanceWatcherFactory::Protocol protocol,
+ const RTTCallback& rtt_callback,
+ const ResetCallback& reset_callback)
: protocol_(protocol),
- socket_performance_watcher_factory_(socket_performance_watcher_factory) {
- DCHECK(socket_performance_watcher_factory_);
-
+ rtt_notification_received_count_(0),
+ rtt_callback_(rtt_callback),
+ reset_callback_(reset_callback) {
switch (protocol) {
case SocketPerformanceWatcherFactory::PROTOCOL_TCP:
case SocketPerformanceWatcherFactory::PROTOCOL_QUIC:
@@ -27,8 +28,25 @@ SocketPerformanceWatcher::SocketPerformanceWatcher(
SocketPerformanceWatcher::~SocketPerformanceWatcher() {}
void SocketPerformanceWatcher::OnUpdatedRTTAvailable(
- const base::TimeDelta& rtt) const {
- socket_performance_watcher_factory_->OnUpdatedRTTAvailable(protocol_, rtt);
+ const base::TimeDelta& rtt) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ rtt_notification_received_count_++;
+ rtt_callback_.Run(protocol_, rtt);
+}
+
+bool SocketPerformanceWatcher::ShouldNotifyUpdatedRTT() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ // Currently using a small value until crbug.com/590300 is fixed.
+ return rtt_notification_received_count_ < 1;
+}
+
+void SocketPerformanceWatcher::Reset() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ rtt_notification_received_count_ = 0;
+ reset_callback_.Run();
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698