Chromium Code Reviews| Index: content/public/browser/content_browser_client.cc |
| diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc |
| index 571a89c924c56dcccf5ad219f0b6ec88b70767c9..21376960079e5fa63d477596957a079cee235c0a 100644 |
| --- a/content/public/browser/content_browser_client.cc |
| +++ b/content/public/browser/content_browser_client.cc |
| @@ -4,8 +4,12 @@ |
| #include "content/public/browser/content_browser_client.h" |
| +#include "base/bind.h" |
| #include "base/files/file_path.h" |
| #include "base/guid.h" |
| +#include "base/task_scheduler/initialization_util.h" |
| +#include "base/task_scheduler/scheduler_worker_pool_params.h" |
| +#include "base/time/time.h" |
| #include "build/build_config.h" |
| #include "content/public/browser/client_certificate_delegate.h" |
| #include "content/public/browser/memory_coordinator_delegate.h" |
| @@ -434,4 +438,52 @@ ContentBrowserClient::GetMemoryCoordinatorDelegate() { |
| return std::unique_ptr<MemoryCoordinatorDelegate>(); |
| } |
| +void ContentBrowserClient::GetTaskSchedulerInitializationParams( |
| + std::vector<base::SchedulerWorkerPoolParams>* params_vector, |
| + base::TaskScheduler::WorkerPoolIndexForTraitsCallback* |
| + index_to_traits_callback) { |
| + enum WorkerPoolType : size_t { |
| + BACKGROUND_WORKER_POOL = 0, |
| + BACKGROUND_FILE_IO_WORKER_POOL, |
| + FOREGROUND_WORKER_POOL, |
| + FOREGROUND_FILE_IO_WORKER_POOL, |
| + WORKER_POOL_COUNT // Always last. |
| + }; |
| + using IORestriction = base::SchedulerWorkerPoolParams::IORestriction; |
| + using StandbyThreadPolicy = |
| + base::SchedulerWorkerPoolParams::StandbyThreadPolicy; |
| + using ThreadPriority = base::ThreadPriority; |
| + params_vector->emplace_back( |
| + "Background", ThreadPriority::BACKGROUND, IORestriction::DISALLOWED, |
| + StandbyThreadPolicy::ONE, |
| + base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0), |
| + base::TimeDelta::FromSeconds(30)); |
| + params_vector->emplace_back( |
| + "BackgroundFileIO", ThreadPriority::BACKGROUND, IORestriction::ALLOWED, |
| + StandbyThreadPolicy::ONE, |
| + base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0), |
| + base::TimeDelta::FromSeconds(30)); |
| + params_vector->emplace_back( |
| + "Foreground", ThreadPriority::NORMAL, IORestriction::DISALLOWED, |
| + StandbyThreadPolicy::ONE, |
| + base::RecommendedMaxNumberOfThreadsInPool(8, 32, 0.3, 0), |
| + base::TimeDelta::FromSeconds(30)); |
| + params_vector->emplace_back( |
| + "ForegroundFileIO", ThreadPriority::NORMAL, IORestriction::ALLOWED, |
| + StandbyThreadPolicy::ONE, |
| + base::RecommendedMaxNumberOfThreadsInPool(8, 32, 0.3, 0), |
| + base::TimeDelta::FromSeconds(30)); |
| + DCHECK(params_vector->size() == WorkerPoolType::WORKER_POOL_COUNT); |
|
gab
2016/11/30 22:36:58
DCHECK_EQ
robliao
2016/12/06 01:31:30
Done.
|
| + *index_to_traits_callback = base::Bind( |
| + [](const base::TaskTraits& traits) -> size_t { |
| + const bool is_background = |
| + traits.priority() == base::TaskPriority::BACKGROUND; |
| + if (traits.with_file_io()) { |
| + return is_background ? BACKGROUND_FILE_IO_WORKER_POOL |
| + : FOREGROUND_FILE_IO_WORKER_POOL; |
| + } |
| + return is_background ? BACKGROUND_WORKER_POOL : FOREGROUND_WORKER_POOL; |
| + }); |
| +} |
| + |
| } // namespace content |