| 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 #include "build/build_config.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class TaskTraits; | |
| 16 } | |
| 17 | |
| 18 namespace task_scheduler_util { | |
| 19 namespace initialization { | |
| 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 | |
| 50 // BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or | |
| 51 // GetDefaultBrowserSchedulerWorkerPoolParams(). | |
| 52 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); | |
| 53 | |
| 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 | |
| 61 } // namespace task_scheduler_util | |
| 62 | |
| 63 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ | |
| OLD | NEW |