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/callback.h" |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
14 #include "base/test/test_pending_task.h" | 15 #include "base/test/test_pending_task.h" |
15 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 | 19 |
19 class TimeDelta; | 20 class TimeDelta; |
(...skipping 16 matching lines...) Expand all Loading... |
36 // (e.g., to post more tasks). | 37 // (e.g., to post more tasks). |
37 // | 38 // |
38 // Note that, like any TaskRunner, TestSimpleTaskRunner is | 39 // Note that, like any TaskRunner, TestSimpleTaskRunner is |
39 // ref-counted. | 40 // ref-counted. |
40 class TestSimpleTaskRunner : public SingleThreadTaskRunner { | 41 class TestSimpleTaskRunner : public SingleThreadTaskRunner { |
41 public: | 42 public: |
42 TestSimpleTaskRunner(); | 43 TestSimpleTaskRunner(); |
43 | 44 |
44 // SingleThreadTaskRunner implementation. | 45 // SingleThreadTaskRunner implementation. |
45 bool PostDelayedTask(const tracked_objects::Location& from_here, | 46 bool PostDelayedTask(const tracked_objects::Location& from_here, |
46 const Closure& task, | 47 Closure task, |
47 TimeDelta delay) override; | 48 TimeDelta delay) override; |
48 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 49 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
49 const Closure& task, | 50 Closure task, |
50 TimeDelta delay) override; | 51 TimeDelta delay) override; |
51 | 52 |
52 bool RunsTasksOnCurrentThread() const override; | 53 bool RunsTasksOnCurrentThread() const override; |
53 | 54 |
54 std::deque<TestPendingTask> TakePendingTasks(); | 55 std::deque<TestPendingTask> TakePendingTasks(); |
55 size_t NumPendingTasks() const; | 56 size_t NumPendingTasks() const; |
56 bool HasPendingTask() const; | 57 bool HasPendingTask() const; |
57 base::TimeDelta NextPendingTaskDelay() const; | 58 base::TimeDelta NextPendingTaskDelay() const; |
58 base::TimeDelta FinalPendingTaskDelay() const; | 59 base::TimeDelta FinalPendingTaskDelay() const; |
59 | 60 |
(...skipping 20 matching lines...) Expand all Loading... |
80 mutable Lock lock_; | 81 mutable Lock lock_; |
81 | 82 |
82 std::deque<TestPendingTask> pending_tasks_; | 83 std::deque<TestPendingTask> pending_tasks_; |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(TestSimpleTaskRunner); | 85 DISALLOW_COPY_AND_ASSIGN(TestSimpleTaskRunner); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace base | 88 } // namespace base |
88 | 89 |
89 #endif // BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ | 90 #endif // BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ |
OLD | NEW |