-
fdoray authored
With this CL, tasks posted to the base/task_scheduler/post_task.h API no longer run asynchronously on a dedicated thread. Instead, they are posted to a MessageLoop on the thread where the ScopedTaskScheduler lives and run synchronously when RunLoop::Run/RunUntilIdle() is invoked. This CL also allows usage of the base/task_scheduler/post_task.h API within the scope of a TestBrowserThreadBundle. Benefits of running TaskScheduler tasks synchronously: - Tests are more deterministic. - It is easier to wait for a chain of tasks involving TaskScheduler. E.g.: base::PostTaskAndReplyWithTraits( FROM_HERE, TaskTraits(), Bind(&A), Bind(&B)); base::RunLoop().RunUntilIdle(); // Without this CL, this returns immediately because there // are no pending tasks on the main thread initially. With // this CL, this returns when A and B have run. Note that this CL prevents a TestBrowserThreadBundle or a MessageLoop from being initialized in the scope of a ScopedTaskScheduler. It fixes tests that previously did this. BUG=553459 Review-Url: https://codereview.chromium.org/2557083002 Cr-Commit-Position: refs/heads/master@{#439505}
ad58f838