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/categorized_worker_pool.h" | 5 #include "content/renderer/categorized_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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 cc::TaskGraphRunner* task_graph_runner) | 50 cc::TaskGraphRunner* task_graph_runner) |
51 : task_graph_runner_(task_graph_runner), | 51 : task_graph_runner_(task_graph_runner), |
52 namespace_token_(task_graph_runner->GenerateNamespaceToken()) {} | 52 namespace_token_(task_graph_runner->GenerateNamespaceToken()) {} |
53 | 53 |
54 // Overridden from base::TaskRunner: | 54 // Overridden from base::TaskRunner: |
55 bool PostDelayedTask(const tracked_objects::Location& from_here, | 55 bool PostDelayedTask(const tracked_objects::Location& from_here, |
56 base::OnceClosure task, | 56 base::OnceClosure task, |
57 base::TimeDelta delay) override { | 57 base::TimeDelta delay) override { |
58 return PostNonNestableDelayedTask(from_here, std::move(task), delay); | 58 return PostNonNestableDelayedTask(from_here, std::move(task), delay); |
59 } | 59 } |
60 bool RunsTasksOnCurrentThread() const override { return true; } | 60 bool RunsTasksInCurrentSequence() const override { return true; } |
61 | 61 |
62 // Overridden from base::SequencedTaskRunner: | 62 // Overridden from base::SequencedTaskRunner: |
63 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 63 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
64 base::OnceClosure task, | 64 base::OnceClosure task, |
65 base::TimeDelta delay) override { | 65 base::TimeDelta delay) override { |
66 DCHECK(task); | 66 DCHECK(task); |
67 base::AutoLock lock(lock_); | 67 base::AutoLock lock(lock_); |
68 | 68 |
69 // Remove completed tasks. | 69 // Remove completed tasks. |
70 DCHECK(completed_tasks_.empty()); | 70 DCHECK(completed_tasks_.empty()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 graph_.nodes.push_back( | 211 graph_.nodes.push_back( |
212 cc::TaskGraph::Node(graph_task.get(), cc::TASK_CATEGORY_FOREGROUND, | 212 cc::TaskGraph::Node(graph_task.get(), cc::TASK_CATEGORY_FOREGROUND, |
213 0u /* priority */, 0u /* dependencies */)); | 213 0u /* priority */, 0u /* dependencies */)); |
214 } | 214 } |
215 | 215 |
216 ScheduleTasksWithLockAcquired(namespace_token_, &graph_); | 216 ScheduleTasksWithLockAcquired(namespace_token_, &graph_); |
217 completed_tasks_.clear(); | 217 completed_tasks_.clear(); |
218 return true; | 218 return true; |
219 } | 219 } |
220 | 220 |
221 bool CategorizedWorkerPool::RunsTasksOnCurrentThread() const { | 221 bool CategorizedWorkerPool::RunsTasksInCurrentSequence() const { |
222 return true; | 222 return true; |
223 } | 223 } |
224 | 224 |
225 void CategorizedWorkerPool::Run( | 225 void CategorizedWorkerPool::Run( |
226 const std::vector<cc::TaskCategory>& categories, | 226 const std::vector<cc::TaskCategory>& categories, |
227 base::ConditionVariable* has_ready_to_run_tasks_cv) { | 227 base::ConditionVariable* has_ready_to_run_tasks_cv) { |
228 base::AutoLock lock(lock_); | 228 base::AutoLock lock(lock_); |
229 | 229 |
230 while (true) { | 230 while (true) { |
231 if (!RunTaskWithLockAcquired(categories)) { | 231 if (!RunTaskWithLockAcquired(categories)) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 : closure_(std::move(closure)) {} | 419 : closure_(std::move(closure)) {} |
420 | 420 |
421 // Overridden from cc::Task: | 421 // Overridden from cc::Task: |
422 void CategorizedWorkerPool::ClosureTask::RunOnWorkerThread() { | 422 void CategorizedWorkerPool::ClosureTask::RunOnWorkerThread() { |
423 std::move(closure_).Run(); | 423 std::move(closure_).Run(); |
424 } | 424 } |
425 | 425 |
426 CategorizedWorkerPool::ClosureTask::~ClosureTask() {} | 426 CategorizedWorkerPool::ClosureTask::~ClosureTask() {} |
427 | 427 |
428 } // namespace content | 428 } // namespace content |
OLD | NEW |