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

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

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.cpp
diff --git a/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..34f51a73ededda32b926d33ebf6f6929a16dc25f
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.cpp
@@ -0,0 +1,45 @@
+// 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.
+
+#include "core/workers/ParentFrameTaskRunners.h"
+
+#include "core/dom/ContextLifecycleObserver.h"
+#include "core/dom/Document.h"
+#include "public/platform/Platform.h"
+#include "wtf/Assertions.h"
+#include "wtf/ThreadingPrimitives.h"
+
+namespace blink {
+
+ParentFrameTaskRunners::ParentFrameTaskRunners(LocalFrame* frame)
+ : LocalFrameLifecycleObserver(frame)
+{
+ if (frame)
+ DCHECK(frame->document()->isContextThread());
+
+ // For now we only support very limited task types.
+ for (auto type : { TaskType::Internal, TaskType::Networking, TaskType::PostedMessage }) {
+ m_taskRunners.add(type, TaskRunnerHelper::get(type, frame));
+ }
+}
+
+WebTaskRunner* ParentFrameTaskRunners::get(TaskType type)
+{
+ MutexLocker lock(m_taskRunnersMutex);
+ return m_taskRunners.get(type);
+}
+
+DEFINE_TRACE(ParentFrameTaskRunners)
+{
+ LocalFrameLifecycleObserver::trace(visitor);
+}
+
+void ParentFrameTaskRunners::contextDestroyed()
+{
+ MutexLocker lock(m_taskRunnersMutex);
+ for (auto& entry : m_taskRunners)
+ entry.value = Platform::current()->currentThread()->getWebTaskRunner();
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h ('k') | third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698