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 <memory> |
10 #include <queue> | 11 #include <queue> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/test/test_pending_task.h" | 17 #include "base/test/test_pending_task.h" |
18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 | 22 |
23 class Clock; | 23 class Clock; |
24 class TickClock; | 24 class TickClock; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void ClearPendingTasks(); | 70 void ClearPendingTasks(); |
71 | 71 |
72 // Returns the current virtual time (initially starting at the Unix epoch). | 72 // Returns the current virtual time (initially starting at the Unix epoch). |
73 Time Now() const; | 73 Time Now() const; |
74 | 74 |
75 // Returns the current virtual tick time (initially starting at 0). | 75 // Returns the current virtual tick time (initially starting at 0). |
76 TimeTicks NowTicks() const; | 76 TimeTicks NowTicks() const; |
77 | 77 |
78 // Returns a Clock that uses the virtual time of |this| as its time source. | 78 // Returns a Clock that uses the virtual time of |this| as its time source. |
79 // The returned Clock will hold a reference to |this|. | 79 // The returned Clock will hold a reference to |this|. |
80 scoped_ptr<Clock> GetMockClock() const; | 80 std::unique_ptr<Clock> GetMockClock() const; |
81 | 81 |
82 // Returns a TickClock that uses the virtual time ticks of |this| as its tick | 82 // Returns a TickClock that uses the virtual time ticks of |this| as its tick |
83 // source. The returned TickClock will hold a reference to |this|. | 83 // source. The returned TickClock will hold a reference to |this|. |
84 scoped_ptr<TickClock> GetMockTickClock() const; | 84 std::unique_ptr<TickClock> GetMockTickClock() const; |
85 | 85 |
86 bool HasPendingTask() const; | 86 bool HasPendingTask() const; |
87 size_t GetPendingTaskCount() const; | 87 size_t GetPendingTaskCount() const; |
88 TimeDelta NextPendingTaskDelay() const; | 88 TimeDelta NextPendingTaskDelay() const; |
89 | 89 |
90 // SingleThreadTaskRunner: | 90 // SingleThreadTaskRunner: |
91 bool RunsTasksOnCurrentThread() const override; | 91 bool RunsTasksOnCurrentThread() const override; |
92 bool PostDelayedTask(const tracked_objects::Location& from_here, | 92 bool PostDelayedTask(const tracked_objects::Location& from_here, |
93 const Closure& task, | 93 const Closure& task, |
94 TimeDelta delay) override; | 94 TimeDelta delay) override; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 size_t next_task_ordinal_; | 161 size_t next_task_ordinal_; |
162 | 162 |
163 Lock tasks_lock_; | 163 Lock tasks_lock_; |
164 | 164 |
165 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); | 165 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); |
166 }; | 166 }; |
167 | 167 |
168 } // namespace base | 168 } // namespace base |
169 | 169 |
170 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 170 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
OLD | NEW |