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

Unified Diff: third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h

Issue 2806623004: Worker: Introduce per-global-scope task scheduler (Closed)
Patch Set: remove unnecessary comments Created 3 years, 8 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
Index: third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h
diff --git a/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h b/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..5e3c7fbd39a4f5f306eb68173f06316b5080bad7
--- /dev/null
+++ b/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h
@@ -0,0 +1,49 @@
+// Copyright 2017 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 THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_WORKER_GLOBAL_SCOPE_SCHEDULER_H_
+#define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_WORKER_GLOBAL_SCOPE_SCHEDULER_H_
+
+#include "platform/scheduler/child/web_task_runner_impl.h"
+#include "public/platform/WebCommon.h"
+#include "public/platform/scheduler/base/task_queue.h"
+
+namespace blink {
+namespace scheduler {
+
+class WorkerScheduler;
+
+// A scheduler provides per-global-scope task queues. This is constructed when a
+// global scope is created and destructed when it's closed.
+//
+// Unless stated otherwise, all methods must be called on the worker thread.
+class BLINK_PLATFORM_EXPORT WorkerGlobalScopeScheduler {
+ public:
+ explicit WorkerGlobalScopeScheduler(WorkerScheduler* worker_scheduler);
+ ~WorkerGlobalScopeScheduler();
+
+ // Unregisters the task queues and cancels tasks in them.
+ void Dispose();
+
+ // Returns the WebTaskRunner for tasks which should never get throttled. This
+ // can be called from any thread.
+ RefPtr<WebTaskRunner> UnthrottledTaskRunner() {
+ return unthrottled_task_runner_;
+ }
+
+ // TODO(nhiroki): Add mechanism to throttle/suspend tasks in response to the
+ // state of the parent document (https://crbug.com/670534).
+
+ private:
+ RefPtr<WebTaskRunnerImpl> unthrottled_task_runner_;
+
+#if DCHECK_IS_ON()
+ bool is_disposed_ = false;
+#endif
+};
+
+} // namespace scheduler
+} // namespace blink
+
+#endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_WORKER_GLOBAL_SCOPE_SCHEDULER_H_

Powered by Google App Engine
This is Rietveld 408576698