Chromium Code Reviews| 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 // SingleThreadTaskRunner implementation. | 44 // SingleThreadTaskRunner implementation. |
| 45 bool PostDelayedTask(const tracked_objects::Location& from_here, | 45 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 46 const Closure& task, | 46 const Closure& task, |
| 47 TimeDelta delay) override; | 47 TimeDelta delay) override; |
| 48 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 48 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 49 const Closure& task, | 49 const Closure& task, |
| 50 TimeDelta delay) override; | 50 TimeDelta delay) override; |
| 51 | 51 |
| 52 bool RunsTasksOnCurrentThread() const override; | 52 bool RunsTasksOnCurrentThread() const override; |
| 53 | 53 |
| 54 std::deque<TestPendingTask> GetPendingTasks() const; | 54 std::deque<TestPendingTask> TakePendingTasks(); |
| 55 size_t NumPendingTasks() const; | 55 size_t NumPendingTasks() const; |
| 56 bool HasPendingTask() const; | 56 bool HasPendingTask() const; |
| 57 base::TimeDelta NextPendingTaskDelay() const; | 57 base::TimeDelta NextPendingTaskDelay() const; |
| 58 base::TimeDelta FinalPendingTaskDelay() const; | |
| 59 tracked_objects::Location GetPendingTaskLocationAt(size_t index) const; | |
|
danakj
2016/09/21 22:16:59
I don't think this is safe, in the time between Nu
pastarmovj
2016/09/22 08:12:51
+1
Maybe take a snapshot of the deque with TakeP
tzik
2016/09/29 05:58:04
Ah, right. I updated it to return a base::Optional
| |
| 58 | 60 |
| 59 // Clears the queue of pending tasks without running them. | 61 // Clears the queue of pending tasks without running them. |
| 60 void ClearPendingTasks(); | 62 void ClearPendingTasks(); |
| 61 | 63 |
| 62 // Runs each current pending task in order and clears the queue. Tasks posted | 64 // Runs each current pending task in order and clears the queue. Tasks posted |
| 63 // by the tasks that run within this call do not run within this call. Can | 65 // by the tasks that run within this call do not run within this call. Can |
| 64 // only be called on the thread that created this TestSimpleTaskRunner. | 66 // only be called on the thread that created this TestSimpleTaskRunner. |
| 65 void RunPendingTasks(); | 67 void RunPendingTasks(); |
| 66 | 68 |
| 67 // Runs pending tasks until the queue is empty. Can only be called on the | 69 // Runs pending tasks until the queue is empty. Can only be called on the |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 79 mutable Lock lock_; | 81 mutable Lock lock_; |
| 80 | 82 |
| 81 std::deque<TestPendingTask> pending_tasks_; | 83 std::deque<TestPendingTask> pending_tasks_; |
| 82 | 84 |
| 83 DISALLOW_COPY_AND_ASSIGN(TestSimpleTaskRunner); | 85 DISALLOW_COPY_AND_ASSIGN(TestSimpleTaskRunner); |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 } // namespace base | 88 } // namespace base |
| 87 | 89 |
| 88 #endif // BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ | 90 #endif // BASE_TEST_TEST_SIMPLE_TASK_RUNNER_H_ |
| OLD | NEW |