| 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
|
|
|