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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 cc::Task::Vector completed_tasks_; | 117 cc::Task::Vector completed_tasks_; |
118 }; | 118 }; |
119 | 119 |
120 RasterWorkerPool::RasterWorkerPool() | 120 RasterWorkerPool::RasterWorkerPool() |
121 : namespace_token_(GetNamespaceToken()), | 121 : namespace_token_(GetNamespaceToken()), |
122 has_ready_to_run_foreground_tasks_cv_(&lock_), | 122 has_ready_to_run_foreground_tasks_cv_(&lock_), |
123 has_ready_to_run_background_tasks_cv_(&lock_), | 123 has_ready_to_run_background_tasks_cv_(&lock_), |
124 has_namespaces_with_finished_running_tasks_cv_(&lock_), | 124 has_namespaces_with_finished_running_tasks_cv_(&lock_), |
125 shutdown_(false) {} | 125 shutdown_(false) {} |
126 | 126 |
127 void RasterWorkerPool::Start( | 127 void RasterWorkerPool::Start(int num_threads) { |
128 int num_threads, | |
129 const base::SimpleThread::Options& thread_options) { | |
130 DCHECK(threads_.empty()); | 128 DCHECK(threads_.empty()); |
131 | 129 |
132 // Start |num_threads| threads for foreground work, including nonconcurrent | 130 // Start |num_threads| threads for foreground work, including nonconcurrent |
133 // foreground work. | 131 // foreground work. |
134 std::vector<cc::TaskCategory> foreground_categories; | 132 std::vector<cc::TaskCategory> foreground_categories; |
135 foreground_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); | 133 foreground_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); |
136 foreground_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); | 134 foreground_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); |
137 | 135 |
138 for (int i = 0; i < num_threads; i++) { | 136 for (int i = 0; i < num_threads; i++) { |
139 scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( | 137 scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
140 base::StringPrintf("CompositorTileWorker%u", | 138 base::StringPrintf("CompositorTileWorker%u", |
141 static_cast<unsigned>(threads_.size() + 1)) | 139 static_cast<unsigned>(threads_.size() + 1)) |
142 .c_str(), | 140 .c_str(), |
143 thread_options, this, foreground_categories, | 141 base::SimpleThread::Options(), this, foreground_categories, |
144 &has_ready_to_run_foreground_tasks_cv_)); | 142 &has_ready_to_run_foreground_tasks_cv_)); |
145 thread->Start(); | 143 thread->Start(); |
146 threads_.push_back(std::move(thread)); | 144 threads_.push_back(std::move(thread)); |
147 } | 145 } |
148 | 146 |
149 // Start a single thread for background work. | 147 // Start a single thread for background work. |
150 std::vector<cc::TaskCategory> background_categories; | 148 std::vector<cc::TaskCategory> background_categories; |
151 background_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); | 149 background_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); |
| 150 |
| 151 // Use background priority for background thread. |
| 152 base::SimpleThread::Options thread_options; |
| 153 #if !defined(OS_MACOSX) |
| 154 thread_options.set_priority(base::ThreadPriority::BACKGROUND); |
| 155 #endif |
| 156 |
152 scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( | 157 scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
153 base::StringPrintf("CompositorTileWorker%u", | 158 base::StringPrintf("CompositorTileWorker%u", |
154 static_cast<unsigned>(threads_.size() + 1)) | 159 static_cast<unsigned>(threads_.size() + 1)) |
155 .c_str(), | 160 .c_str(), |
156 thread_options, this, background_categories, | 161 thread_options, this, background_categories, |
157 &has_ready_to_run_background_tasks_cv_)); | 162 &has_ready_to_run_background_tasks_cv_)); |
158 thread->Start(); | 163 thread->Start(); |
159 threads_.push_back(std::move(thread)); | 164 threads_.push_back(std::move(thread)); |
160 } | 165 } |
161 | 166 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 427 |
423 // Overridden from cc::Task: | 428 // Overridden from cc::Task: |
424 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { | 429 void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { |
425 closure_.Run(); | 430 closure_.Run(); |
426 closure_.Reset(); | 431 closure_.Reset(); |
427 } | 432 } |
428 | 433 |
429 RasterWorkerPool::ClosureTask::~ClosureTask() {} | 434 RasterWorkerPool::ClosureTask::~ClosureTask() {} |
430 | 435 |
431 } // namespace content | 436 } // namespace content |
OLD | NEW |