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_TASK_ENVIRONMENT_H_ | 5 #ifndef BASE_TEST_SCOPED_TASK_ENVIRONMENT_H_ |
6 #define BASE_TEST_SCOPED_TASK_ENVIRONMENT_H_ | 6 #define BASE_TEST_SCOPED_TASK_ENVIRONMENT_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 DEFAULT, | 56 DEFAULT, |
57 // The main thread pumps UI messages. | 57 // The main thread pumps UI messages. |
58 UI, | 58 UI, |
59 // The main thread pumps asynchronous IO messages. | 59 // The main thread pumps asynchronous IO messages. |
60 IO, | 60 IO, |
61 }; | 61 }; |
62 | 62 |
63 ScopedTaskEnvironment( | 63 ScopedTaskEnvironment( |
64 MainThreadType main_thread_type = MainThreadType::DEFAULT); | 64 MainThreadType main_thread_type = MainThreadType::DEFAULT); |
65 | 65 |
66 // Runs pending (Thread|Sequenced)TaskRunnerHandle tasks and pending | 66 // Waits until no undelayed TaskScheduler tasks remain. Then, unregisters the |
67 // BLOCK_SHUTDOWN TaskScheduler tasks. Then, unregisters the TaskScheduler and | 67 // TaskScheduler and the (Thread|Sequenced)TaskRunnerHandle. |
68 // the (Thread|Sequenced)TaskRunnerHandle. | |
69 ~ScopedTaskEnvironment(); | 68 ~ScopedTaskEnvironment(); |
70 | 69 |
71 // Synchronously runs (Thread|Sequenced)TaskRunnerHandle tasks until no | 70 // Synchronously runs (Thread|Sequenced)TaskRunnerHandle tasks until no |
72 // undelayed (Thread|Sequenced)TaskRunnerHandle or TaskScheduler tasks remain. | 71 // undelayed (Thread|Sequenced)TaskRunnerHandle or TaskScheduler tasks remain. |
73 void RunUntilIdle(); | 72 void RunUntilIdle(); |
74 | 73 |
75 private: | 74 private: |
76 // Note: |message_loop_| is an implementation detail and will be replaced in | 75 // Note: |message_loop_| is an implementation detail and will be replaced in |
77 // the future, do NOT rely on the presence of a MessageLoop beyond | 76 // the future, do NOT rely on the presence of a MessageLoop beyond |
78 // (Thread|Sequenced)TaskRunnerHandle and RunLoop. | 77 // (Thread|Sequenced)TaskRunnerHandle and RunLoop. |
79 MessageLoop message_loop_; | 78 MessageLoop message_loop_; |
80 | 79 |
81 const TaskScheduler* task_scheduler_ = nullptr; | 80 const TaskScheduler* task_scheduler_ = nullptr; |
82 | 81 |
83 DISALLOW_COPY_AND_ASSIGN(ScopedTaskEnvironment); | 82 DISALLOW_COPY_AND_ASSIGN(ScopedTaskEnvironment); |
84 }; | 83 }; |
85 | 84 |
86 } // namespace test | 85 } // namespace test |
87 } // namespace base | 86 } // namespace base |
88 | 87 |
89 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ | 88 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ |
OLD | NEW |