| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void RegisterQueue(internal::TaskQueueImpl* queue); | 105 void RegisterQueue(internal::TaskQueueImpl* queue); |
| 106 | 106 |
| 107 // Removes |queue| from the set of task queues that UpdateWorkQueues calls | 107 // Removes |queue| from the set of task queues that UpdateWorkQueues calls |
| 108 // UpdateWorkQueue on. Returns true if |queue| was updatable. | 108 // UpdateWorkQueue on. Returns true if |queue| was updatable. |
| 109 bool UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); | 109 bool UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); |
| 110 | 110 |
| 111 // Removes |queue| from all internal data structures. | 111 // Removes |queue| from all internal data structures. |
| 112 void UnregisterQueue(internal::TaskQueueImpl* queue); | 112 void UnregisterQueue(internal::TaskQueueImpl* queue); |
| 113 | 113 |
| 114 // Updates active queues associated with this TimeDomain. | 114 // Updates active queues associated with this TimeDomain. |
| 115 void UpdateWorkQueues(bool should_trigger_wakeup, | 115 void UpdateWorkQueues(LazyNow lazy_now); |
| 116 const internal::TaskQueueImpl::Task* previous_task, | |
| 117 LazyNow lazy_now); | |
| 118 | 116 |
| 119 // Called by the TaskQueueManager when the TimeDomain is registered. | 117 // Called by the TaskQueueManager when the TimeDomain is registered. |
| 120 virtual void OnRegisterWithTaskQueueManager( | 118 virtual void OnRegisterWithTaskQueueManager( |
| 121 TaskQueueManager* task_queue_manager) = 0; | 119 TaskQueueManager* task_queue_manager) = 0; |
| 122 | 120 |
| 123 // The implementaion will secedule task processing to run with |delay| with | 121 // The implementaion will secedule task processing to run with |delay| with |
| 124 // respect to the TimeDomain's time source. Always called on the main thread. | 122 // respect to the TimeDomain's time source. Always called on the main thread. |
| 125 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime | 123 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime |
| 126 // is sooner than any previously sheduled work or if there is no other | 124 // is sooner than any previously sheduled work or if there is no other |
| 127 // scheduled work. | 125 // scheduled work. |
| 128 virtual void RequestWakeup(base::TimeTicks now, base::TimeDelta delay) = 0; | 126 virtual void RequestWakeup(base::TimeTicks now, base::TimeDelta delay) = 0; |
| 129 | 127 |
| 130 // For implementation specific tracing. | 128 // For implementation specific tracing. |
| 131 virtual void AsValueIntoInternal( | 129 virtual void AsValueIntoInternal( |
| 132 base::trace_event::TracedValue* state) const = 0; | 130 base::trace_event::TracedValue* state) const = 0; |
| 133 | 131 |
| 134 // Call TaskQueueImpl::UpdateDelayedWorkQueue for each queue where the delay | 132 // Call TaskQueueImpl::UpdateDelayedWorkQueue for each queue where the delay |
| 135 // has elapsed. | 133 // has elapsed. |
| 136 void WakeupReadyDelayedQueues( | 134 void WakeupReadyDelayedQueues(LazyNow* lazy_now); |
| 137 LazyNow* lazy_now, | |
| 138 bool should_trigger_wakeup, | |
| 139 const internal::TaskQueueImpl::Task* previous_task); | |
| 140 | 135 |
| 141 protected: | 136 protected: |
| 142 // Clears expired entries from |delayed_wakeup_multimap_|. Caution needs to be | 137 // Clears expired entries from |delayed_wakeup_multimap_|. Caution needs to be |
| 143 // taken to ensure TaskQueueImpl::UpdateDelayedWorkQueue or | 138 // taken to ensure TaskQueueImpl::UpdateDelayedWorkQueue is called on the |
| 144 // TaskQueueImpl::Pump is called on the affected queues. | 139 // affected queues. |
| 145 void ClearExpiredWakeups(); | 140 void ClearExpiredWakeups(); |
| 146 | 141 |
| 147 private: | 142 private: |
| 148 void MoveNewlyUpdatableQueuesIntoUpdatableQueueSet(); | 143 void MoveNewlyUpdatableQueuesIntoUpdatableQueueSet(); |
| 149 | 144 |
| 150 typedef std::multimap<base::TimeTicks, internal::TaskQueueImpl*> | 145 typedef std::multimap<base::TimeTicks, internal::TaskQueueImpl*> |
| 151 DelayedWakeupMultimap; | 146 DelayedWakeupMultimap; |
| 152 | 147 |
| 153 DelayedWakeupMultimap delayed_wakeup_multimap_; | 148 DelayedWakeupMultimap delayed_wakeup_multimap_; |
| 154 | 149 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 | 160 |
| 166 base::ThreadChecker main_thread_checker_; | 161 base::ThreadChecker main_thread_checker_; |
| 167 | 162 |
| 168 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 163 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
| 169 }; | 164 }; |
| 170 | 165 |
| 171 } // namespace scheduler | 166 } // namespace scheduler |
| 172 } // namespace blink | 167 } // namespace blink |
| 173 | 168 |
| 174 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 169 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| OLD | NEW |