Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
| 6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/atomic_sequence_num.h" | 8 #include "base/atomic_sequence_num.h" |
| 9 #include "base/debug/task_annotator.h" | 9 #include "base/debug/task_annotator.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/pending_task.h" | 13 #include "base/pending_task.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 18 #include "content/renderer/scheduler/nestable_single_thread_task_runner.h" | |
|
Sami
2015/03/12 18:53:11
Forward decl here too?
rmcilroy
2015/03/13 10:56:53
Done.
| |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 namespace trace_event { | 21 namespace trace_event { |
| 21 class ConvertableToTraceFormat; | 22 class ConvertableToTraceFormat; |
| 22 class TracedValue; | 23 class TracedValue; |
| 23 } | 24 } |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace cc { | 27 namespace cc { |
| 27 class TestNowSource; | 28 class TestNowSource; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 // automatically scheduled for execution or transferred to the work queue. | 62 // automatically scheduled for execution or transferred to the work queue. |
| 62 // Instead, the selector should call PumpQueue() when necessary to bring | 63 // Instead, the selector should call PumpQueue() when necessary to bring |
| 63 // in new tasks for execution. | 64 // in new tasks for execution. |
| 64 MANUAL | 65 MANUAL |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 // Create a task queue manager with |task_queue_count| task queues. | 68 // Create a task queue manager with |task_queue_count| task queues. |
| 68 // |main_task_runner| identifies the thread on which where the tasks are | 69 // |main_task_runner| identifies the thread on which where the tasks are |
| 69 // eventually run. |selector| is used to choose which task queue to service. | 70 // eventually run. |selector| is used to choose which task queue to service. |
| 70 // It should outlive this class. | 71 // It should outlive this class. |
| 71 TaskQueueManager(size_t task_queue_count, | 72 TaskQueueManager( |
| 72 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 73 size_t task_queue_count, |
| 73 TaskQueueSelector* selector); | 74 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner, |
| 75 TaskQueueSelector* selector); | |
| 74 ~TaskQueueManager(); | 76 ~TaskQueueManager(); |
| 75 | 77 |
| 76 // Returns the task runner which targets the queue selected by |queue_index|. | 78 // Returns the task runner which targets the queue selected by |queue_index|. |
| 77 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue( | 79 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue( |
| 78 size_t queue_index) const; | 80 size_t queue_index) const; |
| 79 | 81 |
| 80 // Sets the pump policy for the |queue_index| to |pump_policy|. By | 82 // Sets the pump policy for the |queue_index| to |pump_policy|. By |
| 81 // default queues are created with AUTO_PUMP_POLICY. | 83 // default queues are created with AUTO_PUMP_POLICY. |
| 82 void SetPumpPolicy(size_t queue_index, PumpPolicy pump_policy); | 84 void SetPumpPolicy(size_t queue_index, PumpPolicy pump_policy); |
| 83 | 85 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 base::TimeTicks Now() const; | 164 base::TimeTicks Now() const; |
| 163 | 165 |
| 164 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 166 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 165 AsValueWithSelectorResult(bool should_run, size_t selected_queue) const; | 167 AsValueWithSelectorResult(bool should_run, size_t selected_queue) const; |
| 166 | 168 |
| 167 std::vector<scoped_refptr<internal::TaskQueue>> queues_; | 169 std::vector<scoped_refptr<internal::TaskQueue>> queues_; |
| 168 base::AtomicSequenceNumber task_sequence_num_; | 170 base::AtomicSequenceNumber task_sequence_num_; |
| 169 base::debug::TaskAnnotator task_annotator_; | 171 base::debug::TaskAnnotator task_annotator_; |
| 170 | 172 |
| 171 base::ThreadChecker main_thread_checker_; | 173 base::ThreadChecker main_thread_checker_; |
| 172 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 174 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner_; |
| 173 TaskQueueSelector* selector_; | 175 TaskQueueSelector* selector_; |
| 174 | 176 |
| 175 base::WeakPtr<TaskQueueManager> task_queue_manager_weak_ptr_; | 177 base::WeakPtr<TaskQueueManager> task_queue_manager_weak_ptr_; |
| 176 | 178 |
| 177 // The pending_dowork_count_ is only tracked on the main thread since that's | 179 // The pending_dowork_count_ is only tracked on the main thread since that's |
| 178 // where re-entrant problems happen. | 180 // where re-entrant problems happen. |
| 179 int pending_dowork_count_; | 181 int pending_dowork_count_; |
| 180 | 182 |
| 181 int work_batch_size_; | 183 int work_batch_size_; |
| 182 | 184 |
| 183 scoped_refptr<cc::TestNowSource> time_source_; | 185 scoped_refptr<cc::TestNowSource> time_source_; |
| 184 | 186 |
| 185 ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 187 ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
| 186 | 188 |
| 187 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 189 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
| 188 | 190 |
| 189 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 191 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
| 190 }; | 192 }; |
| 191 | 193 |
| 192 } // namespace content | 194 } // namespace content |
| 193 | 195 |
| 194 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ | 196 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_MANAGER_H_ |
| OLD | NEW |