Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1205)

Unified Diff: components/scheduler/renderer/throttling_helper.h

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Last few changes Sami requested Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8417d532d1c20bdbf3f04b847ba5b8152edbbf0e
--- /dev/null
+++ b/components/scheduler/renderer/throttling_helper.h
@@ -0,0 +1,61 @@
+// 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 OnTimeDomainHasImmediateWork() override;
+ void OnTimeDomainHasDelayedWork() override;
+
+ void Throttle(TaskQueue* task_queue);
+ void Unthrottle(TaskQueue* task_queue);
+
+ const VirtualTimeDomain* time_domain() const { return time_domain_.get(); }
+
+ static base::TimeDelta DelayToNextRunTimeInSeconds(base::TimeTicks now);
+
+ private:
+ void PumpThrottledTasks();
+ void MaybeSchedulePumpThrottledTasksLocked();
+
+ std::set<TaskQueue*> throttled_queues_;
+ base::Closure pump_throttled_tasks_closure_;
+ base::Closure forward_immediate_work_closure_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED
+ base::TickClock* tick_clock_; // NOT OWNED
+ const char* tracing_category_; // NOT OWNED
+ scoped_ptr<VirtualTimeDomain> time_domain_;
+
+ bool pending_pump_throttled_tasks_;
+
+ base::WeakPtrFactory<ThrottlingHelper> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThrottlingHelper);
+};
+
+} // namespace scheduler
+
+#endif // COMPONENTS_SCHEDULER_RENDERER_THROTTLING_HELPER_H_
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.cc ('k') | components/scheduler/renderer/throttling_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698