| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" |
| 10 #include "base/test/test_simple_task_runner.h" | 11 #include "base/test/test_simple_task_runner.h" |
| 11 | 12 |
| 12 namespace cc { | 13 namespace cc { |
| 13 | 14 |
| 14 // This runs pending tasks based on task's post_time + delay. | 15 // This runs pending tasks based on task's post_time + delay. |
| 15 // We should not execute a delayed task sooner than some of the queued tasks | 16 // We should not execute a delayed task sooner than some of the queued tasks |
| 16 // which don't have a delay even though it is queued early. | 17 // which don't have a delay even though it is queued early. |
| 17 class OrderedSimpleTaskRunner : public base::TestSimpleTaskRunner { | 18 class OrderedSimpleTaskRunner : public base::TestSimpleTaskRunner { |
| 18 public: | 19 public: |
| 19 OrderedSimpleTaskRunner(); | 20 OrderedSimpleTaskRunner(bool advance_now = true); |
| 20 | 21 |
| 22 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 23 const base::Closure& task, |
| 24 base::TimeDelta delay) OVERRIDE; |
| 25 virtual bool PostNonNestableDelayedTask( |
| 26 const tracked_objects::Location& from_here, |
| 27 const base::Closure& task, |
| 28 base::TimeDelta delay) OVERRIDE; |
| 21 virtual void RunPendingTasks() OVERRIDE; | 29 virtual void RunPendingTasks() OVERRIDE; |
| 22 | 30 |
| 31 base::TimeTicks Now(); |
| 32 base::TimeDelta DelayToNextPendingTask(); |
| 33 void SetAutoAdvanceNowToPendingTasks(bool advance_now); |
| 34 void SetNow(base::TimeTicks time); |
| 35 |
| 23 protected: | 36 protected: |
| 24 virtual ~OrderedSimpleTaskRunner(); | 37 virtual ~OrderedSimpleTaskRunner(); |
| 25 | 38 |
| 39 static void SortTasks(std::deque<base::TestPendingTask>& tasks); |
| 40 |
| 26 private: | 41 private: |
| 42 bool advance_now_; |
| 43 base::TimeTicks now_; |
| 44 bool inside_run_pending_tasks_; |
| 45 |
| 27 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); | 46 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); |
| 28 }; | 47 }; |
| 29 | 48 |
| 30 } // namespace cc | 49 } // namespace cc |
| 31 | 50 |
| 32 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ | 51 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ |
| OLD | NEW |