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" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 AddTaskTimeTracker(TaskTimeTracker* task_time_tracker); | |
Sami
2016/08/23 10:34:59
naming bikeshed: Should we rename this to TaskTime
panicker
2016/08/23 18:08:23
Sure, I'm fine with that.
Although I'd prefer to m
| |
91 void RemoveTaskTimeTracker(TaskTimeTracker* task_time_tracker); | |
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 base::ObserverList<TaskTimeTracker> task_time_trackers_; |
252 | 247 |
253 const char* tracing_category_; | 248 const char* tracing_category_; |
254 const char* disabled_by_default_tracing_category_; | 249 const char* disabled_by_default_tracing_category_; |
255 const char* disabled_by_default_verbose_tracing_category_; | 250 const char* disabled_by_default_verbose_tracing_category_; |
256 | 251 |
257 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED | 252 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED |
258 | 253 |
259 Observer* observer_; // NOT OWNED | 254 Observer* observer_; // NOT OWNED |
260 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 255 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
261 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 256 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
262 | 257 |
263 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 258 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
264 }; | 259 }; |
265 | 260 |
266 } // namespace scheduler | 261 } // namespace scheduler |
267 } // namespace blink | 262 } // namespace blink |
268 | 263 |
269 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ | 264 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ |
OLD | NEW |