dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
tfarina | b62c2519 | 2015-10-27 03:14:48 | [diff] [blame] | 5 | #include "content/renderer/raster_worker_pool.h" |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 6 | |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 7 | #include <string> |
ericrk | 5a1188c6 | 2015-12-18 22:04:04 | [diff] [blame] | 8 | #include <utility> |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 9 | #include <vector> |
ericrk | 5a1188c6 | 2015-12-18 22:04:04 | [diff] [blame] | 10 | |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 11 | #include "base/strings/stringprintf.h" |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 12 | #include "base/threading/thread_restrictions.h" |
| 13 | #include "base/trace_event/trace_event.h" |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 14 | #include "cc/base/math_util.h" |
| 15 | #include "cc/raster/task_category.h" |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 16 | |
| 17 | namespace content { |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 18 | namespace { |
| 19 | |
| 20 | // A thread which forwards to RasterWorkerPool::Run with the runnable |
| 21 | // categories. |
| 22 | class RasterWorkerPoolThread : public base::SimpleThread { |
| 23 | public: |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 24 | explicit RasterWorkerPoolThread(const std::string& name_prefix, |
| 25 | const Options& options, |
| 26 | RasterWorkerPool* pool, |
| 27 | std::vector<cc::TaskCategory> categories) |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 28 | : SimpleThread(name_prefix, options), |
| 29 | pool_(pool), |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 30 | categories_(categories) {} |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 31 | |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 32 | void Run() override { pool_->Run(categories_); } |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | RasterWorkerPool* const pool_; |
| 36 | const std::vector<cc::TaskCategory> categories_; |
| 37 | }; |
| 38 | |
| 39 | } // namespace |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 40 | |
| 41 | // A sequenced task runner which posts tasks to a RasterWorkerPool. |
| 42 | class RasterWorkerPool::RasterWorkerPoolSequencedTaskRunner |
| 43 | : public base::SequencedTaskRunner { |
| 44 | public: |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 45 | explicit RasterWorkerPoolSequencedTaskRunner( |
| 46 | cc::TaskGraphRunner* task_graph_runner) |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 47 | : task_graph_runner_(task_graph_runner), |
| 48 | namespace_token_(task_graph_runner->GetNamespaceToken()) {} |
| 49 | |
| 50 | // Overridden from base::TaskRunner: |
| 51 | bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 52 | const base::Closure& task, |
| 53 | base::TimeDelta delay) override { |
| 54 | return PostNonNestableDelayedTask(from_here, task, delay); |
| 55 | } |
| 56 | bool RunsTasksOnCurrentThread() const override { return true; } |
| 57 | |
| 58 | // Overridden from base::SequencedTaskRunner: |
| 59 | bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
| 60 | const base::Closure& task, |
| 61 | base::TimeDelta delay) override { |
| 62 | base::AutoLock lock(lock_); |
| 63 | |
| 64 | // Remove completed tasks. |
| 65 | DCHECK(completed_tasks_.empty()); |
| 66 | task_graph_runner_->CollectCompletedTasks(namespace_token_, |
| 67 | &completed_tasks_); |
| 68 | |
| 69 | tasks_.erase(tasks_.begin(), tasks_.begin() + completed_tasks_.size()); |
| 70 | |
| 71 | tasks_.push_back(make_scoped_refptr(new ClosureTask(task))); |
| 72 | graph_.Reset(); |
dcastagna | d3ecba5 | 2015-08-06 21:37:25 | [diff] [blame] | 73 | for (const auto& graph_task : tasks_) { |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 74 | int dependencies = 0; |
| 75 | if (!graph_.nodes.empty()) |
| 76 | dependencies = 1; |
| 77 | |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 78 | // Treat any tasks that are enqueued through the SequencedTaskRunner as |
| 79 | // FOREGROUND priority. We don't have enough information to know the |
| 80 | // actual priority of such tasks, so we run them as soon as possible. |
| 81 | cc::TaskGraph::Node node(graph_task.get(), cc::TASK_CATEGORY_FOREGROUND, |
ericrk | 5a1188c6 | 2015-12-18 22:04:04 | [diff] [blame] | 82 | 0u /* priority */, dependencies); |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 83 | if (dependencies) { |
| 84 | graph_.edges.push_back( |
| 85 | cc::TaskGraph::Edge(graph_.nodes.back().task, node.task)); |
| 86 | } |
| 87 | graph_.nodes.push_back(node); |
| 88 | } |
| 89 | task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); |
| 90 | completed_tasks_.clear(); |
| 91 | return true; |
| 92 | } |
| 93 | |
| 94 | private: |
| 95 | ~RasterWorkerPoolSequencedTaskRunner() override { |
| 96 | task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
| 97 | task_graph_runner_->CollectCompletedTasks(namespace_token_, |
| 98 | &completed_tasks_); |
| 99 | }; |
| 100 | |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 101 | // Lock to exclusively access all the following members that are used to |
| 102 | // implement the SequencedTaskRunner interfaces. |
| 103 | base::Lock lock_; |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 104 | |
| 105 | cc::TaskGraphRunner* task_graph_runner_; |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 106 | // Namespace used to schedule tasks in the task graph runner. |
| 107 | cc::NamespaceToken namespace_token_; |
| 108 | // List of tasks currently queued up for execution. |
| 109 | cc::Task::Vector tasks_; |
| 110 | // Graph object used for scheduling tasks. |
| 111 | cc::TaskGraph graph_; |
| 112 | // Cached vector to avoid allocation when getting the list of complete |
| 113 | // tasks. |
| 114 | cc::Task::Vector completed_tasks_; |
| 115 | }; |
| 116 | |
| 117 | RasterWorkerPool::RasterWorkerPool() |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 118 | : namespace_token_(GetNamespaceToken()), |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 119 | has_ready_to_run_tasks_cv_(&lock_), |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 120 | has_namespaces_with_finished_running_tasks_cv_(&lock_), |
| 121 | shutdown_(false) {} |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 122 | |
| 123 | void RasterWorkerPool::Start( |
| 124 | int num_threads, |
| 125 | const base::SimpleThread::Options& thread_options) { |
| 126 | DCHECK(threads_.empty()); |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 127 | while (threads_.size() < static_cast<size_t>(num_threads)) { |
| 128 | // Determine the categories that each thread can run. |
| 129 | std::vector<cc::TaskCategory> task_categories; |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 130 | |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 131 | // The first thread can run nonconcurrent tasks. |
| 132 | if (threads_.size() == 0) { |
| 133 | task_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); |
| 134 | } |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 135 | |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 136 | // All threads can run foreground tasks. |
| 137 | task_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); |
| 138 | |
| 139 | // The last thread can run background tasks. |
| 140 | if (threads_.size() == (static_cast<size_t>(num_threads) - 1)) { |
| 141 | task_categories.push_back(cc::TASK_CATEGORY_BACKGROUND); |
| 142 | } |
| 143 | |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 144 | scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
| 145 | base::StringPrintf("CompositorTileWorker%u", |
| 146 | static_cast<unsigned>(threads_.size() + 1)) |
| 147 | .c_str(), |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 148 | thread_options, this, task_categories)); |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 149 | thread->Start(); |
dcheng | 07945f63 | 2015-12-26 07:59:32 | [diff] [blame] | 150 | threads_.push_back(std::move(thread)); |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
| 154 | void RasterWorkerPool::Shutdown() { |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 155 | WaitForTasksToFinishRunning(namespace_token_); |
| 156 | CollectCompletedTasks(namespace_token_, &completed_tasks_); |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 157 | // Shutdown raster threads. |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 158 | { |
| 159 | base::AutoLock lock(lock_); |
| 160 | |
| 161 | DCHECK(!work_queue_.HasReadyToRunTasks()); |
| 162 | DCHECK(!work_queue_.HasAnyNamespaces()); |
| 163 | |
| 164 | DCHECK(!shutdown_); |
| 165 | shutdown_ = true; |
| 166 | |
ericrk | e3e5b6f | 2015-12-02 00:00:37 | [diff] [blame] | 167 | // Wake up all workers so they exit. |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 168 | has_ready_to_run_tasks_cv_.Broadcast(); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 169 | } |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 170 | while (!threads_.empty()) { |
| 171 | threads_.back()->Join(); |
| 172 | threads_.pop_back(); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // Overridden from base::TaskRunner: |
| 177 | bool RasterWorkerPool::PostDelayedTask( |
| 178 | const tracked_objects::Location& from_here, |
| 179 | const base::Closure& task, |
| 180 | base::TimeDelta delay) { |
| 181 | base::AutoLock lock(lock_); |
| 182 | |
| 183 | // Remove completed tasks. |
| 184 | DCHECK(completed_tasks_.empty()); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 185 | CollectCompletedTasksWithLockAcquired(namespace_token_, &completed_tasks_); |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 186 | |
| 187 | cc::Task::Vector::iterator end = std::remove_if( |
| 188 | tasks_.begin(), tasks_.end(), [this](const scoped_refptr<cc::Task>& e) { |
| 189 | return std::find(this->completed_tasks_.begin(), |
| 190 | this->completed_tasks_.end(), |
| 191 | e) != this->completed_tasks_.end(); |
| 192 | }); |
| 193 | tasks_.erase(end, tasks_.end()); |
| 194 | |
| 195 | tasks_.push_back(make_scoped_refptr(new ClosureTask(task))); |
| 196 | graph_.Reset(); |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 197 | for (const auto& graph_task : tasks_) { |
| 198 | // Delayed tasks are assigned FOREGROUND category, ensuring that they run as |
| 199 | // soon as possible once their delay has expired. |
ericrk | 5a1188c6 | 2015-12-18 22:04:04 | [diff] [blame] | 200 | graph_.nodes.push_back( |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 201 | cc::TaskGraph::Node(graph_task.get(), cc::TASK_CATEGORY_FOREGROUND, |
ericrk | 5a1188c6 | 2015-12-18 22:04:04 | [diff] [blame] | 202 | 0u /* priority */, 0u /* dependencies */)); |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 203 | } |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 204 | |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 205 | ScheduleTasksWithLockAcquired(namespace_token_, &graph_); |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 206 | completed_tasks_.clear(); |
| 207 | return true; |
| 208 | } |
| 209 | |
| 210 | bool RasterWorkerPool::RunsTasksOnCurrentThread() const { |
| 211 | return true; |
| 212 | } |
| 213 | |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 214 | void RasterWorkerPool::Run(const std::vector<cc::TaskCategory>& categories) { |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 215 | base::AutoLock lock(lock_); |
| 216 | |
| 217 | while (true) { |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 218 | if (!RunTaskWithLockAcquired(categories)) { |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 219 | // Exit when shutdown is set and no more tasks are pending. |
| 220 | if (shutdown_) |
| 221 | break; |
| 222 | |
| 223 | // Wait for more tasks. |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 224 | has_ready_to_run_tasks_cv_.Wait(); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 225 | continue; |
| 226 | } |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 227 | } |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void RasterWorkerPool::FlushForTesting() { |
| 231 | base::AutoLock lock(lock_); |
| 232 | |
| 233 | while (!work_queue_.HasFinishedRunningTasksInAllNamespaces()) { |
| 234 | has_namespaces_with_finished_running_tasks_cv_.Wait(); |
| 235 | } |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | scoped_refptr<base::SequencedTaskRunner> |
| 239 | RasterWorkerPool::CreateSequencedTaskRunner() { |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 240 | return new RasterWorkerPoolSequencedTaskRunner(this); |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | RasterWorkerPool::~RasterWorkerPool() {} |
| 244 | |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 245 | cc::NamespaceToken RasterWorkerPool::GetNamespaceToken() { |
| 246 | base::AutoLock lock(lock_); |
| 247 | return work_queue_.GetNamespaceToken(); |
| 248 | } |
| 249 | |
| 250 | void RasterWorkerPool::ScheduleTasks(cc::NamespaceToken token, |
| 251 | cc::TaskGraph* graph) { |
vmpstr | 2d80f2ac | 2016-01-26 22:16:52 | [diff] [blame] | 252 | TRACE_EVENT2("disabled-by-default-cc.debug", |
| 253 | "RasterWorkerPool::ScheduleTasks", "num_nodes", |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 254 | graph->nodes.size(), "num_edges", graph->edges.size()); |
| 255 | { |
| 256 | base::AutoLock lock(lock_); |
| 257 | ScheduleTasksWithLockAcquired(token, graph); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | void RasterWorkerPool::ScheduleTasksWithLockAcquired(cc::NamespaceToken token, |
| 262 | cc::TaskGraph* graph) { |
| 263 | DCHECK(token.IsValid()); |
| 264 | DCHECK(!cc::TaskGraphWorkQueue::DependencyMismatch(graph)); |
| 265 | DCHECK(!shutdown_); |
| 266 | |
| 267 | work_queue_.ScheduleTasks(token, graph); |
| 268 | |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 269 | // If there is more work available, wake up the other worker threads. |
| 270 | if (work_queue_.HasReadyToRunTasks()) |
| 271 | has_ready_to_run_tasks_cv_.Broadcast(); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | void RasterWorkerPool::WaitForTasksToFinishRunning(cc::NamespaceToken token) { |
vmpstr | 2d80f2ac | 2016-01-26 22:16:52 | [diff] [blame] | 275 | TRACE_EVENT0("disabled-by-default-cc.debug", |
| 276 | "RasterWorkerPool::WaitForTasksToFinishRunning"); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 277 | |
| 278 | DCHECK(token.IsValid()); |
| 279 | |
| 280 | { |
| 281 | base::AutoLock lock(lock_); |
| 282 | base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 283 | |
| 284 | auto* task_namespace = work_queue_.GetNamespaceForToken(token); |
| 285 | |
| 286 | if (!task_namespace) |
| 287 | return; |
| 288 | |
| 289 | while (!work_queue_.HasFinishedRunningTasksInNamespace(task_namespace)) |
| 290 | has_namespaces_with_finished_running_tasks_cv_.Wait(); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | |
| 294 | void RasterWorkerPool::CollectCompletedTasks( |
| 295 | cc::NamespaceToken token, |
| 296 | cc::Task::Vector* completed_tasks) { |
vmpstr | 2d80f2ac | 2016-01-26 22:16:52 | [diff] [blame] | 297 | TRACE_EVENT0("disabled-by-default-cc.debug", |
| 298 | "RasterWorkerPool::CollectCompletedTasks"); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 299 | |
| 300 | { |
| 301 | base::AutoLock lock(lock_); |
| 302 | CollectCompletedTasksWithLockAcquired(token, completed_tasks); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | void RasterWorkerPool::CollectCompletedTasksWithLockAcquired( |
| 307 | cc::NamespaceToken token, |
| 308 | cc::Task::Vector* completed_tasks) { |
| 309 | DCHECK(token.IsValid()); |
| 310 | work_queue_.CollectCompletedTasks(token, completed_tasks); |
| 311 | } |
| 312 | |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 313 | bool RasterWorkerPool::RunTaskWithLockAcquired( |
| 314 | const std::vector<cc::TaskCategory>& categories) { |
| 315 | for (const auto& category : categories) { |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 316 | if (work_queue_.HasReadyToRunTasksForCategory(category)) { |
ericrk | 7795c700 | 2016-01-21 22:49:18 | [diff] [blame] | 317 | RunTaskInCategoryWithLockAcquired(category); |
| 318 | return true; |
| 319 | } |
| 320 | } |
| 321 | return false; |
| 322 | } |
| 323 | |
| 324 | void RasterWorkerPool::RunTaskInCategoryWithLockAcquired( |
| 325 | cc::TaskCategory category) { |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 326 | TRACE_EVENT0("toplevel", "TaskGraphRunner::RunTask"); |
| 327 | |
| 328 | lock_.AssertAcquired(); |
| 329 | |
ericrk | 5a1188c6 | 2015-12-18 22:04:04 | [diff] [blame] | 330 | auto prioritized_task = work_queue_.GetNextTaskToRun(category); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 331 | cc::Task* task = prioritized_task.task; |
| 332 | |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 333 | // Call WillRun() before releasing |lock_| and running task. |
| 334 | task->WillRun(); |
| 335 | |
| 336 | { |
| 337 | base::AutoUnlock unlock(lock_); |
| 338 | |
| 339 | task->RunOnWorkerThread(); |
| 340 | } |
| 341 | |
| 342 | // This will mark task as finished running. |
| 343 | task->DidRun(); |
| 344 | |
| 345 | work_queue_.CompleteTask(prioritized_task); |
| 346 | |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 347 | // We may have just dequeued more tasks, wake up the other worker threads. |
| 348 | if (work_queue_.HasReadyToRunTasks()) |
| 349 | has_ready_to_run_tasks_cv_.Broadcast(); |
| 350 | |
ericrk | e3e5b6f | 2015-12-02 00:00:37 | [diff] [blame] | 351 | // If namespace has finished running all tasks, wake up origin threads. |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 352 | if (work_queue_.HasFinishedRunningTasksInNamespace( |
| 353 | prioritized_task.task_namespace)) |
skyostil | a1c7eb7 | 2016-02-12 17:14:08 | [diff] [blame] | 354 | has_namespaces_with_finished_running_tasks_cv_.Broadcast(); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 355 | } |
| 356 | |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 357 | RasterWorkerPool::ClosureTask::ClosureTask(const base::Closure& closure) |
| 358 | : closure_(closure) {} |
| 359 | |
| 360 | // Overridden from cc::Task: |
| 361 | void RasterWorkerPool::ClosureTask::RunOnWorkerThread() { |
| 362 | closure_.Run(); |
| 363 | closure_.Reset(); |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 364 | } |
dcastagna | 4517a18 | 2015-08-05 19:51:03 | [diff] [blame] | 365 | |
| 366 | RasterWorkerPool::ClosureTask::~ClosureTask() {} |
| 367 | |
| 368 | } // namespace content |