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

Side by Side Diff: net/base/socket_performance_watcher.cc

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed rsleevi comments, using ScopedTracker, added tests for 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/socket_performance_watcher.h" 5 #include "net/base/socket_performance_watcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 SocketPerformanceWatcher::SocketPerformanceWatcher( 11 SocketPerformanceWatcher::SocketPerformanceWatcher(
12 const SocketPerformanceWatcherFactory::Protocol protocol, 12 const SocketPerformanceWatcherFactory::Protocol protocol,
13 SocketPerformanceWatcherFactory* socket_performance_watcher_factory) 13 SocketPerformanceWatcherFactory* socket_performance_watcher_factory)
14 : protocol_(protocol), 14 : protocol_(protocol),
15 // Currently using a large value until crbug.com/590300 is fixed.
16 rtt_notification_interval_(base::TimeDelta::FromHours(10)),
15 socket_performance_watcher_factory_(socket_performance_watcher_factory) { 17 socket_performance_watcher_factory_(socket_performance_watcher_factory) {
16 DCHECK(socket_performance_watcher_factory_); 18 DCHECK(socket_performance_watcher_factory_);
17 19
18 switch (protocol) { 20 switch (protocol) {
19 case SocketPerformanceWatcherFactory::PROTOCOL_TCP: 21 case SocketPerformanceWatcherFactory::PROTOCOL_TCP:
20 case SocketPerformanceWatcherFactory::PROTOCOL_QUIC: 22 case SocketPerformanceWatcherFactory::PROTOCOL_QUIC:
21 return; 23 return;
22 default: 24 default:
23 NOTREACHED(); 25 NOTREACHED();
24 } 26 }
25 } 27 }
26 28
27 SocketPerformanceWatcher::~SocketPerformanceWatcher() {} 29 SocketPerformanceWatcher::~SocketPerformanceWatcher() {}
28 30
29 void SocketPerformanceWatcher::OnUpdatedRTTAvailable( 31 void SocketPerformanceWatcher::OnUpdatedRTTAvailable(
30 const base::TimeDelta& rtt) const { 32 const base::TimeDelta& rtt) {
33 last_rtt_notification_ = base::TimeTicks::Now();
31 socket_performance_watcher_factory_->OnUpdatedRTTAvailable(protocol_, rtt); 34 socket_performance_watcher_factory_->OnUpdatedRTTAvailable(protocol_, rtt);
32 } 35 }
33 36
37 bool SocketPerformanceWatcher::CanNotifyRTT() const {
38 return base::TimeTicks::Now() - last_rtt_notification_ >=
39 rtt_notification_interval_;
40 }
41
42 void SocketPerformanceWatcher::Reset() const {
Ryan Sleevi 2016/03/02 19:56:57 Shouldn't you also reset last_rtt_notification_ to
tbansal1 2016/03/03 02:09:08 I was going to replace last_rtt_notification_ with
43 socket_performance_watcher_factory_->OnWatcherReset();
44 }
45
34 } // namespace net 46 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698