OLD | NEW |
---|---|
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 rtt_notification_received_count_(0), | |
15 socket_performance_watcher_factory_(socket_performance_watcher_factory) { | 16 socket_performance_watcher_factory_(socket_performance_watcher_factory) { |
16 DCHECK(socket_performance_watcher_factory_); | 17 DCHECK(socket_performance_watcher_factory_); |
17 | 18 |
18 switch (protocol) { | 19 switch (protocol) { |
19 case SocketPerformanceWatcherFactory::PROTOCOL_TCP: | 20 case SocketPerformanceWatcherFactory::PROTOCOL_TCP: |
20 case SocketPerformanceWatcherFactory::PROTOCOL_QUIC: | 21 case SocketPerformanceWatcherFactory::PROTOCOL_QUIC: |
21 return; | 22 return; |
22 default: | 23 default: |
23 NOTREACHED(); | 24 NOTREACHED(); |
24 } | 25 } |
25 } | 26 } |
26 | 27 |
27 SocketPerformanceWatcher::~SocketPerformanceWatcher() {} | 28 SocketPerformanceWatcher::~SocketPerformanceWatcher() {} |
28 | 29 |
29 void SocketPerformanceWatcher::OnUpdatedRTTAvailable( | 30 void SocketPerformanceWatcher::OnUpdatedRTTAvailable( |
30 const base::TimeDelta& rtt) const { | 31 const base::TimeDelta& rtt) { |
32 rtt_notification_received_count_++; | |
31 socket_performance_watcher_factory_->OnUpdatedRTTAvailable(protocol_, rtt); | 33 socket_performance_watcher_factory_->OnUpdatedRTTAvailable(protocol_, rtt); |
32 } | 34 } |
33 | 35 |
36 bool SocketPerformanceWatcher::ShouldNotifyUpdatedRTT() const { | |
37 // Currently using a small value until crbug.com/590300 is fixed. | |
bengr
2016/03/09 17:58:04
Could you elaborate in this comment?
tbansal1
2016/03/09 19:13:11
Done.
| |
38 return rtt_notification_received_count_ < 1; | |
39 } | |
40 | |
41 void SocketPerformanceWatcher::Reset() { | |
42 rtt_notification_received_count_ = 0; | |
43 socket_performance_watcher_factory_->OnWatcherReset(); | |
44 } | |
45 | |
34 } // namespace net | 46 } // namespace net |
OLD | NEW |