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 |