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 // DEPRECATED. Use ScopedTaskEnvironment instead. |
| 17 // |
| 18 // TODO(fdoray): Replace ScopedAsyncTaskScheduler instances by |
| 19 // ScopedTaskEnvironment. https://crbug.com/708584 |
| 20 // |
16 // Allows usage of the base/task_scheduler/post_task.h API within its scope. | 21 // Allows usage of the base/task_scheduler/post_task.h API within its scope. |
17 // | 22 // |
18 // To wait until all tasks posted without a delay have run, use | 23 // To wait until all tasks posted without a delay have run, use |
19 // TaskScheduler::GetInstance()->FlushForTesting(). | 24 // TaskScheduler::GetInstance()->FlushForTesting(). |
20 // | |
21 // Deprecated. Use ScopedTaskEnvironment instead. https://crbug.com/708584 | |
22 // | |
23 // TODO(fdoray): Replace ScopedAsyncTaskScheduler instances by | |
24 // ScopedTaskEnvironment. | |
25 class ScopedAsyncTaskScheduler { | 25 class ScopedAsyncTaskScheduler { |
26 public: | 26 public: |
27 // Registers a single-threaded TaskScheduler. | 27 // Registers a single-threaded TaskScheduler. |
28 ScopedAsyncTaskScheduler(); | 28 ScopedAsyncTaskScheduler(); |
29 | 29 |
30 // Shuts down and unregisters the TaskScheduler. | 30 // Shuts down and unregisters the TaskScheduler. |
31 // | 31 // |
32 // 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. |
33 ~ScopedAsyncTaskScheduler(); | 33 ~ScopedAsyncTaskScheduler(); |
34 | 34 |
35 private: | 35 private: |
36 const TaskScheduler* task_scheduler_ = nullptr; | 36 const TaskScheduler* task_scheduler_ = nullptr; |
37 | 37 |
38 DISALLOW_COPY_AND_ASSIGN(ScopedAsyncTaskScheduler); | 38 DISALLOW_COPY_AND_ASSIGN(ScopedAsyncTaskScheduler); |
39 }; | 39 }; |
40 | 40 |
41 } // namespace test | 41 } // namespace test |
42 } // namespace base | 42 } // namespace base |
43 | 43 |
44 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ | 44 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ |
OLD | NEW |