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

Side by Side Diff: base/test/test_mock_time_task_runner.h

Issue 1575623002: Disable Web Notifications in Incognito (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permfix
Patch Set: No Profile* in WebsiteSettingsPopupView Created 4 years, 11 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 #ifndef BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ 5 #ifndef BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_
6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ 6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // - Tasks aren't guaranteed to be destroyed immediately after they're run. 43 // - Tasks aren't guaranteed to be destroyed immediately after they're run.
44 // 44 //
45 // This is a slightly more sophisticated version of TestSimpleTaskRunner, in 45 // This is a slightly more sophisticated version of TestSimpleTaskRunner, in
46 // that it supports running delayed tasks in the correct temporal order. 46 // that it supports running delayed tasks in the correct temporal order.
47 class TestMockTimeTaskRunner : public SingleThreadTaskRunner { 47 class TestMockTimeTaskRunner : public SingleThreadTaskRunner {
48 public: 48 public:
49 // Constructs an instance whose virtual time will start at the Unix epoch, and 49 // Constructs an instance whose virtual time will start at the Unix epoch, and
50 // whose time ticks will start at zero. 50 // whose time ticks will start at zero.
51 TestMockTimeTaskRunner(); 51 TestMockTimeTaskRunner();
52 52
53 // Constructs an instance starting at the given virtual time and time ticks.
54 TestMockTimeTaskRunner(Time start_time, TimeTicks start_ticks);
55
53 // Fast-forwards virtual time by |delta|, causing all tasks with a remaining 56 // Fast-forwards virtual time by |delta|, causing all tasks with a remaining
54 // delay less than or equal to |delta| to be executed. |delta| must be 57 // delay less than or equal to |delta| to be executed. |delta| must be
55 // non-negative. 58 // non-negative.
56 void FastForwardBy(TimeDelta delta); 59 void FastForwardBy(TimeDelta delta);
57 60
58 // Fast-forwards virtual time just until all tasks are executed. 61 // Fast-forwards virtual time just until all tasks are executed.
59 void FastForwardUntilNoTasksRemain(); 62 void FastForwardUntilNoTasksRemain();
60 63
61 // Executes all tasks that have no remaining delay. Tasks with a remaining 64 // Executes all tasks that have no remaining delay. Tasks with a remaining
62 // delay greater than zero will remain enqueued, and no virtual time will 65 // delay greater than zero will remain enqueued, and no virtual time will
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 size_t next_task_ordinal_; 161 size_t next_task_ordinal_;
159 162
160 Lock tasks_lock_; 163 Lock tasks_lock_;
161 164
162 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); 165 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner);
163 }; 166 };
164 167
165 } // namespace base 168 } // namespace base
166 169
167 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ 170 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698