OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ | 5 #ifndef CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ |
6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ | 6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // Keep running until a task which didn't exist initially would run. | 124 // Keep running until a task which didn't exist initially would run. |
125 base::Callback<bool(void)> TaskExistedInitially(); | 125 base::Callback<bool(void)> TaskExistedInitially(); |
126 | 126 |
127 // Stop running tasks when NextTaskTime() >= stop_at | 127 // Stop running tasks when NextTaskTime() >= stop_at |
128 base::Callback<bool(void)> NowBefore(base::TimeTicks stop_at); | 128 base::Callback<bool(void)> NowBefore(base::TimeTicks stop_at); |
129 | 129 |
130 // Advance Now() to the next task to run. | 130 // Advance Now() to the next task to run. |
131 base::Callback<bool(void)> AdvanceNow(); | 131 base::Callback<bool(void)> AdvanceNow(); |
132 | 132 |
| 133 // Removes all tasks whose weak pointer has been revoked. |
| 134 void RemoveCancelledTasks(); |
| 135 |
133 protected: | 136 protected: |
134 static bool TaskRunCountBelowCallback(size_t max_tasks, size_t* task_run); | 137 static bool TaskRunCountBelowCallback(size_t max_tasks, size_t* task_run); |
135 bool TaskExistedInitiallyCallback( | 138 bool TaskExistedInitiallyCallback( |
136 const std::set<TestOrderablePendingTask>& existing_tasks); | 139 const std::set<TestOrderablePendingTask>& existing_tasks); |
137 bool NowBeforeCallback(base::TimeTicks stop_at); | 140 bool NowBeforeCallback(base::TimeTicks stop_at); |
138 bool AdvanceNowCallback(); | 141 bool AdvanceNowCallback(); |
139 | 142 |
140 ~OrderedSimpleTaskRunner() override; | 143 ~OrderedSimpleTaskRunner() override; |
141 | 144 |
142 base::ThreadChecker thread_checker_; | 145 base::ThreadChecker thread_checker_; |
143 | 146 |
144 bool advance_now_; | 147 bool advance_now_; |
145 // Not owned. | 148 // Not owned. |
146 base::SimpleTestTickClock* now_src_; | 149 base::SimpleTestTickClock* now_src_; |
147 | 150 |
148 size_t max_tasks_; | 151 size_t max_tasks_; |
149 | 152 |
150 bool inside_run_tasks_until_; | 153 bool inside_run_tasks_until_; |
151 std::set<TestOrderablePendingTask> pending_tasks_; | 154 std::set<TestOrderablePendingTask> pending_tasks_; |
152 | 155 |
153 private: | 156 private: |
154 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); | 157 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); |
155 }; | 158 }; |
156 | 159 |
157 } // namespace cc | 160 } // namespace cc |
158 | 161 |
159 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ | 162 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ |
OLD | NEW |