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

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: rebase 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..d8e55579737bd03ee9bf8050b7f24c15407220d4
--- /dev/null
+++ b/third_party/WebKit/Source/platform/scheduler/child/worker_global_scope_scheduler.h
@@ -0,0 +1,47 @@
+// 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 same thread.
+class BLINK_PLATFORM_EXPORT WorkerGlobalScopeScheduler {
+ public:
+ WorkerGlobalScopeScheduler(WorkerScheduler* worker_scheduler);
+ ~WorkerGlobalScopeScheduler();
+
+ // Unregisters the task queues and cancels tasks in them.
+ void Dispose();
Sami 2017/04/12 15:54:07 Could you add a test for this please?
nhiroki 2017/04/13 08:23:50 Done.
+
+ // 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:
+ WorkerScheduler* worker_scheduler_;
+ scoped_refptr<TaskQueue> unthrottled_task_queue_;
+ RefPtr<WebTaskRunnerImpl> unthrottled_task_runner_;
+};
+
+} // 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