OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SIMPLE_TASK_RUNNER_H_ | 5 #ifndef BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ |
6 #define BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ | 6 #define BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // as a template for writing a test TaskRunner implementation using | 40 // as a template for writing a test TaskRunner implementation using |
41 // TestPendingTask. | 41 // TestPendingTask. |
42 // | 42 // |
43 // Note that, like any TaskRunner, TestSimpleTaskRunner is | 43 // Note that, like any TaskRunner, TestSimpleTaskRunner is |
44 // ref-counted. | 44 // ref-counted. |
45 class TestSimpleTaskRunner : public SingleThreadTaskRunner { | 45 class TestSimpleTaskRunner : public SingleThreadTaskRunner { |
46 public: | 46 public: |
47 TestSimpleTaskRunner(); | 47 TestSimpleTaskRunner(); |
48 | 48 |
49 // SingleThreadTaskRunner implementation. | 49 // SingleThreadTaskRunner implementation. |
50 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 50 bool PostDelayedTask(const tracked_objects::Location& from_here, |
51 const Closure& task, | 51 const Closure& task, |
52 TimeDelta delay) override; | 52 TimeDelta delay) override; |
53 virtual bool PostNonNestableDelayedTask( | 53 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
54 const tracked_objects::Location& from_here, | 54 const Closure& task, |
55 const Closure& task, | 55 TimeDelta delay) override; |
56 TimeDelta delay) override; | |
57 | 56 |
58 virtual bool RunsTasksOnCurrentThread() const override; | 57 bool RunsTasksOnCurrentThread() const override; |
59 | 58 |
60 const std::deque<TestPendingTask>& GetPendingTasks() const; | 59 const std::deque<TestPendingTask>& GetPendingTasks() const; |
61 bool HasPendingTask() const; | 60 bool HasPendingTask() const; |
62 base::TimeDelta NextPendingTaskDelay() const; | 61 base::TimeDelta NextPendingTaskDelay() const; |
63 | 62 |
64 // Clears the queue of pending tasks without running them. | 63 // Clears the queue of pending tasks without running them. |
65 void ClearPendingTasks(); | 64 void ClearPendingTasks(); |
66 | 65 |
67 // Runs each current pending task in order and clears the queue. | 66 // Runs each current pending task in order and clears the queue. |
68 // Any tasks posted by the tasks are not run. | 67 // Any tasks posted by the tasks are not run. |
69 virtual void RunPendingTasks(); | 68 virtual void RunPendingTasks(); |
70 | 69 |
71 // Runs pending tasks until the queue is empty. | 70 // Runs pending tasks until the queue is empty. |
72 void RunUntilIdle(); | 71 void RunUntilIdle(); |
73 | 72 |
74 protected: | 73 protected: |
75 virtual ~TestSimpleTaskRunner(); | 74 ~TestSimpleTaskRunner() override; |
76 | 75 |
77 std::deque<TestPendingTask> pending_tasks_; | 76 std::deque<TestPendingTask> pending_tasks_; |
78 ThreadChecker thread_checker_; | 77 ThreadChecker thread_checker_; |
79 | 78 |
80 private: | 79 private: |
81 DISALLOW_COPY_AND_ASSIGN(TestSimpleTaskRunner); | 80 DISALLOW_COPY_AND_ASSIGN(TestSimpleTaskRunner); |
82 }; | 81 }; |
83 | 82 |
84 } // namespace base | 83 } // namespace base |
85 | 84 |
86 #endif // BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ | 85 #endif // BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ |
OLD | NEW |