Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h |
| diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h b/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h |
| index 9bcb72a6d65560b974d1c9330cd3a7d01a79cff8..5fa2058380b5ff148bd2e1f46aaaa7e2258e5a4d 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h |
| +++ b/third_party/WebKit/Source/platform/scheduler/renderer/budget_pool.h |
| @@ -25,6 +25,7 @@ namespace scheduler { |
| class TaskQueue; |
| class BudgetPoolController; |
| +enum class QueueBlockType; |
| // BudgetPool represents a group of task queues which share a limit |
| // on a resource. This limit applies when task queues are already throttled |
| @@ -36,14 +37,28 @@ class BLINK_PLATFORM_EXPORT BudgetPool { |
| const char* Name() const; |
| // Report task run time to the budget pool. |
| - virtual void RecordTaskRunTime(base::TimeTicks start_time, |
| + virtual void RecordTaskRunTime(TaskQueue* queue, |
| + base::TimeTicks start_time, |
| base::TimeTicks end_time) = 0; |
| - // Retuns earliest time (can be in the past) when the next task can run. |
| - virtual base::TimeTicks GetNextAllowedRunTime() = 0; |
| + // Returns earliest time when the next pump can be scheduled to run new tasks. |
|
alex clarke (OOO till 29th)
2017/04/21 09:14:19
Returns the earliest...
altimin
2017/04/25 13:22:35
Done.
|
| + virtual base::TimeTicks GetNextAllowedRunTime( |
| + base::TimeTicks desired_run_time) const = 0; |
| // Returns true at a task can be run immediately at the given time. |
| - virtual bool HasEnoughBudgetToRun(base::TimeTicks now) = 0; |
| + virtual bool CanRunTasksAt(base::TimeTicks moment) const = 0; |
| + |
| + // Returns true if tasks can run at any time up to |moment|. |
| + virtual bool CanRunTasksUntil(base::TimeTicks now, |
| + base::TimeTicks moment) const = 0; |
| + |
| + // Notifies budget pool that queue has work with desired run time. |
| + virtual void OnTaskQueueHasWork(TaskQueue* queue, |
| + base::TimeTicks now, |
| + base::TimeTicks desired_run_time) = 0; |
| + |
| + // Notifies budget pool that wakeup has happened. |
| + virtual void OnWakeup(base::TimeTicks now) = 0; |
| // Returns state for tracing. |
| virtual void AsValueInto(base::trace_event::TracedValue* state, |
| @@ -59,6 +74,9 @@ class BLINK_PLATFORM_EXPORT BudgetPool { |
| // is scheduled. |
|
alex clarke (OOO till 29th)
2017/04/21 09:14:19
Maybe comment this schedules a wake up if needed.
altimin
2017/04/25 13:22:35
Done.
|
| void RemoveQueue(base::TimeTicks now, TaskQueue* queue); |
| + // Unlike RemoveQueue, does not schedule a new wakeup for the queue. |
| + void UnregisterQueue(TaskQueue* queue); |
| + |
| // Enables this time budget pool. Queues from this pool will be |
| // throttled based on their run time. |
| void EnableThrottling(LazyNow* now); |
| @@ -80,6 +98,9 @@ class BLINK_PLATFORM_EXPORT BudgetPool { |
| protected: |
| BudgetPool(const char* name, BudgetPoolController* budget_pool_controller); |
| + // Specify how this budget pool should block affected queues. |
| + virtual QueueBlockType GetBlockType() const = 0; |
| + |
| const char* name_; // NOT OWNED |
| BudgetPoolController* budget_pool_controller_; |
| @@ -142,13 +163,23 @@ class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool { |
| base::Callback<void(base::TimeDelta)> reporting_callback); |
| // BudgetPool implementation: |
| - void RecordTaskRunTime(base::TimeTicks start_time, |
| + void RecordTaskRunTime(TaskQueue* queue, |
| + base::TimeTicks start_time, |
| base::TimeTicks end_time) final; |
| - bool HasEnoughBudgetToRun(base::TimeTicks now) final; |
| - base::TimeTicks GetNextAllowedRunTime() final; |
| + bool CanRunTasksUntil(base::TimeTicks now, base::TimeTicks until) const final; |
| + bool CanRunTasksAt(base::TimeTicks now) const final; |
| + base::TimeTicks GetNextAllowedRunTime( |
| + base::TimeTicks desired_run_time) const final; |
| + void OnTaskQueueHasWork(TaskQueue* queue, |
| + base::TimeTicks now, |
| + base::TimeTicks desired_run_time) final; |
| + void OnWakeup(base::TimeTicks now) final; |
| void AsValueInto(base::trace_event::TracedValue* state, |
| base::TimeTicks now) const final; |
| + protected: |
| + QueueBlockType GetBlockType() const final; |
| + |
| private: |
| FRIEND_TEST_ALL_PREFIXES(TaskQueueThrottlerTest, CPUTimeBudgetPool); |
| @@ -184,6 +215,49 @@ class BLINK_PLATFORM_EXPORT CPUTimeBudgetPool : public BudgetPool { |
| DISALLOW_COPY_AND_ASSIGN(CPUTimeBudgetPool); |
| }; |
| +// WakeupBudgetPool represents a collection of task queues which share a limit |
| +// on total cpu time. |
| +class BLINK_PLATFORM_EXPORT WakeupBudgetPool : public BudgetPool { |
|
alex clarke (OOO till 29th)
2017/04/21 09:14:19
I think we should try to keep to 1 major class per
altimin
2017/04/25 13:22:35
I was thinking that these classes are too similar
alex clarke (OOO till 29th)
2017/04/27 10:28:14
Sorry to be a pain but I think we should separate
altimin
2017/04/27 11:07:40
Done.
|
| + public: |
| + WakeupBudgetPool(const char* name, |
| + BudgetPoolController* budget_pool_controller, |
| + base::TimeTicks now); |
| + ~WakeupBudgetPool(); |
|
alex clarke (OOO till 29th)
2017/04/21 09:14:19
override?
altimin
2017/04/25 13:22:35
Done.
|
| + |
| + void SetWakeupRate(base::TimeTicks now, double wakeups_per_second); |
|
alex clarke (OOO till 29th)
2017/04/21 09:14:19
Why do we need to pass |now| into this? I notice
altimin
2017/04/25 13:22:35
Done.
|
| + |
| + void SetWakeupDuration(base::TimeTicks now, base::TimeDelta duration); |
|
alex clarke (OOO till 29th)
2017/04/21 09:14:19
Same question.
altimin
2017/04/25 13:22:35
Done.
|
| + |
| + // BudgetPool implementation: |
| + void RecordTaskRunTime(TaskQueue* queue, |
| + base::TimeTicks start_time, |
| + base::TimeTicks end_time) final; |
| + bool CanRunTasksUntil(base::TimeTicks now, |
| + base::TimeTicks moment) const final; |
| + bool CanRunTasksAt(base::TimeTicks now) const final; |
| + base::TimeTicks GetNextAllowedRunTime( |
| + base::TimeTicks desired_run_time) const final; |
| + void OnTaskQueueHasWork(TaskQueue* queue, |
| + base::TimeTicks now, |
| + base::TimeTicks desired_run_time) final; |
| + void OnWakeup(base::TimeTicks now) final; |
| + void AsValueInto(base::trace_event::TracedValue* state, |
| + base::TimeTicks now) const final; |
| + |
| + protected: |
| + QueueBlockType GetBlockType() const final; |
| + |
| + private: |
| + base::TimeTicks NextWakeup() const; |
| + |
| + double wakeups_per_second_; |
| + base::TimeDelta wakeup_duration_; |
| + |
| + base::TimeTicks last_wakeup_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WakeupBudgetPool); |
| +}; |
| + |
| } // namespace scheduler |
| } // namespace blink |