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 // If there is a scheduled delayed task, |out_task_queue| is set to the queue | 89 // If there is a scheduled delayed task, |out_task_queue| is set to the queue |
90 // the next task was posted to and it returns true. Returns false otherwise. | 90 // the next task was posted to and it returns true. Returns false otherwise. |
91 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; | 91 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; |
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 LazyNow* lazy_now); | 98 base::TimeTicks now); |
99 | |
100 // Cancels any delayed work requested for |queue|. | |
101 void CancelDelayedWork(internal::TaskQueueImpl* queue); | |
102 | 99 |
103 // Registers the |queue|. | 100 // Registers the |queue|. |
104 void RegisterQueue(internal::TaskQueueImpl* queue); | 101 void RegisterQueue(internal::TaskQueueImpl* queue); |
105 | 102 |
106 // Removes |queue| from all internal data structures. | 103 // Removes |queue| from all internal data structures. |
107 void UnregisterQueue(internal::TaskQueueImpl* queue); | 104 void UnregisterQueue(internal::TaskQueueImpl* queue); |
108 | 105 |
109 // Tells the time domain that |queue| went from having no immediate work to | 106 // Tells the time domain that |queue| went from having no immediate work to |
110 // having some. | 107 // having some. |
111 void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue); | 108 void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue); |
112 | 109 |
113 // Called by the TaskQueueManager when the TimeDomain is registered. | 110 // Called by the TaskQueueManager when the TimeDomain is registered. |
114 virtual void OnRegisterWithTaskQueueManager( | 111 virtual void OnRegisterWithTaskQueueManager( |
115 TaskQueueManager* task_queue_manager) = 0; | 112 TaskQueueManager* task_queue_manager) = 0; |
116 | 113 |
117 // The implementation will schedule task processing to run at time |run_time| | 114 // The implementaion will secedule task processing to run with |delay| with |
118 // within the TimeDomain's time line. Only called from the main thread. | 115 // respect to the TimeDomain's time source. Always called on the main thread. |
119 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime | 116 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime |
120 // is sooner than any previously sheduled work or if there is no other | 117 // is sooner than any previously sheduled work or if there is no other |
121 // scheduled work. | 118 // scheduled work. |
122 virtual void RequestWakeupAt(LazyNow* lazy_now, base::TimeTicks run_time) = 0; | 119 virtual void RequestWakeup(base::TimeTicks now, base::TimeDelta delay) = 0; |
123 | |
124 // The implementation will cancel a wake up previously requested by | |
125 // RequestWakeupAt. It's expected this will be a NOP for most virtual time | |
126 // domains. | |
127 virtual void CancelWakeupAt(base::TimeTicks run_time) = 0; | |
128 | 120 |
129 // For implementation specific tracing. | 121 // For implementation specific tracing. |
130 virtual void AsValueIntoInternal( | 122 virtual void AsValueIntoInternal( |
131 base::trace_event::TracedValue* state) const = 0; | 123 base::trace_event::TracedValue* state) const = 0; |
132 | 124 |
133 // Call TaskQueueImpl::UpdateDelayedWorkQueue for each queue where the delay | 125 // Call TaskQueueImpl::UpdateDelayedWorkQueue for each queue where the delay |
134 // has elapsed. | 126 // has elapsed. |
135 void WakeupReadyDelayedQueues(LazyNow* lazy_now); | 127 void WakeupReadyDelayedQueues(LazyNow* lazy_now); |
136 | 128 |
137 size_t NumberOfScheduledWakeups() const { | 129 size_t NumberOfScheduledWakeups() const { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 161 |
170 base::ThreadChecker main_thread_checker_; | 162 base::ThreadChecker main_thread_checker_; |
171 | 163 |
172 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 164 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
173 }; | 165 }; |
174 | 166 |
175 } // namespace scheduler | 167 } // namespace scheduler |
176 } // namespace blink | 168 } // namespace blink |
177 | 169 |
178 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 170 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
OLD | NEW |