Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| index 21c4aedc800ec0af9b8e848cf3d56a5873467575..275f31dd97e609328f47245d350642d97a622d39 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h |
| @@ -74,8 +74,14 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| // runner. These delayed tasks are de-duplicated. Must be called on the thread |
| // this class was created on. |
| void MaybeScheduleDelayedWork(const tracked_objects::Location& from_here, |
| - base::TimeTicks now, |
| - base::TimeDelta delay); |
| + TimeDomain* requesting_time_domain, |
| + LazyNow* lazy_now, |
| + base::TimeTicks run_time); |
| + |
| + // Cancels a delayed task to process work at |run_time|, previously requested |
| + // with MaybeScheduleDelayedWork. |
| + void CancelDelayedWork(TimeDomain* requesting_time_domain, |
| + base::TimeTicks run_time); |
| // Set the number of tasks executed in a single invocation of the task queue |
| // manager. Increasing the batch size can reduce the overhead of yielding |
| @@ -149,6 +155,55 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| // need them, you can turn them off. |
| void SetRecordTaskDelayHistograms(bool record_task_delay_histograms); |
| + // Intermediate data structure, used to compute NextDelayedDoWork. |
| + // Only public for testing. |
| + class NextTaskDelay { |
|
Sami
2017/02/01 07:30:05
TaskQueueManagerTest is a friend -- could these tw
alex clarke (OOO till 29th)
2017/02/01 14:50:11
I found a way for NextDelayedDoWork to be private
|
| + public: |
| + NextTaskDelay() : time_domain_(nullptr) {} |
| + |
| + NextTaskDelay(base::TimeDelta delay, TimeDomain* time_domain) |
| + : delay_(delay), time_domain_(time_domain) { |
| + DCHECK_GT(delay, base::TimeDelta()); |
| + DCHECK(time_domain); |
| + } |
| + |
| + base::TimeDelta delay() const { return delay_; } |
| + TimeDomain* time_domain() const { return time_domain_; } |
| + |
| + bool operator<(const NextTaskDelay& other) const { |
| + return delay_ < other.delay_; |
| + } |
| + |
| + private: |
| + base::TimeDelta delay_; |
| + TimeDomain* time_domain_; |
| + }; |
| + |
| + // Represents a scheduled delayed DoWork (if any). Only public for testing. |
| + class NextDelayedDoWork { |
| + public: |
| + NextDelayedDoWork() : time_domain_(nullptr) {} |
| + NextDelayedDoWork(base::TimeTicks run_time, TimeDomain* time_domain) |
| + : run_time_(run_time), time_domain_(time_domain) { |
| + DCHECK_NE(run_time, base::TimeTicks()); |
| + DCHECK(time_domain); |
| + } |
| + |
| + base::TimeTicks run_time() const { return run_time_; } |
| + TimeDomain* time_domain() const { return time_domain_; } |
| + |
| + void Clear() { |
| + run_time_ = base::TimeTicks(); |
| + time_domain_ = nullptr; |
| + } |
| + |
| + explicit operator bool() const { return !run_time_.is_null(); } |
| + |
| + private: |
| + base::TimeTicks run_time_; |
| + TimeDomain* time_domain_; |
| + }; |
| + |
| private: |
| friend class LazyNow; |
| friend class internal::TaskQueueImpl; |
| @@ -178,7 +233,7 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| void DoWork(bool delayed); |
| // Post a DoWork continuation if |next_delay| is not empty. |
| - void PostDoWorkContinuationLocked(base::Optional<base::TimeDelta> next_delay, |
| + void PostDoWorkContinuationLocked(base::Optional<NextTaskDelay> next_delay, |
| LazyNow* lazy_now, |
| MoveableAutoLock&& lock); |
| @@ -216,7 +271,7 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| // Calls DelayTillNextTask on all time domains and returns the smallest delay |
| // requested if any. |
| - base::Optional<base::TimeDelta> ComputeDelayTillNextTaskLocked( |
| + base::Optional<NextTaskDelay> ComputeDelayTillNextTaskLocked( |
| LazyNow* lazy_now); |
| void MaybeRecordTaskDelayHistograms( |
| @@ -293,7 +348,7 @@ class BLINK_PLATFORM_EXPORT TaskQueueManager |
| return any_thread_; |
| } |
| - base::TimeTicks next_scheduled_delayed_do_work_time_; |
| + NextDelayedDoWork next_delayed_do_work_; |
| bool record_task_delay_histograms_; |