Chromium Code Reviews| Index: chrome/service/service_process.cc |
| diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc |
| index a29cc1db80d361012977c1c1e26707d148b9cd15..9a89e5747e7d74802356f68c781164621e97042e 100644 |
| --- a/chrome/service/service_process.cc |
| +++ b/chrome/service/service_process.cc |
| @@ -8,6 +8,7 @@ |
| #include <utility> |
| #include "base/base_switches.h" |
| +#include "base/bind.h" |
| #include "base/callback.h" |
| #include "base/command_line.h" |
| #include "base/environment.h" |
| @@ -21,8 +22,11 @@ |
| #include "base/strings/string16.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/synchronization/waitable_event.h" |
| +#include "base/task_scheduler/scheduler_worker_pool_params.h" |
| +#include "base/task_scheduler/task_scheduler.h" |
| #include "base/threading/sequenced_worker_pool.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| +#include "base/time/time.h" |
| #include "base/values.h" |
| #include "build/build_config.h" |
| #include "chrome/common/chrome_constants.h" |
| @@ -157,6 +161,24 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop, |
| Teardown(); |
| return false; |
| } |
| + |
| + // Initialize TaskScheduler and redirect SequencedWorkerPool tasks to it. |
| + constexpr int kMaxTaskSchedulerThreads = 3; |
| + constexpr base::TimeDelta kTaskSchedulerReclaimTime = |
| + base::TimeDelta::FromSeconds(30); |
| + std::vector<base::SchedulerWorkerPoolParams> worker_pool_params_vector; |
| + worker_pool_params_vector.emplace_back( |
| + "Service", base::ThreadPriority::NORMAL, |
| + base::SchedulerWorkerPoolParams::IORestriction::ALLOWED, |
| + kMaxTaskSchedulerThreads, kTaskSchedulerReclaimTime); |
| + base::TaskScheduler::CreateAndSetDefaultTaskScheduler( |
| + worker_pool_params_vector, base::Bind([](const base::TaskTraits&) { |
|
gab
2016/11/15 20:46:02
[](const base::TaskTraits&) -> size_t {}
(will av
fdoray
2016/11/15 21:37:13
Done.
|
| + // All TaskTraits are mapped to the single TaskScheduler pool in this |
| + // process. |
| + return static_cast<size_t>(0); |
| + })); |
| + base::SequencedWorkerPool::RedirectToTaskSchedulerForProcess(); |
| + |
| blocking_pool_ = new base::SequencedWorkerPool( |
| 3, "ServiceBlocking", base::TaskPriority::USER_VISIBLE); |
| @@ -258,6 +280,8 @@ bool ServiceProcess::Teardown() { |
| blocking_pool_ = NULL; |
| } |
| + base::TaskScheduler::GetInstance()->Shutdown(); |
| + |
| // The NetworkChangeNotifier must be destroyed after all other threads that |
| // might use it have been shut down. |
| network_change_notifier_.reset(); |