OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/raster_worker_pool.h" | 5 #include "content/renderer/raster_worker_pool.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 void RasterWorkerPool::Start(int num_threads) { | 127 void RasterWorkerPool::Start(int num_threads) { |
128 DCHECK(threads_.empty()); | 128 DCHECK(threads_.empty()); |
129 | 129 |
130 // Start |num_threads| threads for foreground work, including nonconcurrent | 130 // Start |num_threads| threads for foreground work, including nonconcurrent |
131 // foreground work. | 131 // foreground work. |
132 std::vector<cc::TaskCategory> foreground_categories; | 132 std::vector<cc::TaskCategory> foreground_categories; |
133 foreground_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); | 133 foreground_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); |
134 foreground_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); | 134 foreground_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); |
135 | 135 |
136 for (int i = 0; i < num_threads; i++) { | 136 for (int i = 0; i < num_threads; i++) { |
137 scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( | 137 std::unique_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
138 base::StringPrintf("CompositorTileWorker%u", | 138 base::StringPrintf("CompositorTileWorker%u", |
139 static_cast<unsigned>(threads_.size() + 1)) | 139 static_cast<unsigned>(threads_.size() + 1)) |
140 .c_str(), | 140 .c_str(), |
141 base::SimpleThread::Options(), this, foreground_categories, | 141 base::SimpleThread::Options(), this, foreground_categories, |
142 &has_ready_to_run_foreground_tasks_cv_)); | 142 &has_ready_to_run_foreground_tasks_cv_)); |
143 thread->Start(); | 143 thread->Start(); |
144 threads_.push_back(std::move(thread)); | 144 threads_.push_back(std::move(thread)); |
145 } | 145 } |
146 | 146 |
147 // Start a single thread for background work. | 147 // Start a single thread for background work. |
148 std::vector<cc::TaskCategory> background_categories; | 148 std::vector<cc::TaskCategory> background_categories; |
149 background_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); | 149 background_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); |
150 | 150 |
151 // Use background priority for background thread. | 151 // Use background priority for background thread. |
152 base::SimpleThread::Options thread_options; | 152 base::SimpleThread::Options thread_options; |
153 #if !defined(OS_MACOSX) | 153 #if !defined(OS_MACOSX) |
154 thread_options.set_priority(base::ThreadPriority::BACKGROUND); | 154 thread_options.set_priority(base::ThreadPriority::BACKGROUND); |
155 #endif | 155 #endif |
156 | 156 |
157 scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( | 157 std::unique_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
158 "CompositorTileWorkerBackground", thread_options, this, | 158 "CompositorTileWorkerBackground", thread_options, this, |
159 background_categories, &has_ready_to_run_background_tasks_cv_)); | 159 background_categories, &has_ready_to_run_background_tasks_cv_)); |
160 thread->Start(); | 160 thread->Start(); |
161 threads_.push_back(std::move(thread)); | 161 threads_.push_back(std::move(thread)); |
162 } | 162 } |
163 | 163 |
164 void RasterWorkerPool::Shutdown() { | 164 void RasterWorkerPool::Shutdown() { |
165 WaitForTasksToFinishRunning(namespace_token_); | 165 WaitForTasksToFinishRunning(namespace_token_); |
166 CollectCompletedTasks(namespace_token_, &completed_tasks_); | 166 CollectCompletedTasks(namespace_token_, &completed_tasks_); |
167 // Shutdown raster threads. | 167 // Shutdown raster threads. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 // Overridden from cc::Task: | 425 // Overridden from cc::Task: |
426 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { | 426 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { |
427 closure_.Run(); | 427 closure_.Run(); |
428 closure_.Reset(); | 428 closure_.Reset(); |
429 } | 429 } |
430 | 430 |
431 RasterWorkerPool::ClosureTask::~ClosureTask() {} | 431 RasterWorkerPool::ClosureTask::~ClosureTask() {} |
432 | 432 |
433 } // namespace content | 433 } // namespace content |
OLD | NEW |