OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 "modules/csspaint/PaintWorkletGlobalScopeProxy.h" |
| 6 |
| 7 #include "bindings/core/v8/ScriptSourceCode.h" |
| 8 #include "bindings/core/v8/V8BindingForCore.h" |
| 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/LocalFrame.h" |
| 11 #include "platform/weborigin/KURL.h" |
| 12 #include "platform/wtf/WTF.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 std::unique_ptr<PaintWorkletGlobalScopeProxy> |
| 17 PaintWorkletGlobalScopeProxy::Create(LocalFrame* frame) { |
| 18 return WTF::WrapUnique(new PaintWorkletGlobalScopeProxy(frame)); |
| 19 } |
| 20 |
| 21 PaintWorkletGlobalScopeProxy* PaintWorkletGlobalScopeProxy::From( |
| 22 WorkletGlobalScopeProxy* proxy) { |
| 23 return static_cast<PaintWorkletGlobalScopeProxy*>(proxy); |
| 24 } |
| 25 |
| 26 void PaintWorkletGlobalScopeProxy::FetchAndInvokeScript( |
| 27 const KURL& module_url_record, |
| 28 WorkletPendingTasks* pending_tasks) { |
| 29 DCHECK(WTF::IsMainThread()); |
| 30 global_scope_->FetchAndInvokeScript(module_url_record, pending_tasks); |
| 31 } |
| 32 |
| 33 void PaintWorkletGlobalScopeProxy::EvaluateScript( |
| 34 const ScriptSourceCode& script_source_code) { |
| 35 // This should be called only for threaded worklets that still use classic |
| 36 // script loading. |
| 37 NOTREACHED(); |
| 38 } |
| 39 |
| 40 void PaintWorkletGlobalScopeProxy::TerminateWorkletGlobalScope() { |
| 41 DCHECK(WTF::IsMainThread()); |
| 42 global_scope_->Terminate(); |
| 43 } |
| 44 |
| 45 CSSPaintDefinition* PaintWorkletGlobalScopeProxy::FindDefinition( |
| 46 const String& name) { |
| 47 DCHECK(WTF::IsMainThread()); |
| 48 return global_scope_->FindDefinition(name); |
| 49 } |
| 50 |
| 51 void PaintWorkletGlobalScopeProxy::AddPendingGenerator( |
| 52 const String& name, |
| 53 CSSPaintImageGeneratorImpl* generator) { |
| 54 DCHECK(WTF::IsMainThread()); |
| 55 global_scope_->AddPendingGenerator(name, generator); |
| 56 } |
| 57 |
| 58 PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy(LocalFrame* frame) { |
| 59 DCHECK(WTF::IsMainThread()); |
| 60 Document* document = frame->GetDocument(); |
| 61 global_scope_ = PaintWorkletGlobalScope::Create( |
| 62 frame, document->Url(), document->UserAgent(), |
| 63 document->GetSecurityOrigin(), ToIsolate(document)); |
| 64 } |
| 65 |
| 66 } // namespace blink |
OLD | NEW |