Chromium Code Reviews| Index: base/task_scheduler/task_scheduler.h |
| diff --git a/base/task_scheduler/task_scheduler.h b/base/task_scheduler/task_scheduler.h |
| index 4b07c88998ba922f46914f7f88055b939e1947cc..4544f7733ff967e36f71c8e13d4b105f61fc5253 100644 |
| --- a/base/task_scheduler/task_scheduler.h |
| +++ b/base/task_scheduler/task_scheduler.h |
| @@ -15,6 +15,7 @@ |
| #include "base/sequenced_task_runner.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/task_runner.h" |
| +#include "base/task_scheduler/scheduler_worker_pool_params.h" |
| #include "base/task_scheduler/task_traits.h" |
| #include "base/time/time.h" |
| @@ -29,7 +30,6 @@ class Location; |
| namespace base { |
| class HistogramBase; |
| -class SchedulerWorkerPoolParams; |
| // Interface for a task scheduler and static methods to manage the instance used |
| // by the post_task.h API. Note: all base/task_scheduler users should go through |
| @@ -37,6 +37,21 @@ class SchedulerWorkerPoolParams; |
| // which manages the process' instance. |
| class BASE_EXPORT TaskScheduler { |
| public: |
| + struct BASE_EXPORT InitParams { |
| + InitParams( |
| + const SchedulerWorkerPoolParams& background_worker_pool_params_in, |
| + const SchedulerWorkerPoolParams& |
| + background_blocking_worker_pool_params_in, |
| + const SchedulerWorkerPoolParams& foreground_worker_pool_params_in, |
| + const SchedulerWorkerPoolParams& |
| + foreground_blocking_worker_pool_params_in); |
| + |
| + const SchedulerWorkerPoolParams background_worker_pool_params; |
| + const SchedulerWorkerPoolParams background_blocking_worker_pool_params; |
| + const SchedulerWorkerPoolParams foreground_worker_pool_params; |
| + const SchedulerWorkerPoolParams foreground_blocking_worker_pool_params; |
| + }; |
| + |
| // Returns the index of the worker pool in which a task with |traits| should |
| // run. This should be coded in a future-proof way: new traits should |
| // gracefully map to a default pool. |
| @@ -121,11 +136,23 @@ class BASE_EXPORT TaskScheduler { |
| // |worker_pool_index_for_traits_callback| returns the index in |worker_pools| |
| // of the worker pool in which a task with given traits should run. For tests, |
| // prefer base::test::ScopedTaskScheduler (ensures isolation). |
| + // |
| + // Deprecated. Use the overload below instead. |
|
robliao
2017/03/20 20:47:32
Add bug number for removal.
fdoray
2017/03/20 20:55:35
Done.
|
| static void CreateAndSetDefaultTaskScheduler( |
| const std::vector<SchedulerWorkerPoolParams>& worker_pool_params_vector, |
| const WorkerPoolIndexForTraitsCallback& |
| worker_pool_index_for_traits_callback); |
| + // Creates and sets a task scheduler using custom params. |name| is used to |
| + // label threads and histograms. It should identify the component that creates |
| + // the TaskScheduler. |init_params| is used to initialize the worker pools. |
| + // CHECKs on failure. For tests, prefer base::test::ScopedTaskScheduler |
| + // (ensures isolation). |
| + // |
| + // Note: The names and priority hints in |init_params| are ignored. |
|
gab
2017/03/20 20:31:56
s/are ignored/are ignored (ref. TODO to remove the
fdoray
2017/03/20 20:43:54
Done.
|
| + static void CreateAndSetDefaultTaskScheduler(const std::string& name, |
| + const InitParams& init_params); |
| + |
| // Registers |task_scheduler| to handle tasks posted through the post_task.h |
| // API for this process. For tests, prefer base::test::ScopedTaskScheduler |
| // (ensures isolation). |