Commit 29b802ca authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

Initialize TaskScheduler before IO thread in service process.

This is needed to migrate net::SerialWorker (used early on the IO
thread) from base::WorkerPool to base::TaskScheduler. Initializing
base::TaskScheduler early matches the behavior of the browser
process.

Bug: 
Change-Id: I0e409980228c379ccabadc3e32f0b9255d91a2e0
Reviewed-on: https://chromium-review.googlesource.com/660598Reviewed-by: default avatarGene Gutnik <gene@chromium.org>
Commit-Queue: Francois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501251}
parent cb14e960
......@@ -154,16 +154,6 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop,
main_message_loop_ = message_loop;
service_process_state_.reset(state);
network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_IO;
io_thread_.reset(new ServiceIOThread("ServiceProcess_IO"));
file_thread_.reset(new base::Thread("ServiceProcess_File"));
if (!io_thread_->StartWithOptions(options) ||
!file_thread_->StartWithOptions(options)) {
NOTREACHED();
Teardown();
return false;
}
// Initialize TaskScheduler and redirect SequencedWorkerPool tasks to it.
constexpr int kMaxBackgroundThreads = 1;
......@@ -183,6 +173,18 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop,
base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess();
// Initialize the IO and FILE threads.
base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_IO;
io_thread_.reset(new ServiceIOThread("ServiceProcess_IO"));
file_thread_.reset(new base::Thread("ServiceProcess_File"));
if (!io_thread_->StartWithOptions(options) ||
!file_thread_->StartWithOptions(options)) {
NOTREACHED();
Teardown();
return false;
}
// Since SequencedWorkerPool is redirected to TaskScheduler, the value of
// |kMaxBlockingPoolThreads| is ignored.
constexpr int kMaxBlockingPoolThreads = 3;
......
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