| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 base::TimeTicks delayed_run_time, |
| 98 int sequence_num, |
| 98 base::TimeTicks now); | 99 base::TimeTicks now); |
| 99 | 100 |
| 100 // Cancels any scheduled calls to TaskQueueImpl::WakeUpForDelayedWork for | 101 // Cancels any scheduled calls to TaskQueueImpl::WakeUpForDelayedWork for |
| 101 // |queue|. | 102 // |queue|. |
| 102 void CancelDelayedWork(internal::TaskQueueImpl* queue); | 103 void CancelDelayedWork(internal::TaskQueueImpl* queue); |
| 103 | 104 |
| 104 // Registers the |queue|. | 105 // Registers the |queue|. |
| 105 void RegisterQueue(internal::TaskQueueImpl* queue); | 106 void RegisterQueue(internal::TaskQueueImpl* queue); |
| 106 | 107 |
| 107 // Removes |queue| from all internal data structures. | 108 // Removes |queue| from all internal data structures. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 132 // has elapsed. | 133 // has elapsed. |
| 133 void WakeupReadyDelayedQueues(LazyNow* lazy_now); | 134 void WakeupReadyDelayedQueues(LazyNow* lazy_now); |
| 134 | 135 |
| 135 size_t NumberOfScheduledWakeups() const { | 136 size_t NumberOfScheduledWakeups() const { |
| 136 return delayed_wakeup_queue_.size(); | 137 return delayed_wakeup_queue_.size(); |
| 137 } | 138 } |
| 138 | 139 |
| 139 private: | 140 private: |
| 140 struct DelayedWakeup { | 141 struct DelayedWakeup { |
| 141 base::TimeTicks time; | 142 base::TimeTicks time; |
| 143 int sequence_num; |
| 142 internal::TaskQueueImpl* queue; | 144 internal::TaskQueueImpl* queue; |
| 143 | 145 |
| 144 bool operator<=(const DelayedWakeup& other) const { | 146 bool operator<=(const DelayedWakeup& other) const { |
| 145 if (time == other.time) | 147 if (time == other.time) { |
| 146 return queue <= other.queue; | 148 DCHECK_NE(sequence_num, other.sequence_num); |
| 149 return (sequence_num - other.sequence_num) < 0; |
| 150 } |
| 147 return time < other.time; | 151 return time < other.time; |
| 148 } | 152 } |
| 149 | 153 |
| 150 void SetHeapHandle(HeapHandle handle) { | 154 void SetHeapHandle(HeapHandle handle) { |
| 151 DCHECK(handle.IsValid()); | 155 DCHECK(handle.IsValid()); |
| 152 queue->set_heap_handle(handle); | 156 queue->set_heap_handle(handle); |
| 153 } | 157 } |
| 154 | 158 |
| 155 void ClearHeapHandle() { | 159 void ClearHeapHandle() { |
| 156 DCHECK(queue->heap_handle().IsValid()); | 160 DCHECK(queue->heap_handle().IsValid()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 167 | 171 |
| 168 base::ThreadChecker main_thread_checker_; | 172 base::ThreadChecker main_thread_checker_; |
| 169 | 173 |
| 170 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 174 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
| 171 }; | 175 }; |
| 172 | 176 |
| 173 } // namespace scheduler | 177 } // namespace scheduler |
| 174 } // namespace blink | 178 } // namespace blink |
| 175 | 179 |
| 176 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 180 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| OLD | NEW |