Chromium Code Reviews| Index: third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScopeProxy.cpp |
| diff --git a/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScopeProxy.cpp b/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScopeProxy.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6ad4ebe17a7fe5c97c4efdf45031de966f915fe0 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScopeProxy.cpp |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2017 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/csspaint/PaintWorkletGlobalScopeProxy.h" |
| + |
| +#include "bindings/core/v8/ScriptSourceCode.h" |
| +#include "bindings/core/v8/V8BindingForCore.h" |
| +#include "core/dom/Document.h" |
| +#include "core/frame/LocalFrame.h" |
| +#include "platform/weborigin/KURL.h" |
| +#include "platform/wtf/WTF.h" |
| + |
| +namespace blink { |
| + |
| +std::unique_ptr<PaintWorkletGlobalScopeProxy> |
| +PaintWorkletGlobalScopeProxy::Create(LocalFrame* frame) { |
| + return WTF::WrapUnique(new PaintWorkletGlobalScopeProxy(frame)); |
|
haraken
2017/05/01 08:43:46
MakeUnique
nhiroki
2017/05/02 04:45:24
To change this to MakeUnique, we need to make the
|
| +} |
| + |
| +PaintWorkletGlobalScopeProxy* PaintWorkletGlobalScopeProxy::From( |
| + WorkletGlobalScopeProxy* proxy) { |
| + return static_cast<PaintWorkletGlobalScopeProxy*>(proxy); |
| +} |
| + |
| +void PaintWorkletGlobalScopeProxy::FetchAndInvokeScript( |
| + const KURL& module_url_record, |
| + WorkletPendingTasks* pending_tasks) { |
| + DCHECK(WTF::IsMainThread()); |
|
haraken
2017/05/01 08:43:46
WTF:: wouldn't be needed.
nhiroki
2017/05/02 04:45:24
Done.
|
| + global_scope_->FetchAndInvokeScript(module_url_record, pending_tasks); |
|
haraken
2017/05/01 08:43:47
Just to confirm: You can simply redirect the metho
nhiroki
2017/05/02 04:45:24
Yes, that's right.
For other threaded worklets, t
|
| +} |
| + |
| +void PaintWorkletGlobalScopeProxy::EvaluateScript( |
| + const ScriptSourceCode& script_source_code) { |
| + // This should be called only for threaded worklets that still use classic |
| + // script loading. |
| + NOTREACHED(); |
| +} |
| + |
| +void PaintWorkletGlobalScopeProxy::TerminateWorkletGlobalScope() { |
| + DCHECK(WTF::IsMainThread()); |
| + global_scope_->Terminate(); |
| +} |
| + |
| +CSSPaintDefinition* PaintWorkletGlobalScopeProxy::FindDefinition( |
| + const String& name) { |
| + DCHECK(WTF::IsMainThread()); |
| + return global_scope_->FindDefinition(name); |
| +} |
| + |
| +void PaintWorkletGlobalScopeProxy::AddPendingGenerator( |
| + const String& name, |
| + CSSPaintImageGeneratorImpl* generator) { |
| + DCHECK(WTF::IsMainThread()); |
| + global_scope_->AddPendingGenerator(name, generator); |
| +} |
| + |
| +PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy(LocalFrame* frame) { |
| + DCHECK(WTF::IsMainThread()); |
| + Document* document = frame->GetDocument(); |
| + global_scope_ = PaintWorkletGlobalScope::Create( |
| + frame, document->Url(), document->UserAgent(), |
| + document->GetSecurityOrigin(), ToIsolate(document)); |
| +} |
| + |
| +} // namespace blink |