OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |
| 6 #define COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
| 11 #include "base/time/time.h" |
| 12 |
| 13 namespace base { |
| 14 class TaskTraits; |
| 15 } |
| 16 |
| 17 namespace task_scheduler_util { |
| 18 namespace initialization { |
| 19 |
| 20 enum WorkerPoolType : size_t { |
| 21 BACKGROUND = 0, |
| 22 BACKGROUND_FILE_IO, |
| 23 FOREGROUND, |
| 24 FOREGROUND_FILE_IO, |
| 25 WORKER_POOL_COUNT // Always last. |
| 26 }; |
| 27 |
| 28 struct SingleWorkerPoolConfiguration { |
| 29 base::SchedulerWorkerPoolParams::StandbyThreadPolicy standby_thread_policy; |
| 30 int threads = 0; |
| 31 base::TimeDelta detach_period; |
| 32 }; |
| 33 |
| 34 struct BrowserWorkerPoolsConfiguration { |
| 35 SingleWorkerPoolConfiguration background; |
| 36 SingleWorkerPoolConfiguration background_file_io; |
| 37 SingleWorkerPoolConfiguration foreground; |
| 38 SingleWorkerPoolConfiguration foreground_file_io; |
| 39 }; |
| 40 |
| 41 // Converts a BrowserWorkerPoolsConfiguration to a vector of |
| 42 // base::SchedulerWorkerPoolParams for consumption by task scheduler |
| 43 // initialization. |
| 44 std::vector<base::SchedulerWorkerPoolParams> |
| 45 BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams( |
| 46 const BrowserWorkerPoolsConfiguration& config); |
| 47 |
| 48 // Maps |traits| to the index of a browser worker pool vector provided by |
| 49 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or |
| 50 // GetDefaultBrowserSchedulerWorkerPoolParams(). |
| 51 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); |
| 52 |
| 53 // Returns the default browser scheduler worker pool params. |
| 54 std::vector<base::SchedulerWorkerPoolParams> |
| 55 GetDefaultBrowserSchedulerWorkerPoolParams(); |
| 56 |
| 57 } // namespace initialization |
| 58 } // namespace task_scheduler_util |
| 59 |
| 60 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |
OLD | NEW |