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::Closure 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 GenerateNamespaceToken() override; | 44 cc::NamespaceToken GenerateNamespaceToken() 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 28 matching lines...) Expand all Loading... |
78 | 78 |
79 private: | 79 private: |
80 class CategorizedWorkerPoolSequencedTaskRunner; | 80 class CategorizedWorkerPoolSequencedTaskRunner; |
81 friend class CategorizedWorkerPoolSequencedTaskRunner; | 81 friend class CategorizedWorkerPoolSequencedTaskRunner; |
82 | 82 |
83 // Simple Task for the TaskGraphRunner that wraps a closure. | 83 // Simple Task for the TaskGraphRunner that wraps a closure. |
84 // This class is used to schedule TaskRunner tasks on the | 84 // This class is used to schedule TaskRunner tasks on the |
85 // |task_graph_runner_|. | 85 // |task_graph_runner_|. |
86 class ClosureTask : public cc::Task { | 86 class ClosureTask : public cc::Task { |
87 public: | 87 public: |
88 explicit ClosureTask(const base::Closure& closure); | 88 explicit ClosureTask(base::Closure closure); |
89 | 89 |
90 // Overridden from cc::Task: | 90 // Overridden from cc::Task: |
91 void RunOnWorkerThread() override; | 91 void RunOnWorkerThread() override; |
92 | 92 |
93 protected: | 93 protected: |
94 ~ClosureTask() override; | 94 ~ClosureTask() override; |
95 | 95 |
96 private: | 96 private: |
97 base::Closure closure_; | 97 base::Closure closure_; |
98 | 98 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Condition variable that is waited on by origin threads until a namespace | 143 // Condition variable that is waited on by origin threads until a namespace |
144 // has finished running all associated tasks. | 144 // has finished running all associated tasks. |
145 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; | 145 base::ConditionVariable has_namespaces_with_finished_running_tasks_cv_; |
146 // Set during shutdown. Tells Run() to return when no more tasks are pending. | 146 // Set during shutdown. Tells Run() to return when no more tasks are pending. |
147 bool shutdown_; | 147 bool shutdown_; |
148 }; | 148 }; |
149 | 149 |
150 } // namespace content | 150 } // namespace content |
151 | 151 |
152 #endif // CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ | 152 #endif // CONTENT_RENDERER_CATEGORIZED_WORKER_POOL_H_ |
OLD | NEW |