| 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; | 87 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; |
| 88 | 88 |
| 89 // Notifies the time domain observer (if any) that |queue| has incoming | 89 // Notifies the time domain observer (if any) that |queue| has incoming |
| 90 // immediate work. | 90 // immediate work. |
| 91 void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue); | 91 void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue); |
| 92 | 92 |
| 93 // Schedules a call to TaskQueueImpl::WakeUpForDelayedWork when this | 93 // Schedules a call to TaskQueueImpl::WakeUpForDelayedWork when this |
| 94 // TimeDomain reaches |delayed_run_time|. This supersedes any previously | 94 // TimeDomain reaches |delayed_run_time|. This supersedes any previously |
| 95 // registered wakeup for |queue|. | 95 // registered wakeup for |queue|. |
| 96 void ScheduleDelayedWork(internal::TaskQueueImpl* queue, | 96 void ScheduleDelayedWork(internal::TaskQueueImpl* queue, |
| 97 base::TimeTicks delayed_run_time, | 97 internal::TaskQueueImpl::DelayedWakeUp wake_up, |
| 98 base::TimeTicks now); | 98 base::TimeTicks now); |
| 99 | 99 |
| 100 // Cancels any scheduled calls to TaskQueueImpl::WakeUpForDelayedWork for | 100 // Cancels any scheduled calls to TaskQueueImpl::WakeUpForDelayedWork for |
| 101 // |queue|. | 101 // |queue|. |
| 102 void CancelDelayedWork(internal::TaskQueueImpl* queue); | 102 void CancelDelayedWork(internal::TaskQueueImpl* queue); |
| 103 | 103 |
| 104 // Registers the |queue|. | 104 // Registers the |queue|. |
| 105 void RegisterQueue(internal::TaskQueueImpl* queue); | 105 void RegisterQueue(internal::TaskQueueImpl* queue); |
| 106 | 106 |
| 107 // Removes |queue| from all internal data structures. | 107 // Removes |queue| from all internal data structures. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 130 | 130 |
| 131 // Call TaskQueueImpl::UpdateDelayedWorkQueue for each queue where the delay | 131 // Call TaskQueueImpl::UpdateDelayedWorkQueue for each queue where the delay |
| 132 // has elapsed. | 132 // has elapsed. |
| 133 void WakeupReadyDelayedQueues(LazyNow* lazy_now); | 133 void WakeupReadyDelayedQueues(LazyNow* lazy_now); |
| 134 | 134 |
| 135 size_t NumberOfScheduledWakeups() const { | 135 size_t NumberOfScheduledWakeups() const { |
| 136 return delayed_wakeup_queue_.size(); | 136 return delayed_wakeup_queue_.size(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 struct DelayedWakeup { | 140 struct ScheduledDelayedWakeUp { |
| 141 base::TimeTicks time; | 141 internal::TaskQueueImpl::DelayedWakeUp wake_up; |
| 142 internal::TaskQueueImpl* queue; | 142 internal::TaskQueueImpl* queue; |
| 143 | 143 |
| 144 bool operator<=(const DelayedWakeup& other) const { | 144 bool operator<=(const ScheduledDelayedWakeUp& other) const { |
| 145 if (time == other.time) | 145 return wake_up <= other.wake_up; |
| 146 return queue <= other.queue; | |
| 147 return time < other.time; | |
| 148 } | 146 } |
| 149 | 147 |
| 150 void SetHeapHandle(HeapHandle handle) { | 148 void SetHeapHandle(HeapHandle handle) { |
| 151 DCHECK(handle.IsValid()); | 149 DCHECK(handle.IsValid()); |
| 152 queue->set_heap_handle(handle); | 150 queue->set_heap_handle(handle); |
| 153 } | 151 } |
| 154 | 152 |
| 155 void ClearHeapHandle() { | 153 void ClearHeapHandle() { |
| 156 DCHECK(queue->heap_handle().IsValid()); | 154 DCHECK(queue->heap_handle().IsValid()); |
| 157 queue->set_heap_handle(HeapHandle()); | 155 queue->set_heap_handle(HeapHandle()); |
| 158 | 156 |
| 159 DCHECK_NE(queue->scheduled_time_domain_wakeup(), base::TimeTicks()); | 157 DCHECK_NE(queue->scheduled_time_domain_wakeup(), base::TimeTicks()); |
| 160 queue->set_scheduled_time_domain_wakeup(base::TimeTicks()); | 158 queue->set_scheduled_time_domain_wakeup(base::TimeTicks()); |
| 161 } | 159 } |
| 162 }; | 160 }; |
| 163 | 161 |
| 164 IntrusiveHeap<DelayedWakeup> delayed_wakeup_queue_; | 162 IntrusiveHeap<ScheduledDelayedWakeUp> delayed_wakeup_queue_; |
| 165 | 163 |
| 166 Observer* const observer_; // NOT OWNED. | 164 Observer* const observer_; // NOT OWNED. |
| 167 | 165 |
| 168 base::ThreadChecker main_thread_checker_; | 166 base::ThreadChecker main_thread_checker_; |
| 169 | 167 |
| 170 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 168 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
| 171 }; | 169 }; |
| 172 | 170 |
| 173 } // namespace scheduler | 171 } // namespace scheduler |
| 174 } // namespace blink | 172 } // namespace blink |
| 175 | 173 |
| 176 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 174 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| OLD | NEW |