Index: components/scheduler/child/task_queue_impl.h |
diff --git a/components/scheduler/child/task_queue_impl.h b/components/scheduler/child/task_queue_impl.h |
index 99c565b43e234f5885221bc49aae6da8cf64037b..1e05e5ab0069ef0dbc0198ca11b332e5ec8beee7 100644 |
--- a/components/scheduler/child/task_queue_impl.h |
+++ b/components/scheduler/child/task_queue_impl.h |
@@ -27,39 +27,6 @@ |
const char* disabled_by_default_tracing_category, |
const char* disabled_by_default_verbose_tracing_category); |
- class SCHEDULER_EXPORT Task : public base::PendingTask { |
- public: |
- Task(); |
- Task(const tracked_objects::Location& posted_from, |
- const base::Closure& task, |
- int sequence_number, |
- bool nestable); |
- |
- int enqueue_order() const { |
-#ifndef NDEBUG |
- DCHECK(enqueue_order_set_); |
-#endif |
- return enqueue_order_; |
- } |
- |
- void set_enqueue_order(int enqueue_order) { |
-#ifndef NDEBUG |
- DCHECK(!enqueue_order_set_); |
- enqueue_order_set_ = true; |
-#endif |
- enqueue_order_ = enqueue_order; |
- } |
- |
- private: |
-#ifndef NDEBUG |
- bool enqueue_order_set_; |
-#endif |
- // Similar to sequence number, but the |enqueue_order| is set by |
- // EnqueueTasksLocked and is not initially defined for delayed tasks until |
- // they are enqueued on the |incoming_queue_|. |
- int enqueue_order_; |
- }; |
- |
// TaskQueue implementation. |
bool RunsTasksOnCurrentThread() const override; |
bool PostDelayedTask(const tracked_objects::Location& from_here, |
@@ -83,12 +50,12 @@ |
void UpdateWorkQueue(LazyNow* lazy_now, |
bool should_trigger_wakeup, |
- const Task* previous_task); |
- Task TakeTaskFromWorkQueue(); |
+ const base::PendingTask* previous_task); |
+ base::PendingTask TakeTaskFromWorkQueue(); |
void WillDeleteTaskQueueManager(); |
- std::queue<Task>& work_queue() { return work_queue_; } |
+ base::TaskQueue& work_queue() { return work_queue_; } |
WakeupPolicy wakeup_policy() const { |
DCHECK(main_thread_checker_.CalledOnValidThread()); |
@@ -103,16 +70,16 @@ |
void set_task_queue_set_index(size_t set_index) { set_index_ = set_index; } |
- // If the work queue isn't empty, |enqueue_order| gets set to the enqueue |
- // order of the front task and the function returns true. Otherwise the |
- // function returns false. |
- bool GetWorkQueueFrontTaskEnqueueOrder(int* enqueue_order) const; |
+ // If the work queue isn't empty, |age| gets set to the sequence number of the |
+ // front task and the dunctio returns true. Otherwise the function returns |
+ // false. |
+ bool GetWorkQueueFrontTaskAge(int* age) const; |
bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; } |
bool GetShouldNotifyObservers() const { return should_notify_observers_; } |
// Test support functions. These should not be used in production code. |
- void PushTaskOntoWorkQueueForTest(const Task& task); |
+ void PushTaskOntoWorkQueueForTest(const base::PendingTask& task); |
void PopTaskFromWorkQueueForTest(); |
size_t WorkQueueSizeForTest() const { return work_queue_.size(); } |
@@ -159,23 +126,20 @@ |
void ScheduleDelayedWorkLocked(LazyNow* lazy_now); |
void PumpQueueLocked(); |
- bool TaskIsOlderThanQueuedTasks(const Task* task); |
+ bool TaskIsOlderThanQueuedTasks(const base::PendingTask* task); |
bool ShouldAutoPumpQueueLocked(bool should_trigger_wakeup, |
- const Task* previous_task); |
+ const base::PendingTask* previous_task); |
- enum class EnqueueOrderPolicy { SET_ENQUEUE_ORDER, DONT_SET_ENQUEUE_ORDER }; |
- |
- // Push the task onto the |incoming_queue_| and maybe allocate an |
- // enqueue_order for it based on |enqueue_order_policy|. |
- void EnqueueTaskLocked(const Task& pending_task, |
- EnqueueOrderPolicy enqueue_order_policy); |
+ // Push the task onto the |incoming_queue_| and allocate a sequence number |
+ // for it. |
+ void EnqueueTaskLocked(const base::PendingTask& pending_task); |
void TraceQueueSize(bool is_locked) const; |
- static void QueueAsValueInto(const std::queue<Task>& queue, |
+ static void QueueAsValueInto(const base::TaskQueue& queue, |
base::trace_event::TracedValue* state); |
- static void QueueAsValueInto(const std::priority_queue<Task>& queue, |
+ static void QueueAsValueInto(const base::DelayedTaskQueue& queue, |
base::trace_event::TracedValue* state); |
- static void TaskAsValueInto(const Task& task, |
+ static void TaskAsValueInto(const base::PendingTask& task, |
base::trace_event::TracedValue* state); |
// This lock protects all members in the contigious block below. |
@@ -183,9 +147,13 @@ |
mutable base::Lock lock_; |
base::PlatformThreadId thread_id_; |
TaskQueueManager* task_queue_manager_; |
- std::queue<Task> incoming_queue_; |
+ base::TaskQueue incoming_queue_; |
PumpPolicy pump_policy_; |
- std::priority_queue<Task> delayed_task_queue_; |
+ // Queue-local task sequence number for maintaining the order of delayed |
+ // tasks which are posted for the exact same time. Note that this will be |
+ // replaced by the global sequence number when the delay has elapsed. |
+ int delayed_task_sequence_number_; |
+ base::DelayedTaskQueue delayed_task_queue_; |
std::set<base::TimeTicks> in_flight_kick_delayed_tasks_; |
const char* name_; |
@@ -193,7 +161,7 @@ |
const char* disabled_by_default_verbose_tracing_category_; |
base::ThreadChecker main_thread_checker_; |
- std::queue<Task> work_queue_; |
+ base::TaskQueue work_queue_; |
WakeupPolicy wakeup_policy_; |
size_t set_index_; |
bool should_monitor_quiescence_; |