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 #ifndef CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ | 5 #ifndef CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ |
6 #define CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ | 6 #define CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // schedule a graph of tasks with their dependencies. | 29 // schedule a graph of tasks with their dependencies. |
30 // 3. CreateSequencedTaskRunner() creates a sequenced task runner that might run | 30 // 3. CreateSequencedTaskRunner() creates a sequenced task runner that might run |
31 // in parallel with other instances of sequenced task runners. | 31 // in parallel with other instances of sequenced task runners. |
32 class CONTENT_EXPORT CategorizedWorkerPool : public base::TaskRunner, | 32 class CONTENT_EXPORT CategorizedWorkerPool : public base::TaskRunner, |
33 public cc::TaskGraphRunner { | 33 public cc::TaskGraphRunner { |
34 public: | 34 public: |
35 CategorizedWorkerPool(); | 35 CategorizedWorkerPool(); |
36 | 36 |
37 // Overridden from base::TaskRunner: | 37 // Overridden from base::TaskRunner: |
38 bool PostDelayedTask(const tracked_objects::Location& from_here, | 38 bool PostDelayedTask(const tracked_objects::Location& from_here, |
39 const base::Closure& task, | 39 base::OnceClosure task, |
40 base::TimeDelta delay) override; | 40 base::TimeDelta delay) override; |
41 bool RunsTasksOnCurrentThread() const override; | 41 bool RunsTasksOnCurrentThread() const override; |
42 | 42 |
43 // Overridden from cc::TaskGraphRunner: | 43 // Overridden from cc::TaskGraphRunner: |
44 cc::NamespaceToken GetNamespaceToken() override; | 44 cc::NamespaceToken GetNamespaceToken() override; |
45 void ScheduleTasks(cc::NamespaceToken token, cc::TaskGraph* graph) override; | 45 void ScheduleTasks(cc::NamespaceToken token, cc::TaskGraph* graph) override; |
46 void WaitForTasksToFinishRunning(cc::NamespaceToken token) override; | 46 void WaitForTasksToFinishRunning(cc::NamespaceToken token) override; |
47 void CollectCompletedTasks(cc::NamespaceToken token, | 47 void CollectCompletedTasks(cc::NamespaceToken token, |
48 cc::Task::Vector* completed_tasks) override; | 48 cc::Task::Vector* completed_tasks) override; |
49 | 49 |
(...skipping 24 matching lines...) Expand all Loading... |
74 | 74 |
75 private: | 75 private: |
76 class CategorizedWorkerPoolSequencedTaskRunner; | 76 class CategorizedWorkerPoolSequencedTaskRunner; |
77 friend class CategorizedWorkerPoolSequencedTaskRunner; | 77 friend class CategorizedWorkerPoolSequencedTaskRunner; |
78 | 78 |
79 // Simple Task for the TaskGraphRunner that wraps a closure. | 79 // Simple Task for the TaskGraphRunner that wraps a closure. |
80 // This class is used to schedule TaskRunner tasks on the | 80 // This class is used to schedule TaskRunner tasks on the |
81 // |task_graph_runner_|. | 81 // |task_graph_runner_|. |
82 class ClosureTask : public cc::Task { | 82 class ClosureTask : public cc::Task { |
83 public: | 83 public: |
84 explicit ClosureTask(const base::Closure& closure); | 84 explicit ClosureTask(base::OnceClosure closure); |
85 | 85 |
86 // Overridden from cc::Task: | 86 // Overridden from cc::Task: |
87 void RunOnWorkerThread() override; | 87 void RunOnWorkerThread() override; |
88 | 88 |
89 protected: | 89 protected: |
90 ~ClosureTask() override; | 90 ~ClosureTask() override; |
91 | 91 |
92 private: | 92 private: |
93 base::Closure closure_; | 93 base::OnceClosure closure_; |
94 | 94 |
95 DISALLOW_COPY_AND_ASSIGN(ClosureTask); | 95 DISALLOW_COPY_AND_ASSIGN(ClosureTask); |
96 }; | 96 }; |
97 | 97 |
98 void ScheduleTasksWithLockAcquired(cc::NamespaceToken token, | 98 void ScheduleTasksWithLockAcquired(cc::NamespaceToken token, |
99 cc::TaskGraph* graph); | 99 cc::TaskGraph* graph); |
100 void CollectCompletedTasksWithLockAcquired(cc::NamespaceToken token, | 100 void CollectCompletedTasksWithLockAcquired(cc::NamespaceToken token, |
101 cc::Task::Vector* completed_tasks); | 101 cc::Task::Vector* completed_tasks); |
102 | 102 |
103 // Runs a task from one of the provided categories. Categories listed first | 103 // Runs a task from one of the provided categories. Categories listed first |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Condition variable that is waited on by origin threads until a namespace | 139 // Condition variable that is waited on by origin threads until a namespace |
140 // has finished running all associated tasks. | 140 // has finished running all associated tasks. |
141 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; | 141 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; |
142 // Set during shutdown. Tells Run() to return when no more tasks are pending. | 142 // Set during shutdown. Tells Run() to return when no more tasks are pending. |
143 bool shutdown_; | 143 bool shutdown_; |
144 }; | 144 }; |
145 | 145 |
146 } // namespace content | 146 } // namespace content |
147 | 147 |
148 #endif // CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ | 148 #endif // CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ |
OLD | NEW |