Index: components/scheduler/renderer/throttling_helper.h |
diff --git a/components/scheduler/renderer/throttling_helper.h b/components/scheduler/renderer/throttling_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4513c097497dd9ee8b4000d56e722fc94d2e0310 |
--- /dev/null |
+++ b/components/scheduler/renderer/throttling_helper.h |
@@ -0,0 +1,64 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ |
+#define COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ |
+ |
+#include <set> |
+ |
+#include "base/macros.h" |
+#include "components/scheduler/base/time_domain.h" |
+#include "components/scheduler/scheduler_export.h" |
+#include "third_party/WebKit/public/platform/WebViewScheduler.h" |
+ |
+namespace scheduler { |
+ |
+class RendererSchedulerImpl; |
+class VirtualTimeDomain; |
+class WebFrameSchedulerImpl; |
+ |
+class SCHEDULER_EXPORT ThrottlingHelper : public TimeDomain::Observer { |
+ public: |
+ ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler, |
+ const char* tracing_category); |
+ |
+ ~ThrottlingHelper() override; |
+ |
+ // TimeDomain::Observer implementation: |
+ void OnRegisterAsUpdatableTaskQueue() override; |
+ void OnRequestWakeup() override; |
+ |
+ void ThrottleBackgroundFrame(WebFrameSchedulerImpl* frame_scheduler); |
Sami
2015/11/24 12:48:48
What if the unit that the ThrottlingHelper works w
alex clarke (OOO till 29th)
2015/11/25 12:30:12
Done.
Sami
2015/11/25 17:12:25
Thanks, this seems like a nice simplification.
alex clarke (OOO till 29th)
2015/11/26 18:43:27
Acknowledged.
|
+ void UnthrottleForegroundFrame(WebFrameSchedulerImpl* frame_scheduler); |
+ void Unregister(WebFrameSchedulerImpl* frame_scheduler); |
+ |
+ const scoped_refptr<VirtualTimeDomain>& time_domain() const { |
+ return time_domain_; |
+ } |
+ |
+ static base::TimeDelta DelayToNextRunTimeInSeconds(base::TimeTicks now); |
+ |
+ private: |
+ void PumpThrottledTasks(); |
+ void MaybeSchedulePumpThrottledTasksLocked(); |
+ |
+ std::set<WebFrameSchedulerImpl*> background_frame_schedulers_; |
+ base::Closure pump_throttled_tasks_closure_; |
+ RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED |
+ const char* tracing_category_; // NOT OWNED |
+ scoped_refptr<VirtualTimeDomain> time_domain_; |
+ |
+ // Protects members from the contigious block below. |
Sami
2015/11/24 12:48:48
typo: contiguous
alex clarke (OOO till 29th)
2015/11/25 12:29:36
Acknowledged.
|
+ base::Lock lock_; |
+ bool pending_pump_throttled_tasks_; |
+ bool work_to_do_; |
+ |
+ base::WeakPtrFactory<ThrottlingHelper> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ThrottlingHelper); |
+}; |
+ |
+} // namespace scheduler |
+ |
+#endif // COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_ |