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 | |
136 protected: | 133 protected: |
137 static bool TaskRunCountBelowCallback(size_t max_tasks, size_t* task_run); | 134 static bool TaskRunCountBelowCallback(size_t max_tasks, size_t* task_run); |
138 bool TaskExistedInitiallyCallback( | 135 bool TaskExistedInitiallyCallback( |
139 const std::set<TestOrderablePendingTask>& existing_tasks); | 136 const std::set<TestOrderablePendingTask>& existing_tasks); |
140 bool NowBeforeCallback(base::TimeTicks stop_at); | 137 bool NowBeforeCallback(base::TimeTicks stop_at); |
141 bool AdvanceNowCallback(); | 138 bool AdvanceNowCallback(); |
142 | 139 |
143 ~OrderedSimpleTaskRunner() override; | 140 ~OrderedSimpleTaskRunner() override; |
144 | 141 |
145 base::ThreadChecker thread_checker_; | 142 base::ThreadChecker thread_checker_; |
146 | 143 |
147 bool advance_now_; | 144 bool advance_now_; |
148 // Not owned. | 145 // Not owned. |
149 base::SimpleTestTickClock* now_src_; | 146 base::SimpleTestTickClock* now_src_; |
150 | 147 |
151 size_t max_tasks_; | 148 size_t max_tasks_; |
152 | 149 |
153 bool inside_run_tasks_until_; | 150 bool inside_run_tasks_until_; |
154 std::set<TestOrderablePendingTask> pending_tasks_; | 151 std::set<TestOrderablePendingTask> pending_tasks_; |
155 | 152 |
156 private: | 153 private: |
157 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); | 154 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); |
158 }; | 155 }; |
159 | 156 |
160 } // namespace cc | 157 } // namespace cc |
161 | 158 |
162 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ | 159 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ |
OLD | NEW |