| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MOCK_TIME_TASK_RUNNER_H_ | 5 #ifndef BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
| 6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <queue> | 12 #include <queue> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" |
| 15 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
| 19 #include "base/test/test_pending_task.h" | 20 #include "base/test/test_pending_task.h" |
| 20 #include "base/threading/thread_checker_impl.h" | 21 #include "base/threading/thread_checker_impl.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 | 25 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 std::unique_ptr<TickClock> GetMockTickClock() const; | 134 std::unique_ptr<TickClock> GetMockTickClock() const; |
| 134 | 135 |
| 135 std::deque<TestPendingTask> TakePendingTasks(); | 136 std::deque<TestPendingTask> TakePendingTasks(); |
| 136 bool HasPendingTask() const; | 137 bool HasPendingTask() const; |
| 137 size_t GetPendingTaskCount() const; | 138 size_t GetPendingTaskCount() const; |
| 138 TimeDelta NextPendingTaskDelay() const; | 139 TimeDelta NextPendingTaskDelay() const; |
| 139 | 140 |
| 140 // SingleThreadTaskRunner: | 141 // SingleThreadTaskRunner: |
| 141 bool RunsTasksOnCurrentThread() const override; | 142 bool RunsTasksOnCurrentThread() const override; |
| 142 bool PostDelayedTask(const tracked_objects::Location& from_here, | 143 bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 143 const Closure& task, | 144 Closure task, |
| 144 TimeDelta delay) override; | 145 TimeDelta delay) override; |
| 145 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 146 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 146 const Closure& task, | 147 Closure task, |
| 147 TimeDelta delay) override; | 148 TimeDelta delay) override; |
| 148 | 149 |
| 149 protected: | 150 protected: |
| 150 ~TestMockTimeTaskRunner() override; | 151 ~TestMockTimeTaskRunner() override; |
| 151 | 152 |
| 152 // Whether the elapsing of virtual time is stopped or not. Subclasses can | 153 // Whether the elapsing of virtual time is stopped or not. Subclasses can |
| 153 // override this method to perform early exits from a running task runner. | 154 // override this method to perform early exits from a running task runner. |
| 154 // Defaults to always return false. | 155 // Defaults to always return false. |
| 155 virtual bool IsElapsingStopped(); | 156 virtual bool IsElapsingStopped(); |
| 156 | 157 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 size_t next_task_ordinal_; | 215 size_t next_task_ordinal_; |
| 215 | 216 |
| 216 Lock tasks_lock_; | 217 Lock tasks_lock_; |
| 217 | 218 |
| 218 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); | 219 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); |
| 219 }; | 220 }; |
| 220 | 221 |
| 221 } // namespace base | 222 } // namespace base |
| 222 | 223 |
| 223 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 224 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
| OLD | NEW |