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

Side by Side Diff: components/task_scheduler_util/renderer/initialization.cc

Issue 2799453002: Remove deprecated functions from components/task_scheduler_util/. (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 unified diff | Download patch
« no previous file with comments | « components/task_scheduler_util/renderer/initialization.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/task_scheduler_util/renderer/initialization.h" 5 #include "components/task_scheduler_util/renderer/initialization.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/task_scheduler/task_traits.h"
9 #include "components/task_scheduler_util/common/variations_util.h" 8 #include "components/task_scheduler_util/common/variations_util.h"
10 9
11 namespace task_scheduler_util { 10 namespace task_scheduler_util {
12 11
13 namespace {
14
15 enum WorkerPoolType : size_t {
16 BACKGROUND = 0,
17 BACKGROUND_BLOCKING,
18 FOREGROUND,
19 FOREGROUND_BLOCKING,
20 WORKER_POOL_COUNT // Always last.
21 };
22
23 } // namespace
24
25 std::unique_ptr<base::TaskScheduler::InitParams> 12 std::unique_ptr<base::TaskScheduler::InitParams>
26 GetRendererTaskSchedulerInitParamsFromCommandLine() { 13 GetRendererTaskSchedulerInitParamsFromCommandLine() {
27 return GetTaskSchedulerInitParams( 14 return GetTaskSchedulerInitParams(
28 "Renderer", GetVariationParamsFromCommandLine( 15 "Renderer", GetVariationParamsFromCommandLine(
29 *base::CommandLine::ForCurrentProcess())); 16 *base::CommandLine::ForCurrentProcess()));
30 } 17 }
31 18
32 std::vector<base::SchedulerWorkerPoolParams> GetRendererWorkerPoolParams() {
33 const auto init_params = GetRendererTaskSchedulerInitParamsFromCommandLine();
34 if (!init_params)
35 return std::vector<base::SchedulerWorkerPoolParams>();
36
37 return std::vector<base::SchedulerWorkerPoolParams>{
38 init_params->background_worker_pool_params,
39 init_params->background_blocking_worker_pool_params,
40 init_params->foreground_worker_pool_params,
41 init_params->foreground_blocking_worker_pool_params};
42 }
43
44 size_t RendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) {
45 const bool is_background =
46 traits.priority() == base::TaskPriority::BACKGROUND;
47 if (traits.may_block() || traits.with_base_sync_primitives())
48 return is_background ? BACKGROUND_BLOCKING : FOREGROUND_BLOCKING;
49 return is_background ? BACKGROUND : FOREGROUND;
50 }
51
52 } // namespace task_scheduler_util 19 } // namespace task_scheduler_util
OLDNEW
« no previous file with comments | « components/task_scheduler_util/renderer/initialization.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698