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

Unified Diff: chrome/service/service_process.cc

Issue 2794423002: Initialize TaskScheduler with InitParams in service_process.cc. (Closed)
Patch Set: Created 3 years, 8 months 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 0691cb6e4d5ea8ebe189b5da460568e5b2fb4dbf..117771ff7c23e86d00201d9744b0982ca197ba39 100644
--- a/chrome/service/service_process.cc
+++ b/chrome/service/service_process.cc
@@ -163,20 +163,34 @@ bool ServiceProcess::Initialize(base::MessageLoopForUI* message_loop,
}
// Initialize TaskScheduler and redirect SequencedWorkerPool tasks to it.
- constexpr int kMaxTaskSchedulerThreads = 3;
- std::vector<base::SchedulerWorkerPoolParams> worker_pool_params_vector;
- worker_pool_params_vector.emplace_back(
- "CloudPrintServiceProcess", base::ThreadPriority::NORMAL,
- base::SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY,
- kMaxTaskSchedulerThreads, base::TimeDelta::FromSeconds(30),
- base::SchedulerBackwardCompatibility::INIT_COM_STA);
+ using StandbyThreadPolicy =
+ base::SchedulerWorkerPoolParams::StandbyThreadPolicy;
+ constexpr int kMaxBackgroundThreads = 1;
+ constexpr int kMaxBackgroundBlockingThreads = 1;
+ constexpr int kMaxForegroundThreads = 3;
+ constexpr int kMaxForegroundBlockingThreads = 3;
+ constexpr base::TimeDelta kSuggestedReclaimTime =
+ base::TimeDelta::FromSeconds(30);
+
base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
- worker_pool_params_vector,
- base::Bind([](const base::TaskTraits&) -> size_t { return 0; }));
+ "CloudPrintServiceProcess",
+ {{StandbyThreadPolicy::LAZY, kMaxBackgroundThreads,
+ kSuggestedReclaimTime},
+ {StandbyThreadPolicy::LAZY, kMaxBackgroundBlockingThreads,
+ kSuggestedReclaimTime},
+ {StandbyThreadPolicy::LAZY, kMaxForegroundThreads,
+ kSuggestedReclaimTime},
+ {StandbyThreadPolicy::LAZY, kMaxForegroundBlockingThreads,
+ kSuggestedReclaimTime,
+ base::SchedulerBackwardCompatibility::INIT_COM_STA}});
+
base::SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess();
+ // Since SequencedWorkerPool is redirected to TaskScheduler, the value of
+ // |kMaxBlockingPoolThreads| is ignored.
+ constexpr int kMaxBlockingPoolThreads = 3;
blocking_pool_ =
- new base::SequencedWorkerPool(kMaxTaskSchedulerThreads, "ServiceBlocking",
+ new base::SequencedWorkerPool(kMaxBlockingPoolThreads, "ServiceBlocking",
base::TaskPriority::USER_VISIBLE);
// Initialize Mojo early so things can use it.
« 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