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

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

Issue 1510603005: [Do not submit] Worklet implementation. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A basic CompositorWorklet implementation. Created 5 years 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/Worklet.cpp
diff --git a/third_party/WebKit/Source/modules/worklet/Worklet.cpp b/third_party/WebKit/Source/modules/worklet/Worklet.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9d885636fcd256243af66f31b705ecde45e655d7
--- /dev/null
+++ b/third_party/WebKit/Source/modules/worklet/Worklet.cpp
@@ -0,0 +1,49 @@
+// Copyright 2015 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 "config.h"
+#include "modules/worklet/Worklet.h"
+
+#include "bindings/core/v8/V8RecursionScope.h"
+#include "bindings/core/v8/WorkerScriptController.h"
+#include "modules/worklet/WorkletGlobalScope.h"
+#include "modules/worklet/WorkletMessagingProxy.h"
+
+namespace blink {
+
+// static
+Worklet* Worklet::create(ExecutionContext* executionContext)
+{
+ return new Worklet(executionContext);
+}
+
+Worklet::Worklet(ExecutionContext* executionContext)
+ : ActiveDOMObject(executionContext)
+ , m_workletGlobalScope(WorkletGlobalScope::create(v8::Isolate::GetCurrent()))
+ , m_workletMessagingProxy(WorkletMessagingProxy::create(this))
+{
+ m_workletMessagingProxy->loadScript("42;");
+}
+
+double Worklet::num()
+{
+ ScriptState::Scope scope(m_workletGlobalScope->script()->scriptState());
+ V8RecursionScope recursionScope(m_workletGlobalScope->isolate());
+
+ v8::Local<v8::String> source = v8::String::NewFromUtf8(m_workletGlobalScope->isolate(), "42", v8::NewStringType::kNormal).ToLocalChecked();
+ v8::Local<v8::Script> script = v8::Script::Compile(m_workletGlobalScope->script()->context(), source).ToLocalChecked();
+ v8::Local<v8::Value> result = script->Run(m_workletGlobalScope->script()->context()).ToLocalChecked();
+
+ return v8::Number::Cast(*result)->Value();
+}
+
+DEFINE_TRACE(Worklet)
+{
+#if ENABLE(OILPAN)
+ m_workletGlobalScope->trace(visitor);
+#endif
+ ActiveDOMObject::trace(visitor);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/worklet/Worklet.h ('k') | third_party/WebKit/Source/modules/worklet/Worklet.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698