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

Unified Diff: public/platform/WebScheduler.h

Issue 656323005: scheduler: Add new platform interface for implementing scheduling (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months 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
« no previous file with comments | « public/platform/Platform.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: public/platform/WebScheduler.h
diff --git a/public/platform/WebScheduler.h b/public/platform/WebScheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..443c02ccf0688a2e33c0f49a50998c9468cc470d
--- /dev/null
+++ b/public/platform/WebScheduler.h
@@ -0,0 +1,44 @@
+// Copyright 2014 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 WebScheduler_h
+#define WebScheduler_h
+
+namespace blink {
+
+class WebTraceLocation;
+
+// This class is used to submit tasks and pass other information from Blink to
+// the platform's scheduler.
+class WebScheduler {
+public:
+ virtual ~WebScheduler() { }
+
+ // An IdleTask is passed a deadline in CLOCK_MONOTONIC seconds and is
+ // expected to complete before this deadline.
+ class IdleTask {
+ public:
+ virtual ~IdleTask() { }
+ virtual void run(double deadlineSeconds) = 0;
+ };
+
+ // Called during Blink's shutdown to delete any pending tasks from the
+ // scheduler. Must be called on the main thread.
+ virtual void shutdown() { }
+
+ // Returns true if there is high priority work pending on the main thread
+ // and the caller should yield to let the scheduler service that work.
+ // Must be called on the main thread.
+ virtual bool shouldYieldForHighPriorityWork() { return false; }
+
+ // Schedule an idle task to run the Blink main thread. For non-critical
+ // tasks which may be reordered relative to other task types and may be
+ // starved for an arbitrarily long time if no idle time is available.
+ // Takes ownership of |IdleTask|. Can be called from any thread.
+ virtual void postIdleTask(const WebTraceLocation&, IdleTask*) { }
+};
+
+} // namespace blink
+
+#endif // WebScheduler_h
« no previous file with comments | « public/platform/Platform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698