Chromium Code Reviews| Index: components/task_scheduler_util/initialization/browser_util.h |
| diff --git a/components/task_scheduler_util/initialization/browser_util.h b/components/task_scheduler_util/initialization/browser_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eb5073d74c6ee0bffb2650aff7a07445b603a16c |
| --- /dev/null |
| +++ b/components/task_scheduler_util/initialization/browser_util.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |
| +#define COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/task_scheduler/scheduler_worker_pool_params.h" |
| +#include "base/time/time.h" |
| + |
| +namespace base { |
| +class TaskTraits; |
| +} // namespace base |
|
gab
2016/12/06 19:16:07
// namespace comments not required on short fwd-de
robliao
2016/12/07 00:03:54
Done.
|
| + |
| +namespace task_scheduler_util { |
| +namespace initialization { |
| + |
| +enum WorkerPoolType : size_t { |
| + BACKGROUND = 0, |
| + BACKGROUND_FILE_IO, |
| + FOREGROUND, |
| + FOREGROUND_FILE_IO, |
| + WORKER_POOL_COUNT // Always last. |
| +}; |
| + |
| +struct SingleWorkerPoolConfiguration { |
|
fdoray
2016/12/06 17:22:24
SingleWorkerPoolVariationParams?
robliao
2016/12/07 00:03:54
I intentionally avoided the word "variation" to ma
|
| + base::SchedulerWorkerPoolParams::StandbyThreadPolicy standby_thread_policy; |
| + int threads = 0; |
| + base::TimeDelta detach_period; |
| +}; |
| + |
| +struct BrowserWorkerPoolsConfiguration { |
|
fdoray
2016/12/06 17:22:24
BrowserWorkerPoolsVariationParams?
robliao
2016/12/07 00:03:54
See above.
|
| + SingleWorkerPoolConfiguration background; |
| + SingleWorkerPoolConfiguration background_file_io; |
| + SingleWorkerPoolConfiguration foreground; |
| + SingleWorkerPoolConfiguration foreground_file_io; |
| +}; |
| + |
| +// Converts a BrowserWorkerPoolsConfiguration to a vector of |
| +// base::SchedulerWorkerPoolParams for consumption by task scheduler |
| +// initialization. |
| +std::vector<base::SchedulerWorkerPoolParams> |
| +BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams( |
| + const BrowserWorkerPoolsConfiguration& config); |
| + |
| +// Maps |traits| to a browser worker pool vector index returned by |
| +// BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams() or |
| +// GetDefaultBrowserSchedulerWorkerPoolParams(). |
|
gab
2016/12/06 19:16:07
This sentence makes it sound like the "index" is r
robliao
2016/12/07 00:03:54
Done.
|
| +size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits); |
| + |
| +// Returns the default browser scheduler worker pool params. |
| +std::vector<base::SchedulerWorkerPoolParams> |
| +GetDefaultBrowserSchedulerWorkerPoolParams(); |
| + |
| +} // namespace initialization |
| +} // namespace task_scheduler_util |
| + |
| +#endif // COMPONENTS_TASK_SCHEDULER_UTIL_INITIALIZATION_BROWSER_UTIL_H_ |