Index: content/public/test/test_browser_thread_bundle.h |
diff --git a/content/public/test/test_browser_thread_bundle.h b/content/public/test/test_browser_thread_bundle.h |
index 970c9404ef95853db8495f154fd002210b5a0865..15cdba8f5c6b350876bfb172fe04a15de5dac492 100644 |
--- a/content/public/test/test_browser_thread_bundle.h |
+++ b/content/public/test/test_browser_thread_bundle.h |
@@ -9,26 +9,43 @@ |
// the first member variable in test classes, so it is destroyed last, and the |
// test threads always exist from the perspective of other classes. |
// |
-// By default, all of the created TestBrowserThreads and the task scheduler will |
-// be backed by a single shared MessageLoop. If a test truly needs separate |
-// threads, it can do so by passing the appropriate combination of option values |
-// during the TestBrowserThreadBundle construction. |
+// By default, all of the created TestBrowserThreads will be backed by a single |
+// shared MessageLoop. If a test truly needs separate threads, it can do so by |
+// passing the appropriate combination of option values during the |
+// TestBrowserThreadBundle construction. TaskScheduler and blocking pool tasks |
+// always run on dedicated threads. |
// |
-// To synchronously run tasks posted to task scheduler or to TestBrowserThreads |
-// that use the shared MessageLoop, call RunLoop::Run/RunUntilIdle() on the |
-// thread where the TestBrowserThreadBundle lives. The destructor of |
-// TestBrowserThreadBundle runs remaining TestBrowserThreads tasks, remaining |
-// blocking pool tasks, and remaining BLOCK_SHUTDOWN task scheduler tasks. |
+// To synchronously run tasks from the shared MessageLoop: |
+// |
+// ... until there are no undelayed tasks in the shared MessageLoop: |
+// base::RunLoop::RunUntilIdle(); |
+// |
+// ... until there are no undelayed tasks in the shared MessageLoop, in |
+// TaskScheduler or in the blocking pool (excluding tasks not posted from the |
+// shared MessageLoop's thread, TaskScheduler or the blocking pool): |
+// content::RunAllBlockingPoolTasksUntilIdle(); |
+// |
+// ... until a condition is met: |
+// base::RunLoop run_loop; |
+// // Runs until a task running in the shared MessageLoop calls |
+// // run_loop.Quit() or runs run_loop.QuitClosure() (&run_loop or |
+// // run_loop.QuitClosure() must be kept somewhere accessible by that task). |
+// run_loop.Run(); |
+// |
+// To wait until there are no pending undelayed tasks in TaskScheduler or in the |
+// blocking pool, without running tasks from the shared MessageLoop: |
+// base::TaskScheduler::GetInstance()->FlushForTesting(); |
+// // Note: content::BrowserThread::GetBlockingPool()->FlushForTesting() is |
+// // equivalent but deprecated. |
+// |
+// The destructor of TestBrowserThreadBundle runs remaining TestBrowserThreads |
+// tasks, remaining blocking pool tasks, and remaining BLOCK_SHUTDOWN task |
+// scheduler tasks. |
// |
// If a test needs a MessageLoopForIO on the main thread, it should use the |
-// IO_MAINLOOP option. This also allows task scheduler tasks to use |
-// FileDescriptorWatcher. Most of the time, IO_MAINLOOP avoids needing to use a |
+// IO_MAINLOOP option. Most of the time, IO_MAINLOOP avoids needing to use a |
// REAL_IO_THREAD. |
// |
-// If a test needs a TaskScheduler that runs tasks on a dedicated thread, it |
-// should use REAL_TASK_SCHEDULER. Usage of this option should be justified as |
-// it is easier to understand and debug a single-threaded unit test. |
-// |
// For some tests it is important to emulate real browser startup. During real |
// browser startup, the main MessageLoop is created before other threads. |
// Passing DONT_CREATE_THREADS to constructor will delay creating other threads |
@@ -48,7 +65,6 @@ namespace base { |
class MessageLoop; |
namespace test { |
class ScopedAsyncTaskScheduler; |
-class ScopedTaskScheduler; |
} // namespace test |
} // namespace base |
@@ -67,8 +83,7 @@ class TestBrowserThreadBundle { |
REAL_DB_THREAD = 1 << 1, |
REAL_FILE_THREAD = 1 << 2, |
REAL_IO_THREAD = 1 << 3, |
- REAL_TASK_SCHEDULER = 1 << 4, |
- DONT_CREATE_THREADS = 1 << 5, |
+ DONT_CREATE_THREADS = 1 << 4, |
}; |
TestBrowserThreadBundle(); |
@@ -86,7 +101,6 @@ class TestBrowserThreadBundle { |
std::unique_ptr<base::MessageLoop> message_loop_; |
std::unique_ptr<base::test::ScopedAsyncTaskScheduler> |
scoped_async_task_scheduler_; |
- std::unique_ptr<base::test::ScopedTaskScheduler> scoped_task_scheduler_; |
std::unique_ptr<TestBrowserThread> ui_thread_; |
std::unique_ptr<TestBrowserThread> db_thread_; |
std::unique_ptr<TestBrowserThread> file_thread_; |