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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/worklet/Worklet.h"
7
8 #include "bindings/core/v8/V8RecursionScope.h"
9 #include "bindings/core/v8/WorkerScriptController.h"
10 #include "modules/worklet/WorkletGlobalScope.h"
11 #include "modules/worklet/WorkletMessagingProxy.h"
12
13 namespace blink {
14
15 // static
16 Worklet* Worklet::create(ExecutionContext* executionContext)
17 {
18 return new Worklet(executionContext);
19 }
20
21 Worklet::Worklet(ExecutionContext* executionContext)
22 : ActiveDOMObject(executionContext)
23 , m_workletGlobalScope(WorkletGlobalScope::create(v8::Isolate::GetCurrent()) )
24 , m_workletMessagingProxy(WorkletMessagingProxy::create(this))
25 {
26 m_workletMessagingProxy->loadScript("42;");
27 }
28
29 double Worklet::num()
30 {
31 ScriptState::Scope scope(m_workletGlobalScope->script()->scriptState());
32 V8RecursionScope recursionScope(m_workletGlobalScope->isolate());
33
34 v8::Local<v8::String> source = v8::String::NewFromUtf8(m_workletGlobalScope- >isolate(), "42", v8::NewStringType::kNormal).ToLocalChecked();
35 v8::Local<v8::Script> script = v8::Script::Compile(m_workletGlobalScope->scr ipt()->context(), source).ToLocalChecked();
36 v8::Local<v8::Value> result = script->Run(m_workletGlobalScope->script()->co ntext()).ToLocalChecked();
37
38 return v8::Number::Cast(*result)->Value();
39 }
40
41 DEFINE_TRACE(Worklet)
42 {
43 #if ENABLE(OILPAN)
44 m_workletGlobalScope->trace(visitor);
45 #endif
46 ActiveDOMObject::trace(visitor);
47 }
48
49 } // namespace blink
OLDNEW
« 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