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 4947fd5e0c529a79d0af9cf5a78c04b595d6f6f1..639d1742a35feec99c4355430a72a7ab048b076a 100644 |
--- a/third_party/WebKit/Source/platform/scheduler/base/time_domain.h |
+++ b/third_party/WebKit/Source/platform/scheduler/base/time_domain.h |
@@ -62,11 +62,9 @@ |
// Evaluate this TimeDomain's Now. Can be called from any thread. |
virtual base::TimeTicks Now() const = 0; |
- // Computes the delay until the next task the TimeDomain is aware of, if any. |
- // Note virtual time domains may return base::TimeDelta() if they have any |
- // tasks that are eligible to run. |
- virtual base::Optional<base::TimeDelta> DelayTillNextTask( |
- LazyNow* lazy_now) = 0; |
+ // Some TimeDomains support virtual time, this method tells us to advance time |
+ // if possible and return true if time was advanced. |
+ virtual bool MaybeAdvanceTime() = 0; |
// Returns the name of this time domain for tracing. |
virtual const char* GetName() const = 0; |
@@ -90,6 +88,10 @@ |
// the next task was posted to and it returns true. Returns false otherwise. |
bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; |
+ // Adds |queue| to the set of task queues that UpdateWorkQueues calls |
+ // UpdateWorkQueue on. |
+ void RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); |
+ |
// Schedules a call to TaskQueueImpl::WakeUpForDelayedWork when this |
// TimeDomain reaches |delayed_run_time|. This supersedes any previously |
// registered wakeup for |queue|. |
@@ -100,12 +102,15 @@ |
// Registers the |queue|. |
void RegisterQueue(internal::TaskQueueImpl* queue); |
+ // Removes |queue| from the set of task queues that UpdateWorkQueues calls |
+ // UpdateWorkQueue on. Returns true if |queue| was updatable. |
+ bool UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); |
+ |
// Removes |queue| from all internal data structures. |
void UnregisterQueue(internal::TaskQueueImpl* queue); |
- // Tells the time domain that |queue| went from having no immediate work to |
- // having some. |
- void OnQueueHasImmediateWork(internal::TaskQueueImpl* queue); |
+ // Updates active queues associated with this TimeDomain. |
+ void UpdateWorkQueues(LazyNow lazy_now); |
// Called by the TaskQueueManager when the TimeDomain is registered. |
virtual void OnRegisterWithTaskQueueManager( |
@@ -131,6 +136,8 @@ |
} |
private: |
+ void MoveNewlyUpdatableQueuesIntoUpdatableQueueSet(); |
+ |
struct DelayedWakeup { |
base::TimeTicks time; |
internal::TaskQueueImpl* queue; |
@@ -157,6 +164,15 @@ |
IntrusiveHeap<DelayedWakeup> delayed_wakeup_queue_; |
+ // This lock guards only |newly_updatable_|. It's not expected to be heavily |
+ // contended. |
+ base::Lock newly_updatable_lock_; |
+ std::vector<internal::TaskQueueImpl*> newly_updatable_; |
+ |
+ // Set of task queues with avaliable work on the incoming queue. This should |
+ // only be accessed from the main thread. |
+ std::set<internal::TaskQueueImpl*> updatable_queue_set_; |
+ |
Observer* observer_; // NOT OWNED. |
base::ThreadChecker main_thread_checker_; |