Chromium Code Reviews| Index: content/renderer/raster_worker_pool.cc |
| diff --git a/content/renderer/raster_worker_pool.cc b/content/renderer/raster_worker_pool.cc |
| index e8ed13bf8cad0012e91abc13f9b2d6d3b23b117a..1aacf12409ca93fa1378299b29652a21bc03b78b 100644 |
| --- a/content/renderer/raster_worker_pool.cc |
| +++ b/content/renderer/raster_worker_pool.cc |
| @@ -124,44 +124,46 @@ RasterWorkerPool::RasterWorkerPool() |
| has_namespaces_with_finished_running_tasks_cv_(&lock_), |
| shutdown_(false) {} |
| +void RasterWorkerPool::CreateAndStartRasterWorkerPoolThread( |
| + const base::SimpleThread::Options& thread_options, |
| + const std::vector<cc::TaskCategory>& categories, |
| + base::ConditionVariable* has_ready_to_run_tasks_cv) { |
| + scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
| + base::StringPrintf( |
| + "CompositorTileWorker%u(%s)", |
| + static_cast<unsigned>(threads_.size() + 1), |
| + base::GetThreadPriorityAbbr(thread_options.priority()).c_str()) |
| + .c_str(), |
| + thread_options, this, categories, has_ready_to_run_tasks_cv)); |
| + thread->Start(); |
| + threads_.push_back(std::move(thread)); |
| +} |
| + |
| void RasterWorkerPool::Start(int num_threads) { |
| DCHECK(threads_.empty()); |
| + base::SimpleThread::Options thread_options; |
| + |
| // Start |num_threads| threads for foreground work, including nonconcurrent |
| // foreground work. |
| std::vector<cc::TaskCategory> foreground_categories; |
| foreground_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); |
| foreground_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); |
| - |
| for (int i = 0; i < num_threads; i++) { |
| - scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
| - base::StringPrintf("CompositorTileWorker%u", |
| - static_cast<unsigned>(threads_.size() + 1)) |
| - .c_str(), |
| - base::SimpleThread::Options(), this, foreground_categories, |
| - &has_ready_to_run_foreground_tasks_cv_)); |
| - thread->Start(); |
| - threads_.push_back(std::move(thread)); |
| + CreateAndStartRasterWorkerPoolThread( |
| + thread_options, foreground_categories, |
| + &has_ready_to_run_foreground_tasks_cv_); |
| } |
| - // Start a single thread for background work. |
| - std::vector<cc::TaskCategory> background_categories; |
| - background_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); |
| - |
| // Use background priority for background thread. |
| - base::SimpleThread::Options thread_options; |
| #if !defined(OS_MACOSX) |
| thread_options.set_priority(base::ThreadPriority::BACKGROUND); |
| #endif |
| - |
| - scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
| - base::StringPrintf("CompositorTileWorker%u", |
|
reveman
2016/03/24 15:40:46
Can we reduce this patch to a one line change here
prashant.n
2016/03/24 17:13:29
Okay. I'll reduce the patch. May be later we can a
|
| - static_cast<unsigned>(threads_.size() + 1)) |
| - .c_str(), |
| - thread_options, this, background_categories, |
| - &has_ready_to_run_background_tasks_cv_)); |
| - thread->Start(); |
| - threads_.push_back(std::move(thread)); |
| + // Start a single thread for background work. |
| + std::vector<cc::TaskCategory> background_categories; |
| + background_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); |
| + CreateAndStartRasterWorkerPoolThread(thread_options, background_categories, |
| + &has_ready_to_run_background_tasks_cv_); |
| } |
| void RasterWorkerPool::Shutdown() { |