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

Unified Diff: third_party/WebKit/Source/modules/worklet/ThreadedWorkletGlobalScopeProxy.cpp

Issue 1992933002: Introduce WorkletGlobalScopeProxy interface. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests. Created 4 years, 6 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/modules/worklet/ThreadedWorkletGlobalScopeProxy.cpp
diff --git a/third_party/WebKit/Source/modules/worklet/ThreadedWorkletGlobalScopeProxy.cpp b/third_party/WebKit/Source/modules/worklet/ThreadedWorkletGlobalScopeProxy.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4d28c64d9f8c441bc0b0cf53a9d7ddbd2cf767b5
--- /dev/null
+++ b/third_party/WebKit/Source/modules/worklet/ThreadedWorkletGlobalScopeProxy.cpp
@@ -0,0 +1,48 @@
+// 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 "modules/worklet/ThreadedWorkletGlobalScopeProxy.h"
+
+#include "bindings/core/v8/ScriptSourceCode.h"
+#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
+#include "core/dom/CrossThreadTask.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/workers/WorkletGlobalScope.h"
+#include "public/platform/WebTraceLocation.h"
+
+namespace blink {
+
+namespace {
+
+void processEvaluateScript(const String& source, const KURL& scriptURL, ExecutionContext* executionContext)
+{
+ WorkletGlobalScope* globalScope = toWorkletGlobalScope(executionContext);
+ globalScope->scriptController()->evaluate(ScriptSourceCode(source, scriptURL));
+}
+
+} // namespace
+
+ThreadedWorkletGlobalScopeProxy::ThreadedWorkletGlobalScopeProxy(PassOwnPtr<WorkletThread> workletThread)
+ : m_workletThread(std::move(workletThread))
+{
+}
+
+ThreadedWorkletGlobalScopeProxy::~ThreadedWorkletGlobalScopeProxy()
+{
+}
+
+void ThreadedWorkletGlobalScopeProxy::evaluateScript(const String& source, const KURL& scriptURL)
+{
+ DCHECK(isMainThread());
+ m_workletThread->postTask(BLINK_FROM_HERE, createCrossThreadTask(&processEvaluateScript, source, scriptURL));
+}
+
+void ThreadedWorkletGlobalScopeProxy::terminateWorkletGlobalScope()
+{
+ DCHECK(isMainThread());
+
+ // TODO write termination dance.
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698