OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SCOPED_ASYNC_TASK_SCHEDULER_H_ | 5 #ifndef BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ |
6 #define BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ | 6 #define BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 | 11 |
12 class TaskScheduler; | 12 class TaskScheduler; |
13 | 13 |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 // Allows usage of the base/task_scheduler/post_task.h API within its scope. | 16 // Allows usage of the base/task_scheduler/post_task.h API within its scope. |
17 // | 17 // |
18 // To wait until all tasks posted without a delay have run, use | 18 // To wait until all tasks posted without a delay have run, use |
19 // TaskScheduler::GetInstance()->FlushForTesting(). | 19 // TaskScheduler::GetInstance()->FlushForTesting(). |
| 20 // |
| 21 // Deprecated. Use ScopedTaskEnvironment instead. https://crbug.com/708584 |
| 22 // |
| 23 // TODO(fdoray): Replace ScopedAsyncTaskScheduler instances by |
| 24 // ScopedTaskEnvironment. |
20 class ScopedAsyncTaskScheduler { | 25 class ScopedAsyncTaskScheduler { |
21 public: | 26 public: |
22 // Registers a single-threaded TaskScheduler. | 27 // Registers a single-threaded TaskScheduler. |
23 ScopedAsyncTaskScheduler(); | 28 ScopedAsyncTaskScheduler(); |
24 | 29 |
25 // Shuts down and unregisters the TaskScheduler. | 30 // Shuts down and unregisters the TaskScheduler. |
26 // | 31 // |
27 // It is guaranteed that all BLOCK_SHUTDOWN tasks have run when this returns. | 32 // It is guaranteed that all BLOCK_SHUTDOWN tasks have run when this returns. |
28 ~ScopedAsyncTaskScheduler(); | 33 ~ScopedAsyncTaskScheduler(); |
29 | 34 |
30 private: | 35 private: |
31 const TaskScheduler* task_scheduler_ = nullptr; | 36 const TaskScheduler* task_scheduler_ = nullptr; |
32 | 37 |
33 DISALLOW_COPY_AND_ASSIGN(ScopedAsyncTaskScheduler); | 38 DISALLOW_COPY_AND_ASSIGN(ScopedAsyncTaskScheduler); |
34 }; | 39 }; |
35 | 40 |
36 } // namespace test | 41 } // namespace test |
37 } // namespace base | 42 } // namespace base |
38 | 43 |
39 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ | 44 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ |
OLD | NEW |