Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scheduler/renderer/throttling_helper.h |
| diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/throttling_helper.h b/third_party/WebKit/Source/platform/scheduler/renderer/throttling_helper.h |
| index 0f3a99325e487b723096acaaaad7d7aa5838ed2a..ca9d4da695f197f1d98b920da02f89d59de3bbc3 100644 |
| --- a/third_party/WebKit/Source/platform/scheduler/renderer/throttling_helper.h |
| +++ b/third_party/WebKit/Source/platform/scheduler/renderer/throttling_helper.h |
| @@ -19,6 +19,22 @@ class RendererSchedulerImpl; |
| class ThrottledTimeDomain; |
| class WebFrameSchedulerImpl; |
| +// The job of the ThrottlingHelper is to run tasks posted on throttled queues at |
| +// most once per second. This is done by disabling throttled queues and running |
| +// a special "heart beat" function |PumpThrottledTasks| which when run |
| +// temporarily enables throttled queues and posts a task on them to disable |
| +// themselves till next time. |
| +// |
| +// Of course the ThrottlingHelper isn't the only sub-system that wants to enable |
| +// or disable queues. E.g. RendererSchedulerImpl also does this for policy |
| +// reasons. To prevent the systems from fighting, clients of ThrottlingHelper |
| +// must use SetQueueEnabled rather than calling the function directly on the |
| +// queue. |
| +// |
| +// There may be more than one system that wishes to throttle a queue (e.g. |
| +// renderer suspension vs level tab suspension) so the ThrottlingHelper keeps a |
|
Sami
2016/08/25 15:54:13
Did you mean renderer level vs. tab level suspensi
alex clarke (OOO till 29th)
2016/08/26 13:29:09
Done.
|
| +// count of the number of systems that wish a queue to be throttled. |
| +// See IncreaseThrottleRefCount & DecreaseThrottleRefCount. |
| class BLINK_PLATFORM_EXPORT ThrottlingHelper : public TimeDomain::Observer { |
| public: |
| ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler, |
| @@ -50,6 +66,9 @@ class BLINK_PLATFORM_EXPORT ThrottlingHelper : public TimeDomain::Observer { |
| // Removes |task_queue| from |throttled_queues_|. |
| void UnregisterTaskQueue(TaskQueue* task_queue); |
| + // Returns true if the |task_queue| is throttled. |
| + bool IsThrottled(TaskQueue* task_queue) const; |
| + |
| // Tells the ThrottlingHelper we're using virtual time, which disables all |
| // throttling. |
| void EnableVirtualTime(); |
| @@ -73,6 +92,7 @@ class BLINK_PLATFORM_EXPORT ThrottlingHelper : public TimeDomain::Observer { |
| using TaskQueueMap = std::map<TaskQueue*, Metadata>; |
| void PumpThrottledTasks(); |
| + void MaybeDisableQueue(TaskQueue* task_queue); |
| // Note |unthrottled_runtime| might be in the past. When this happens we |
| // compute the delay to the next runtime based on now rather than |
| @@ -93,6 +113,7 @@ class BLINK_PLATFORM_EXPORT ThrottlingHelper : public TimeDomain::Observer { |
| CancelableClosureHolder pump_throttled_tasks_closure_; |
| base::TimeTicks pending_pump_throttled_tasks_runtime_; |
| bool virtual_time_; |
| + bool ignore_incoming_immediate_work_; |
| base::WeakPtrFactory<ThrottlingHelper> weak_factory_; |