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

Unified Diff: third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h

Issue 2236833002: Pass per-frame task runners to Workers (when possible) [2nd try] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing hash traits Created 4 years, 4 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/ParentFrameTaskRunners.h
diff --git a/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h
new file mode 100644
index 0000000000000000000000000000000000000000..5c105eb3cc4c1cfd42f9bb020694098ea576ec73
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h
@@ -0,0 +1,54 @@
+// Copyright 2016 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 ParentFrameTaskRunners_h
+#define ParentFrameTaskRunners_h
+
+#include "core/CoreExport.h"
+#include "core/dom/TaskRunnerHelper.h"
+#include "core/frame/LocalFrameLifecycleObserver.h"
+#include "platform/heap/Handle.h"
+#include "wtf/Allocator.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/PtrUtil.h"
+#include <memory>
+
+namespace blink {
+
+class LocalFrame;
+class WebTaskRunner;
+
+// Represents a set of task runners of the parent (or associated) document's
+// frame. This could be accessed from worker thread(s) and must be initialized
+// on the parent context thread (i.e. MainThread) on construction time, rather
+// than being done lazily.
+//
+// This observes LocalFrame lifecycle only for in-process worker cases (i.e.
+// only when a non-null LocalFrame is given).
+class CORE_EXPORT ParentFrameTaskRunners final : public GarbageCollectedFinalized<ParentFrameTaskRunners>, public LocalFrameLifecycleObserver {
+ USING_GARBAGE_COLLECTED_MIXIN(ParentFrameTaskRunners);
+ WTF_MAKE_NONCOPYABLE(ParentFrameTaskRunners);
+
+public:
+ // LocalFrame could be nullptr if the worker is not associated with a
+ // particular local frame.
+ explicit ParentFrameTaskRunners(LocalFrame*);
+
+ // Might return nullptr for unsupported task types.
+ WebTaskRunner* get(TaskType);
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ using TaskRunnerHashMap = HashMap<TaskType, WebTaskRunner*, WTF::IntHash<TaskType>, TaskTypeTraits>;
+
+ void contextDestroyed() override;
+
+ Mutex m_taskRunnersMutex;
+ TaskRunnerHashMap m_taskRunners;
+};
+
+} // namespace blink
+
+#endif // ParentFrameTaskRunners_h

Powered by Google App Engine
This is Rietveld 408576698