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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
11 #include "base/debug/task_annotator.h" | 11 #include "base/debug/task_annotator.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/pending_task.h" | 15 #include "base/pending_task.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "platform/scheduler/base/enqueue_order.h" | 18 #include "platform/scheduler/base/enqueue_order.h" |
19 #include "platform/scheduler/base/task_queue_impl.h" | 19 #include "platform/scheduler/base/task_queue_impl.h" |
20 #include "platform/scheduler/base/task_queue_selector.h" | 20 #include "platform/scheduler/base/task_queue_selector.h" |
21 #include "public/platform/WebThread.h" | |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class TickClock; | 24 class TickClock; |
24 | 25 |
25 namespace trace_event { | 26 namespace trace_event { |
26 class ConvertableToTraceFormat; | 27 class ConvertableToTraceFormat; |
27 class TracedValue; | 28 class TracedValue; |
28 } // namespace trace_event | 29 } // namespace trace_event |
29 } // namespace base | 30 } // namespace base |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 namespace scheduler { | 33 namespace scheduler { |
33 namespace internal { | 34 namespace internal { |
34 class TaskQueueImpl; | 35 class TaskQueueImpl; |
35 } // namespace internal | 36 } // namespace internal |
36 | 37 |
37 class LazyNow; | 38 class LazyNow; |
38 class RealTimeDomain; | 39 class RealTimeDomain; |
39 class TimeDomain; | 40 class TimeDomain; |
40 class TaskQueueManagerDelegate; | 41 class TaskQueueManagerDelegate; |
41 class TaskTimeTracker; | |
42 | 42 |
43 // The task queue manager provides N task queues and a selector interface for | 43 // The task queue manager provides N task queues and a selector interface for |
44 // choosing which task queue to service next. Each task queue consists of two | 44 // choosing which task queue to service next. Each task queue consists of two |
45 // sub queues: | 45 // sub queues: |
46 // | 46 // |
47 // 1. Incoming task queue. Tasks that are posted get immediately appended here. | 47 // 1. Incoming task queue. Tasks that are posted get immediately appended here. |
48 // When a task is appended into an empty incoming queue, the task manager | 48 // When a task is appended into an empty incoming queue, the task manager |
49 // work function (DoWork) is scheduled to run on the main task runner. | 49 // work function (DoWork) is scheduled to run on the main task runner. |
50 // | 50 // |
51 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from | 51 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from |
(...skipping 24 matching lines...) Expand all Loading... | |
76 void MaybeScheduleDelayedWork(const tracked_objects::Location& from_here, | 76 void MaybeScheduleDelayedWork(const tracked_objects::Location& from_here, |
77 base::TimeTicks now, | 77 base::TimeTicks now, |
78 base::TimeDelta delay); | 78 base::TimeDelta delay); |
79 | 79 |
80 // Set the number of tasks executed in a single invocation of the task queue | 80 // Set the number of tasks executed in a single invocation of the task queue |
81 // manager. Increasing the batch size can reduce the overhead of yielding | 81 // manager. Increasing the batch size can reduce the overhead of yielding |
82 // back to the main message loop -- at the cost of potentially delaying other | 82 // back to the main message loop -- at the cost of potentially delaying other |
83 // tasks posted to the main loop. The batch size is 1 by default. | 83 // tasks posted to the main loop. The batch size is 1 by default. |
84 void SetWorkBatchSize(int work_batch_size); | 84 void SetWorkBatchSize(int work_batch_size); |
85 | 85 |
86 // When given a non-null TaskTimeTracker, the TaskQueueManager calls its | |
87 // ReportTaskTime method for every top level task. The task_time_tracker must | |
88 // outlive this object, or be removed via SetTaskTimeTracker(nullptr). | |
89 void SetTaskTimeTracker(TaskTimeTracker* task_time_tracker) { | |
90 task_time_tracker_ = task_time_tracker; | |
91 } | |
92 | |
93 // These functions can only be called on the same thread that the task queue | 86 // These functions can only be called on the same thread that the task queue |
94 // manager executes its tasks on. | 87 // manager executes its tasks on. |
95 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); | 88 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); |
96 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); | 89 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); |
90 void AddTaskTimeObserver(WebThread::TaskTimeObserver* task_time_observer); | |
Sami
2016/08/22 15:51:30
Earlier I really should've talked about base/ vs.
panickercorp
2016/08/22 16:55:45
I agree it makes sense to make it a separate inter
Sami
2016/08/22 17:02:58
The latter sounds good to me. I think we're still
panicker
2016/08/22 23:14:14
Done.
| |
91 void RemoveTaskTimeObserver(WebThread::TaskTimeObserver* task_time_observer); | |
97 | 92 |
98 // Returns true if any task from a monitored task queue was was run since the | 93 // Returns true if any task from a monitored task queue was was run since the |
99 // last call to GetAndClearSystemIsQuiescentBit. | 94 // last call to GetAndClearSystemIsQuiescentBit. |
100 bool GetAndClearSystemIsQuiescentBit(); | 95 bool GetAndClearSystemIsQuiescentBit(); |
101 | 96 |
102 // Creates a task queue with the given |spec|. Must be called on the thread | 97 // Creates a task queue with the given |spec|. Must be called on the thread |
103 // this class was created on. | 98 // this class was created on. |
104 scoped_refptr<internal::TaskQueueImpl> NewTaskQueue( | 99 scoped_refptr<internal::TaskQueueImpl> NewTaskQueue( |
105 const TaskQueue::Spec& spec); | 100 const TaskQueue::Spec& spec); |
106 | 101 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 | 236 |
242 // Protects |other_thread_pending_wakeups_|. | 237 // Protects |other_thread_pending_wakeups_|. |
243 mutable base::Lock other_thread_lock_; | 238 mutable base::Lock other_thread_lock_; |
244 std::set<base::TimeTicks> other_thread_pending_wakeups_; | 239 std::set<base::TimeTicks> other_thread_pending_wakeups_; |
245 | 240 |
246 int work_batch_size_; | 241 int work_batch_size_; |
247 size_t task_count_; | 242 size_t task_count_; |
248 | 243 |
249 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 244 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
250 | 245 |
251 TaskTimeTracker* task_time_tracker_; // NOT OWNED | 246 bool has_task_time_observer; |
alph
2016/08/22 22:21:27
Is it used?
panicker
2016/08/22 23:14:14
Removed in new patch
| |
247 base::ObserverList<WebThread::TaskTimeObserver> task_time_observers_; | |
252 | 248 |
253 const char* tracing_category_; | 249 const char* tracing_category_; |
254 const char* disabled_by_default_tracing_category_; | 250 const char* disabled_by_default_tracing_category_; |
255 const char* disabled_by_default_verbose_tracing_category_; | 251 const char* disabled_by_default_verbose_tracing_category_; |
256 | 252 |
257 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED | 253 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED |
258 | 254 |
259 Observer* observer_; // NOT OWNED | 255 Observer* observer_; // NOT OWNED |
260 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 256 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
261 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 257 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
262 | 258 |
263 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 259 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
264 }; | 260 }; |
265 | 261 |
266 } // namespace scheduler | 262 } // namespace scheduler |
267 } // namespace blink | 263 } // namespace blink |
268 | 264 |
269 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ | 265 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ |
OLD | NEW |