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

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

Issue 2568793003: Control TaskScheduler initialization params in renderers via field trial. (Closed)
Patch Set: fix ios build error Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/task_scheduler_util/renderer/initialization.h"
6
7 #include <map>
8 #include <string>
9
10 #include "base/command_line.h"
11 #include "base/logging.h"
12 #include "base/task_scheduler/task_traits.h"
13 #include "base/threading/platform_thread.h"
14 #include "components/task_scheduler_util/common/variations_util.h"
15
16 namespace task_scheduler_util {
17
18 namespace {
19
20 enum WorkerPoolType : size_t {
21 BACKGROUND = 0,
22 BACKGROUND_BLOCKING,
23 FOREGROUND,
24 FOREGROUND_BLOCKING,
25 WORKER_POOL_COUNT // Always last.
26 };
27
28 } // namespace
29
30 std::vector<base::SchedulerWorkerPoolParams> GetRendererWorkerPoolParams() {
31 using ThreadPriority = base::ThreadPriority;
32 std::vector<SchedulerImmutableWorkerPoolParams> immutable_worker_pool_params;
33 DCHECK_EQ(BACKGROUND, immutable_worker_pool_params.size());
34 immutable_worker_pool_params.emplace_back("RendererBackground",
35 ThreadPriority::BACKGROUND);
36 DCHECK_EQ(BACKGROUND_BLOCKING, immutable_worker_pool_params.size());
37 immutable_worker_pool_params.emplace_back("RendererBackgroundBlocking",
38 ThreadPriority::BACKGROUND);
39 DCHECK_EQ(FOREGROUND, immutable_worker_pool_params.size());
40 immutable_worker_pool_params.emplace_back("RendererForeground",
41 ThreadPriority::NORMAL);
42 DCHECK_EQ(FOREGROUND_BLOCKING, immutable_worker_pool_params.size());
43 immutable_worker_pool_params.emplace_back("RendererForegroundBlocking",
44 ThreadPriority::NORMAL);
45 return GetWorkerPoolParams(immutable_worker_pool_params,
46 GetVariationParamsFromCommandLine(
47 *base::CommandLine::ForCurrentProcess()));
48 }
49
50 size_t RendererWorkerPoolIndexForTraits(const base::TaskTraits& traits) {
51 const bool is_background =
52 traits.priority() == base::TaskPriority::BACKGROUND;
53 if (traits.may_block() || traits.with_base_sync_primitives())
54 return is_background ? BACKGROUND_BLOCKING : FOREGROUND_BLOCKING;
55 return is_background ? BACKGROUND : FOREGROUND;
56 }
57
58 } // 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