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

Side by Side Diff: net/nqe/socket_watcher_unittest.cc

Issue 2690113004: Throttle Socket watcher RTT notifications from QUIC (Closed)
Patch Set: Rebased, rch comments 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 unified diff | Download patch
« no previous file with comments | « net/nqe/socket_watcher_factory.cc ('k') | net/quic/chromium/quic_connection_logger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/nqe/socket_watcher.h"
6
7 #include "base/bind.h"
8 #include "base/test/simple_test_tick_clock.h"
9 #include "base/threading/thread_task_runner_handle.h"
10 #include "base/time/time.h"
11 #include "net/socket/socket_performance_watcher.h"
12 #include "net/socket/socket_performance_watcher_factory.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace net {
16
17 namespace nqe {
18
19 namespace internal {
20
21 namespace {
22
23 void OnUpdatedRTTAvailable(SocketPerformanceWatcherFactory::Protocol protocol,
24 const base::TimeDelta& rtt) {}
25
26 // Verify that the buffer size is never exceeded.
27 TEST(NetworkQualitySocketWatcherTest, NotificationsThrottled) {
28 base::SimpleTestTickClock tick_clock;
29 tick_clock.SetNowTicks(base::TimeTicks::Now());
30
31 SocketWatcher socket_watcher(SocketPerformanceWatcherFactory::PROTOCOL_QUIC,
32 base::TimeDelta::FromMilliseconds(2000),
33 base::ThreadTaskRunnerHandle::Get(),
34 base::Bind(OnUpdatedRTTAvailable), &tick_clock);
35
36 EXPECT_TRUE(socket_watcher.ShouldNotifyUpdatedRTT());
37 socket_watcher.OnUpdatedRTTAvailable(base::TimeDelta::FromSeconds(10));
38
39 EXPECT_FALSE(socket_watcher.ShouldNotifyUpdatedRTT());
40
41 tick_clock.Advance(base::TimeDelta::FromMilliseconds(1000));
42 // Minimum interval between consecutive notifications is 2000 msec.
43 EXPECT_FALSE(socket_watcher.ShouldNotifyUpdatedRTT());
44
45 // Advance the clock by 1000 msec more so that the current time is at least
46 // 2000 msec more than the last time |socket_watcher| received a notification.
47 tick_clock.Advance(base::TimeDelta::FromMilliseconds(1000));
48 EXPECT_TRUE(socket_watcher.ShouldNotifyUpdatedRTT());
49 }
50
51 } // namespace
52
53 } // namespace internal
54
55 } // namespace nqe
56
57 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/socket_watcher_factory.cc ('k') | net/quic/chromium/quic_connection_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698