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

Side by Side Diff: components/task_scheduler_util/initialization/browser_util.h

Issue 2565013002: Split browser-specific and generic code in components/task_scheduler_util/. (Closed)
Patch Set: self-review Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // TODO(fdoray): Remove this file once TaskScheduler initialization in the
6 // browser process uses the components/task_scheduler_util/browser/ API on all
7 // platforms.
8
5 #ifndef COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ 9 #ifndef COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_
6 #define COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ 10 #define COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_
7 11
8 #include <vector> 12 #include <vector>
9 13
10 #include "base/task_scheduler/scheduler_worker_pool_params.h"
11 #include "base/time/time.h"
12 #include "build/build_config.h" 14 #include "build/build_config.h"
13 15
14 namespace base { 16 namespace base {
17 class SchedulerWorkerPoolParams;
15 class TaskTraits; 18 class TaskTraits;
16 } 19 }
17 20
18 namespace task_scheduler_util { 21 namespace task_scheduler_util {
19 namespace initialization { 22 namespace initialization {
20 23
21 enum WorkerPoolType : size_t {
22 BACKGROUND = 0,
23 BACKGROUND_FILE_IO,
24 FOREGROUND,
25 FOREGROUND_FILE_IO,
26 WORKER_POOL_COUNT // Always last.
27 };
28
29 struct SingleWorkerPoolConfiguration {
30 base::SchedulerWorkerPoolParams::StandbyThreadPolicy standby_thread_policy;
31 int threads = 0;
32 base::TimeDelta detach_period;
33 };
34
35 struct BrowserWorkerPoolsConfiguration {
36 SingleWorkerPoolConfiguration background;
37 SingleWorkerPoolConfiguration background_file_io;
38 SingleWorkerPoolConfiguration foreground;
39 SingleWorkerPoolConfiguration foreground_file_io;
40 };
41
42 // Converts a BrowserWorkerPoolsConfiguration to a vector of
43 // base::SchedulerWorkerPoolParams for consumption by task scheduler
44 // initialization.
45 std::vector<base::SchedulerWorkerPoolParams>
46 BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams(
47 const BrowserWorkerPoolsConfiguration& config);
48
49 // Maps |traits| to the index of a browser worker pool vector provided by 24 // Maps |traits| to the index of a browser worker pool vector provided by
50 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or 25 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or
51 // GetDefaultBrowserSchedulerWorkerPoolParams(). 26 // GetDefaultBrowserSchedulerWorkerPoolParams().
52 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); 27 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits);
53 28
54 #if defined(OS_IOS) 29 #if defined(OS_IOS)
55 // Returns the default browser scheduler worker pool params. 30 // Returns the default browser scheduler worker pool params.
56 std::vector<base::SchedulerWorkerPoolParams> 31 std::vector<base::SchedulerWorkerPoolParams>
57 GetDefaultBrowserSchedulerWorkerPoolParams(); 32 GetDefaultBrowserSchedulerWorkerPoolParams();
58 #endif // defined(OS_IOS) 33 #endif // defined(OS_IOS)
59 34
60 } // namespace initialization 35 } // namespace initialization
61 } // namespace task_scheduler_util 36 } // namespace task_scheduler_util
62 37
63 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ 38 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698