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 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 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 // tasks posted to the main loop. The batch size is 1 by default. | 84 // tasks posted to the main loop. The batch size is 1 by default. |
| 84 void SetWorkBatchSize(int work_batch_size); | 85 void SetWorkBatchSize(int work_batch_size); |
| 85 | 86 |
| 86 // When given a non-null TaskTimeTracker, the TaskQueueManager calls its | 87 // When given a non-null TaskTimeTracker, the TaskQueueManager calls its |
| 87 // ReportTaskTime method for every top level task. The task_time_tracker must | 88 // ReportTaskTime method for every top level task. The task_time_tracker must |
| 88 // outlive this object, or be removed via SetTaskTimeTracker(nullptr). | 89 // outlive this object, or be removed via SetTaskTimeTracker(nullptr). |
| 89 void SetTaskTimeTracker(TaskTimeTracker* task_time_tracker) { | 90 void SetTaskTimeTracker(TaskTimeTracker* task_time_tracker) { |
| 90 task_time_tracker_ = task_time_tracker; | 91 task_time_tracker_ = task_time_tracker; |
| 91 } | 92 } |
| 92 | 93 |
| 94 void AddTaskTimeObserver(WebThread::TaskTimeObserver* task_time_observer) { | |
| 95 // FIX ME: Make this a list! | |
| 96 task_time_observer_ = task_time_observer; | |
| 97 } | |
| 98 | |
| 99 void RemoveTaskTimeObserver(WebThread::TaskTimeObserver* task_time_observer) { | |
| 100 // FIX ME: Remove from list! | |
| 101 task_time_observer_ = nullptr; | |
| 102 } | |
| 103 | |
| 93 // These functions can only be called on the same thread that the task queue | 104 // These functions can only be called on the same thread that the task queue |
| 94 // manager executes its tasks on. | 105 // manager executes its tasks on. |
| 95 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); | 106 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); |
| 96 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); | 107 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); |
| 97 | 108 |
| 98 // Returns true if any task from a monitored task queue was was run since the | 109 // Returns true if any task from a monitored task queue was was run since the |
| 99 // last call to GetAndClearSystemIsQuiescentBit. | 110 // last call to GetAndClearSystemIsQuiescentBit. |
| 100 bool GetAndClearSystemIsQuiescentBit(); | 111 bool GetAndClearSystemIsQuiescentBit(); |
| 101 | 112 |
| 102 // Creates a task queue with the given |spec|. Must be called on the thread | 113 // Creates a task queue with the given |spec|. Must be called on the thread |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 // Protects |other_thread_pending_wakeups_|. | 253 // Protects |other_thread_pending_wakeups_|. |
| 243 mutable base::Lock other_thread_lock_; | 254 mutable base::Lock other_thread_lock_; |
| 244 std::set<base::TimeTicks> other_thread_pending_wakeups_; | 255 std::set<base::TimeTicks> other_thread_pending_wakeups_; |
| 245 | 256 |
| 246 int work_batch_size_; | 257 int work_batch_size_; |
| 247 size_t task_count_; | 258 size_t task_count_; |
| 248 | 259 |
| 249 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; | 260 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
| 250 | 261 |
| 251 TaskTimeTracker* task_time_tracker_; // NOT OWNED | 262 TaskTimeTracker* task_time_tracker_; // NOT OWNED |
| 263 WebThread::TaskTimeObserver* task_time_observer_; // NOT OWNED | |
|
Sami
2016/08/19 14:44:56
Could we define this interface here instead? In pr
panicker
2016/08/19 18:06:50
Could you clarify the base/-core/ issue here? Is p
| |
| 252 | 264 |
| 253 const char* tracing_category_; | 265 const char* tracing_category_; |
| 254 const char* disabled_by_default_tracing_category_; | 266 const char* disabled_by_default_tracing_category_; |
| 255 const char* disabled_by_default_verbose_tracing_category_; | 267 const char* disabled_by_default_verbose_tracing_category_; |
| 256 | 268 |
| 257 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED | 269 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED |
| 258 | 270 |
| 259 Observer* observer_; // NOT OWNED | 271 Observer* observer_; // NOT OWNED |
| 260 scoped_refptr<DeletionSentinel> deletion_sentinel_; | 272 scoped_refptr<DeletionSentinel> deletion_sentinel_; |
| 261 base::WeakPtrFactory<TaskQueueManager> weak_factory_; | 273 base::WeakPtrFactory<TaskQueueManager> weak_factory_; |
| 262 | 274 |
| 263 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); | 275 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); |
| 264 }; | 276 }; |
| 265 | 277 |
| 266 } // namespace scheduler | 278 } // namespace scheduler |
| 267 } // namespace blink | 279 } // namespace blink |
| 268 | 280 |
| 269 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ | 281 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ |
| OLD | NEW |