| 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_SCHEDULER_TASK_QUEUE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_IMPL_H_ | 6 #define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/pending_task.h" | 10 #include "base/pending_task.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 base::TimeDelta delay) override; | 71 base::TimeDelta delay) override; |
| 72 bool PostDelayedTaskAt(const tracked_objects::Location& from_here, | 72 bool PostDelayedTaskAt(const tracked_objects::Location& from_here, |
| 73 const base::Closure& task, | 73 const base::Closure& task, |
| 74 base::TimeTicks desired_run_time) override; | 74 base::TimeTicks desired_run_time) override; |
| 75 | 75 |
| 76 bool IsQueueEnabled() const override; | 76 bool IsQueueEnabled() const override; |
| 77 QueueState GetQueueState() const override; | 77 QueueState GetQueueState() const override; |
| 78 void SetQueuePriority(QueuePriority priority) override; | 78 void SetQueuePriority(QueuePriority priority) override; |
| 79 void PumpQueue() override; | 79 void PumpQueue() override; |
| 80 void SetPumpPolicy(PumpPolicy pump_policy) override; | 80 void SetPumpPolicy(PumpPolicy pump_policy) override; |
| 81 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; |
| 82 void RemoveTaskObserver( |
| 83 base::MessageLoop::TaskObserver* task_observer) override; |
| 81 | 84 |
| 82 bool NextPendingDelayedTaskRunTime( | 85 bool NextPendingDelayedTaskRunTime( |
| 83 base::TimeTicks* next_pending_delayed_task); | 86 base::TimeTicks* next_pending_delayed_task); |
| 84 | 87 |
| 85 void UpdateWorkQueue(LazyNow* lazy_now, | 88 void UpdateWorkQueue(LazyNow* lazy_now, |
| 86 bool should_trigger_wakeup, | 89 bool should_trigger_wakeup, |
| 87 const Task* previous_task); | 90 const Task* previous_task); |
| 88 Task TakeTaskFromWorkQueue(); | 91 Task TakeTaskFromWorkQueue(); |
| 89 | 92 |
| 90 std::queue<Task>& work_queue() { return work_queue_; } | 93 std::queue<Task>& work_queue() { return work_queue_; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 void set_task_queue_set_index(size_t set_index) { set_index_ = set_index; } | 106 void set_task_queue_set_index(size_t set_index) { set_index_ = set_index; } |
| 104 | 107 |
| 105 // If the work queue isn't empty, |enqueue_order| gets set to the enqueue | 108 // If the work queue isn't empty, |enqueue_order| gets set to the enqueue |
| 106 // order of the front task and the function returns true. Otherwise the | 109 // order of the front task and the function returns true. Otherwise the |
| 107 // function returns false. | 110 // function returns false. |
| 108 bool GetWorkQueueFrontTaskEnqueueOrder(int* enqueue_order) const; | 111 bool GetWorkQueueFrontTaskEnqueueOrder(int* enqueue_order) const; |
| 109 | 112 |
| 110 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; } | 113 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; } |
| 111 bool GetShouldNotifyObservers() const { return should_notify_observers_; } | 114 bool GetShouldNotifyObservers() const { return should_notify_observers_; } |
| 112 | 115 |
| 116 void NotifyWillProcessTask(const base::PendingTask& pending_task); |
| 117 void NotifyDidProcessTask(const base::PendingTask& pending_task); |
| 118 |
| 113 // Delayed task posted to the underlying run loop, which locks |lock_| and | 119 // Delayed task posted to the underlying run loop, which locks |lock_| and |
| 114 // calls MoveReadyDelayedTasksToIncomingQueueLocked to process dealyed tasks | 120 // calls MoveReadyDelayedTasksToIncomingQueueLocked to process dealyed tasks |
| 115 // that need to be run now. Thread safe, but in practice it's always called | 121 // that need to be run now. Thread safe, but in practice it's always called |
| 116 // from the main thread. | 122 // from the main thread. |
| 117 void MoveReadyDelayedTasksToIncomingQueue(LazyNow* lazy_now); | 123 void MoveReadyDelayedTasksToIncomingQueue(LazyNow* lazy_now); |
| 118 | 124 |
| 119 // Test support functions. These should not be used in production code. | 125 // Test support functions. These should not be used in production code. |
| 120 void PushTaskOntoWorkQueueForTest(const Task& task); | 126 void PushTaskOntoWorkQueueForTest(const Task& task); |
| 121 void PopTaskFromWorkQueueForTest(); | 127 void PopTaskFromWorkQueueForTest(); |
| 122 size_t WorkQueueSizeForTest() const { return work_queue_.size(); } | 128 size_t WorkQueueSizeForTest() const { return work_queue_.size(); } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 std::queue<Task> incoming_queue_; | 190 std::queue<Task> incoming_queue_; |
| 185 PumpPolicy pump_policy_; | 191 PumpPolicy pump_policy_; |
| 186 std::priority_queue<Task> delayed_task_queue_; | 192 std::priority_queue<Task> delayed_task_queue_; |
| 187 | 193 |
| 188 const char* name_; | 194 const char* name_; |
| 189 const char* disabled_by_default_tracing_category_; | 195 const char* disabled_by_default_tracing_category_; |
| 190 const char* disabled_by_default_verbose_tracing_category_; | 196 const char* disabled_by_default_verbose_tracing_category_; |
| 191 | 197 |
| 192 base::ThreadChecker main_thread_checker_; | 198 base::ThreadChecker main_thread_checker_; |
| 193 std::queue<Task> work_queue_; | 199 std::queue<Task> work_queue_; |
| 200 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; |
| 194 WakeupPolicy wakeup_policy_; | 201 WakeupPolicy wakeup_policy_; |
| 195 size_t set_index_; | 202 size_t set_index_; |
| 196 bool should_monitor_quiescence_; | 203 bool should_monitor_quiescence_; |
| 197 bool should_notify_observers_; | 204 bool should_notify_observers_; |
| 198 | 205 |
| 199 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); | 206 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); |
| 200 }; | 207 }; |
| 201 | 208 |
| 202 } // namespace internal | 209 } // namespace internal |
| 203 } // namespace scheduler | 210 } // namespace scheduler |
| 204 | 211 |
| 205 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_IMPL_H_ | 212 #endif // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_IMPL_H_ |
| OLD | NEW |