OLD | NEW |
---|---|
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> | |
9 | |
10 #include "base/task_scheduler/scheduler_worker_pool_params.h" | |
11 #include "base/time/time.h" | |
12 #include "build/build_config.h" | |
13 | |
14 namespace base { | 12 namespace base { |
15 class TaskTraits; | 13 class TaskTraits; |
16 } | 14 } |
17 | 15 |
18 namespace task_scheduler_util { | 16 namespace task_scheduler_util { |
19 namespace initialization { | 17 namespace initialization { |
20 | 18 |
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 | 19 // Maps |traits| to the index of a browser worker pool vector provided by |
50 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or | 20 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or |
51 // GetDefaultBrowserSchedulerWorkerPoolParams(). | 21 // GetDefaultBrowserSchedulerWorkerPoolParams(). |
52 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); | 22 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); |
robliao
2016/12/15 22:07:09
Quick iOS Build: This needs stddef.h
fdoray
2016/12/16 13:06:44
Done.
| |
53 | 23 |
54 #if defined(OS_IOS) | |
55 // Returns the default browser scheduler worker pool params. | |
56 std::vector<base::SchedulerWorkerPoolParams> | |
57 GetDefaultBrowserSchedulerWorkerPoolParams(); | |
58 #endif // defined(OS_IOS) | |
59 | |
60 } // namespace initialization | 24 } // namespace initialization |
61 } // namespace task_scheduler_util | 25 } // namespace task_scheduler_util |
62 | 26 |
63 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ | 27 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |
OLD | NEW |