Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7059)

Unified Diff: chrome/service/service_process.cc

Issue 2501033002: Redirect SequencedWorkerPool to TaskScheduler in the service process. (Closed)
Patch Set: self-review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/service/service_process.cc
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index 0dca832cbbfac04d8317f8dbdec2ab82696973e7..8e2b4af10f386813e095eeae0362e5a5d145ee67 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"
@@ -160,6 +164,22 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop,
blocking_pool_ = new base::SequencedWorkerPool(
3, "ServiceBlocking", base::TaskPriority::USER_VISIBLE);
+ // Initialize TaskScheduler and redirect SequencedWorkerPool tasks to it.
+ constexpr int kMaxTaskSchedulerThreads = 3;
+ constexpr base::TimeDelta kTaskSchedulerReclaimTime =
+ base::TimeDelta::FromSeconds(15);
+ base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
+ {base::SchedulerWorkerPoolParams(
robliao 2016/11/14 22:54:33 Looks like this is being copy-constructed rather t
fdoray 2016/11/15 16:43:34 Done.
+ "Service", base::ThreadPriority::NORMAL,
+ base::SchedulerWorkerPoolParams::IORestriction::ALLOWED,
+ kMaxTaskSchedulerThreads, kTaskSchedulerReclaimTime)},
+ base::Bind([](const base::TaskTraits&) {
+ // All TaskTraits are mapped to the single TaskScheduler pool in this
+ // process.
+ return static_cast<size_t>(0);
+ }));
+ base::SequencedWorkerPool::RedirectToTaskSchedulerForProcess();
+
// Initialize Mojo early so things can use it.
mojo::edk::Init();
mojo_ipc_support_.reset(
@@ -253,6 +273,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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698