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 <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // which don't have a delay even though it is queued early. | 48 // which don't have a delay even though it is queued early. |
49 class OrderedSimpleTaskRunner : public base::SingleThreadTaskRunner { | 49 class OrderedSimpleTaskRunner : public base::SingleThreadTaskRunner { |
50 public: | 50 public: |
51 OrderedSimpleTaskRunner(); | 51 OrderedSimpleTaskRunner(); |
52 OrderedSimpleTaskRunner(scoped_refptr<TestNowSource> now_src, | 52 OrderedSimpleTaskRunner(scoped_refptr<TestNowSource> now_src, |
53 bool advance_now); | 53 bool advance_now); |
54 | 54 |
55 // base::TestSimpleTaskRunner implementation: | 55 // base::TestSimpleTaskRunner implementation: |
56 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 56 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
57 const base::Closure& task, | 57 const base::Closure& task, |
58 base::TimeDelta delay) OVERRIDE; | 58 base::TimeDelta delay) override; |
59 virtual bool PostNonNestableDelayedTask( | 59 virtual bool PostNonNestableDelayedTask( |
60 const tracked_objects::Location& from_here, | 60 const tracked_objects::Location& from_here, |
61 const base::Closure& task, | 61 const base::Closure& task, |
62 base::TimeDelta delay) OVERRIDE; | 62 base::TimeDelta delay) override; |
63 | 63 |
64 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | 64 virtual bool RunsTasksOnCurrentThread() const override; |
65 | 65 |
66 // Set a maximum number of tasks to run at once. Useful as a timeout to | 66 // Set a maximum number of tasks to run at once. Useful as a timeout to |
67 // prevent infinite task loops. | 67 // prevent infinite task loops. |
68 static const size_t kAbsoluteMaxTasks; | 68 static const size_t kAbsoluteMaxTasks; |
69 void SetRunTaskLimit(size_t max_tasks) { max_tasks_ = max_tasks; } | 69 void SetRunTaskLimit(size_t max_tasks) { max_tasks_ = max_tasks; } |
70 void ClearRunTaskLimit() { max_tasks_ = kAbsoluteMaxTasks; } | 70 void ClearRunTaskLimit() { max_tasks_ = kAbsoluteMaxTasks; } |
71 | 71 |
72 // Allow task runner to advance now when running tasks. | 72 // Allow task runner to advance now when running tasks. |
73 void SetAutoAdvanceNowToPendingTasks(bool advance_now) { | 73 void SetAutoAdvanceNowToPendingTasks(bool advance_now) { |
74 advance_now_ = advance_now; | 74 advance_now_ = advance_now; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 bool inside_run_tasks_until_; | 146 bool inside_run_tasks_until_; |
147 std::set<TestOrderablePendingTask> pending_tasks_; | 147 std::set<TestOrderablePendingTask> pending_tasks_; |
148 | 148 |
149 private: | 149 private: |
150 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); | 150 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); |
151 }; | 151 }; |
152 | 152 |
153 } // namespace cc | 153 } // namespace cc |
154 | 154 |
155 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ | 155 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ |
OLD | NEW |