| 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> | 12 #include <stddef.h> |
| 9 | |
| 10 #include "base/task_scheduler/scheduler_worker_pool_params.h" | |
| 11 #include "base/time/time.h" | |
| 12 #include "build/build_config.h" | |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class TaskTraits; | 15 class TaskTraits; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace task_scheduler_util { | 18 namespace task_scheduler_util { |
| 19 namespace initialization { | 19 namespace initialization { |
| 20 | 20 |
| 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 | 21 // Maps |traits| to the index of a browser worker pool vector provided by |
| 50 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or | 22 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or |
| 51 // GetDefaultBrowserSchedulerWorkerPoolParams(). | 23 // GetDefaultBrowserSchedulerWorkerPoolParams(). |
| 52 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); | 24 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); |
| 53 | 25 |
| 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 | 26 } // namespace initialization |
| 61 } // namespace task_scheduler_util | 27 } // namespace task_scheduler_util |
| 62 | 28 |
| 63 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ | 29 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |
| OLD | NEW |