Commit 54151d83 authored by fdoray's avatar fdoray Committed by Commit bot

Create TaskScheduler in BrowserMainLoop constructor.

This CL allows tasks to be posted via base/task_scheduler/post_task.h
as soon as BrowserMainLoop is instantiated. Tasks don't run until
TaskScheduler::Start() is called in BrowserMainLoop::CreateThreads().

BUG=690706

Review-Url: https://codereview.chromium.org/2835933004
Cr-Commit-Position: refs/heads/master@{#467283}
parent a7695ef8
......@@ -531,6 +531,10 @@ BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters)
tracing::TraceConfigFile::GetInstance()->GetStartupDuration() > 0)) {
DCHECK(!g_current_browser_main_loop);
g_current_browser_main_loop = this;
// Use an empty string as TaskScheduler name to match the suffix of browser
// process TaskScheduler histograms.
base::TaskScheduler::Create("");
}
BrowserMainLoop::~BrowserMainLoop() {
......@@ -951,14 +955,15 @@ void BrowserMainLoop::CreateStartupTasks() {
int BrowserMainLoop::CreateThreads() {
TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads");
auto task_scheduler_init_params =
GetContentClient()->browser()->GetTaskSchedulerInitParams();
if (!task_scheduler_init_params)
task_scheduler_init_params = GetDefaultTaskSchedulerInitParams();
DCHECK(task_scheduler_init_params);
base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
"", *task_scheduler_init_params.get());
{
auto task_scheduler_init_params =
GetContentClient()->browser()->GetTaskSchedulerInitParams();
if (!task_scheduler_init_params)
task_scheduler_init_params = GetDefaultTaskSchedulerInitParams();
DCHECK(task_scheduler_init_params);
base::TaskScheduler::GetInstance()->Start(
*task_scheduler_init_params.get());
}
GetContentClient()->browser()->PerformExperimentalTaskSchedulerRedirections();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment