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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerTaskRunners.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/core/workers/WorkerTaskRunners.h
diff --git a/third_party/WebKit/Source/core/workers/WorkerTaskRunners.h b/third_party/WebKit/Source/core/workers/WorkerTaskRunners.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8f5e8b98fe34964065e74d131580b2c065296ed
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkerTaskRunners.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 WorkerTaskRunners_h
+#define WorkerTaskRunners_h
+
+#include <memory>
+#include "core/CoreExport.h"
+#include "core/dom/TaskRunnerHelper.h"
+#include "platform/wtf/HashMap.h"
+#include "platform/wtf/Noncopyable.h"
+#include "platform/wtf/PassRefPtr.h"
+#include "platform/wtf/RefPtr.h"
+#include "platform/wtf/ThreadSafeRefCounted.h"
+
+namespace blink {
+
+class WebTaskRunner;
+class WorkerOrWorkletGlobalScope;
+
+// Represents a set of task runners of the worker/worklet global context. This
+// could be accessed from any threads and must be initialized on the thread
+// where the context is running.
+class CORE_EXPORT WorkerTaskRunners final
+ : public ThreadSafeRefCounted<WorkerTaskRunners> {
+ WTF_MAKE_NONCOPYABLE(WorkerTaskRunners);
+
+ public:
+ static RefPtr<WorkerTaskRunners> Create(WorkerOrWorkletGlobalScope*);
+
+ RefPtr<WebTaskRunner> Get(TaskType);
+
+ private:
+ using TaskRunnerHashMap = HashMap<TaskType,
+ RefPtr<WebTaskRunner>,
+ WTF::IntHash<TaskType>,
+ TaskTypeTraits>;
+
+ explicit WorkerTaskRunners(WorkerOrWorkletGlobalScope*);
+
+ TaskRunnerHashMap task_runners_;
+};
+
+} // namespace blink
+
+#endif // WorkerTaskRunners_h

Powered by Google App Engine
This is Rietveld 408576698