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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerTaskRunners.cpp

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/core/workers/WorkerTaskRunners.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerTaskRunners.cpp b/third_party/WebKit/Source/core/workers/WorkerTaskRunners.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d05252ddb25236c0a0d0aafa130940bae700535c
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkerTaskRunners.cpp
@@ -0,0 +1,34 @@
+// 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.
+
+#include "core/workers/WorkerTaskRunners.h"
+
+#include "core/workers/WorkerOrWorkletGlobalScope.h"
+#include "platform/WebTaskRunner.h"
+#include "platform/wtf/Assertions.h"
+#include "public/platform/Platform.h"
+
+namespace blink {
+
+RefPtr<WorkerTaskRunners> WorkerTaskRunners::Create(
+ WorkerOrWorkletGlobalScope* global_scope) {
+ return AdoptRef(new WorkerTaskRunners(global_scope));
+}
+
+WorkerTaskRunners::WorkerTaskRunners(WorkerOrWorkletGlobalScope* global_scope) {
+ DCHECK(global_scope);
+ DCHECK(global_scope->IsContextThread());
+ for (unsigned i = 0; i < static_cast<unsigned>(TaskType::kNumberOfTaskTypes);
+ ++i) {
+ TaskType type = static_cast<TaskType>(i);
+ task_runners_.insert(type, TaskRunnerHelper::Get(type, global_scope));
+ }
+}
+
+RefPtr<WebTaskRunner> WorkerTaskRunners::Get(TaskType type) {
+ DCHECK_GT(TaskType::kNumberOfTaskTypes, type);
+ return task_runners_.at(type);
Sami 2017/04/12 15:54:06 Is there some benefit to caching runners in |task_
kinuko 2017/04/13 01:46:59 Yeah, (in case it wasn't clear) I agree with this
nhiroki 2017/04/13 08:23:50 I removed WorkerTaskRunners. The original motivati
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698