| Index: third_party/WebKit/Source/platform/scheduler/base/time_domain.h
|
| diff --git a/third_party/WebKit/Source/platform/scheduler/base/time_domain.h b/third_party/WebKit/Source/platform/scheduler/base/time_domain.h
|
| index 82db58b8f2cd520c568fbc6135675fe0d309c1f1..4c965977c2556fbccb15878d912b56fbf3a43f82 100644
|
| --- a/third_party/WebKit/Source/platform/scheduler/base/time_domain.h
|
| +++ b/third_party/WebKit/Source/platform/scheduler/base/time_domain.h
|
| @@ -31,12 +31,27 @@ class TaskQueueManager;
|
| // the wake-ups on the underlying base::MessageLoop. Various levels of de-duping
|
| // are employed to prevent unnecessary posting of TaskQueueManager::DoWork.
|
| //
|
| -// Note the TimeDomain only knows about the first wake-up per queue, it's the
|
| +// Note the TimeDomain only knows about the first wakeup per queue, it's the
|
| // responsibility of TaskQueueImpl to keep the time domain up to date if this
|
| // changes.
|
| class BLINK_PLATFORM_EXPORT TimeDomain {
|
| public:
|
| - TimeDomain();
|
| + class BLINK_PLATFORM_EXPORT Observer {
|
| + public:
|
| + virtual ~Observer() {}
|
| +
|
| + // Called when an empty TaskQueue registered with this TimeDomain has a task
|
| + // enqueued.
|
| + // |task_queue| - task queue which has immediate work scheduled.
|
| + virtual void OnTimeDomainHasImmediateWork(TaskQueue* task_queue) = 0;
|
| +
|
| + // Called when a TaskQueue registered with this TimeDomain has a delayed
|
| + // task enqueued.
|
| + // |task_queue| - task queue which has delayed work scheduled.
|
| + virtual void OnTimeDomainHasDelayedWork(TaskQueue* task_queue) = 0;
|
| + };
|
| +
|
| + explicit TimeDomain(Observer* observer);
|
| virtual ~TimeDomain();
|
|
|
| // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from
|
| @@ -71,9 +86,13 @@ class BLINK_PLATFORM_EXPORT TimeDomain {
|
| // the next task was posted to and it returns true. Returns false otherwise.
|
| bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const;
|
|
|
| + // Notifies the time domain observer (if any) that |queue| has incoming
|
| + // immediate work.
|
| + void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue);
|
| +
|
| // Schedules a call to TaskQueueImpl::WakeUpForDelayedWork when this
|
| // TimeDomain reaches |delayed_run_time|. This supersedes any previously
|
| - // registered wake-up for |queue|.
|
| + // registered wakeup for |queue|.
|
| void ScheduleDelayedWork(internal::TaskQueueImpl* queue,
|
| internal::TaskQueueImpl::DelayedWakeUp wake_up,
|
| base::TimeTicks now);
|
| @@ -97,13 +116,13 @@ class BLINK_PLATFORM_EXPORT TimeDomain {
|
| // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime
|
| // is sooner than any previously sheduled work or if there is no other
|
| // scheduled work.
|
| - virtual void RequestWakeUpAt(base::TimeTicks now,
|
| + virtual void RequestWakeupAt(base::TimeTicks now,
|
| base::TimeTicks run_time) = 0;
|
|
|
| // The implementation will cancel a wake up previously requested by
|
| - // RequestWakeUpAt. It's expected this will be a NOP for most virtual time
|
| + // RequestWakeupAt. It's expected this will be a NOP for most virtual time
|
| // domains.
|
| - virtual void CancelWakeUpAt(base::TimeTicks run_time) = 0;
|
| + virtual void CancelWakeupAt(base::TimeTicks run_time) = 0;
|
|
|
| // For implementation specific tracing.
|
| virtual void AsValueIntoInternal(
|
| @@ -111,10 +130,10 @@ class BLINK_PLATFORM_EXPORT TimeDomain {
|
|
|
| // Call TaskQueueImpl::UpdateDelayedWorkQueue for each queue where the delay
|
| // has elapsed.
|
| - void WakeUpReadyDelayedQueues(LazyNow* lazy_now);
|
| + void WakeupReadyDelayedQueues(LazyNow* lazy_now);
|
|
|
| - size_t NumberOfScheduledWakeUps() const {
|
| - return delayed_wake_up_queue_.size();
|
| + size_t NumberOfScheduledWakeups() const {
|
| + return delayed_wakeup_queue_.size();
|
| }
|
|
|
| private:
|
| @@ -135,12 +154,14 @@ class BLINK_PLATFORM_EXPORT TimeDomain {
|
| DCHECK(queue->heap_handle().IsValid());
|
| queue->set_heap_handle(HeapHandle());
|
|
|
| - DCHECK_NE(queue->scheduled_time_domain_wake_up(), base::TimeTicks());
|
| - queue->set_scheduled_time_domain_wake_up(base::TimeTicks());
|
| + DCHECK_NE(queue->scheduled_time_domain_wakeup(), base::TimeTicks());
|
| + queue->set_scheduled_time_domain_wakeup(base::TimeTicks());
|
| }
|
| };
|
|
|
| - IntrusiveHeap<ScheduledDelayedWakeUp> delayed_wake_up_queue_;
|
| + IntrusiveHeap<ScheduledDelayedWakeUp> delayed_wakeup_queue_;
|
| +
|
| + Observer* const observer_; // NOT OWNED.
|
|
|
| base::ThreadChecker main_thread_checker_;
|
|
|
|
|