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 #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 <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // | 26 // |
27 // TestMockTimeTaskRunner has the following properties: | 27 // TestMockTimeTaskRunner has the following properties: |
28 // | 28 // |
29 // - Methods RunsTasksOnCurrentThread() and Post[Delayed]Task() can be called | 29 // - Methods RunsTasksOnCurrentThread() and Post[Delayed]Task() can be called |
30 // from any thread, but the rest of the methods must be called on the same | 30 // from any thread, but the rest of the methods must be called on the same |
31 // thread the TaskRunner was created on. | 31 // thread the TaskRunner was created on. |
32 // - It allows for reentrancy, in that it handles the running of tasks that in | 32 // - It allows for reentrancy, in that it handles the running of tasks that in |
33 // turn call back into it (e.g., to post more tasks). | 33 // turn call back into it (e.g., to post more tasks). |
34 // - Tasks are stored in a priority queue, and executed in the increasing | 34 // - Tasks are stored in a priority queue, and executed in the increasing |
35 // order of post time + delay. | 35 // order of post time + delay. |
36 // - It does not check for overflow when doing time arithmetic``. A sufficient | 36 // - It does not check for overflow when doing time arithmetic. A sufficient |
37 // condition for preventing overflows is to make sure that the sum of all | 37 // condition for preventing overflows is to make sure that the sum of all |
38 // posted task delays and fast-forward increments is still representable by | 38 // posted task delays and fast-forward increments is still representable by |
39 // a TimeDelta, and that adding this delta to the starting values of Time | 39 // a TimeDelta, and that adding this delta to the starting values of Time |
40 // and TickTime is still within their respective range. | 40 // and TickTime is still within their respective range. |
41 // - Non-nestable tasks are not supported. | 41 // - Non-nestable tasks are not supported. |
42 // - Tasks aren't guaranteed to be destroyed immediately after they're run. | 42 // - Tasks aren't guaranteed to be destroyed immediately after they're run. |
43 // | 43 // |
44 // This is a slightly more sophisticated version of TestSimpleTaskRunner, in | 44 // This is a slightly more sophisticated version of TestSimpleTaskRunner, in |
45 // that it supports running delayed tasks in the correct temporal order. | 45 // that it supports running delayed tasks in the correct temporal order. |
46 class TestMockTimeTaskRunner : public SingleThreadTaskRunner { | 46 class TestMockTimeTaskRunner : public SingleThreadTaskRunner { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // |tasks_lock_| is held. | 142 // |tasks_lock_| is held. |
143 TaskPriorityQueue tasks_; | 143 TaskPriorityQueue tasks_; |
144 Lock tasks_lock_; | 144 Lock tasks_lock_; |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); | 146 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); |
147 }; | 147 }; |
148 | 148 |
149 } // namespace base | 149 } // namespace base |
150 | 150 |
151 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 151 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
OLD | NEW |