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

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScopeProxy.cpp

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: fix wrong dcheck Created 3 years, 6 months 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/csspaint/PaintWorkletGlobalScopeProxy.h" 5 #include "modules/csspaint/PaintWorkletGlobalScopeProxy.h"
6 6
7 #include "bindings/core/v8/ScriptSourceCode.h" 7 #include "bindings/core/v8/ScriptSourceCode.h"
8 #include "bindings/core/v8/V8BindingForCore.h" 8 #include "bindings/core/v8/V8BindingForCore.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
11 #include "platform/weborigin/KURL.h" 11 #include "platform/weborigin/KURL.h"
12 #include "platform/wtf/WTF.h" 12 #include "platform/wtf/WTF.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 PaintWorkletGlobalScopeProxy* PaintWorkletGlobalScopeProxy::From( 16 PaintWorkletGlobalScopeProxy* PaintWorkletGlobalScopeProxy::From(
17 WorkletGlobalScopeProxy* proxy) { 17 WorkletGlobalScopeProxy* proxy) {
18 return static_cast<PaintWorkletGlobalScopeProxy*>(proxy); 18 return static_cast<PaintWorkletGlobalScopeProxy*>(proxy);
19 } 19 }
20 20
21 PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy(LocalFrame* frame) { 21 PaintWorkletGlobalScopeProxy::PaintWorkletGlobalScopeProxy(
22 LocalFrame* frame,
23 PaintWorkletPendingGeneratorRegistry* pending_generator_registry) {
22 DCHECK(IsMainThread()); 24 DCHECK(IsMainThread());
23 Document* document = frame->GetDocument(); 25 Document* document = frame->GetDocument();
24 global_scope_ = PaintWorkletGlobalScope::Create( 26 global_scope_ = PaintWorkletGlobalScope::Create(
25 frame, document->Url(), document->UserAgent(), 27 frame, document->Url(), document->UserAgent(),
26 document->GetSecurityOrigin(), ToIsolate(document)); 28 document->GetSecurityOrigin(), ToIsolate(document),
29 pending_generator_registry);
27 } 30 }
28 31
29 void PaintWorkletGlobalScopeProxy::FetchAndInvokeScript( 32 void PaintWorkletGlobalScopeProxy::FetchAndInvokeScript(
30 const KURL& module_url_record, 33 const KURL& module_url_record,
31 WebURLRequest::FetchCredentialsMode credentials_mode, 34 WebURLRequest::FetchCredentialsMode credentials_mode,
32 WorkletPendingTasks* pending_tasks) { 35 WorkletPendingTasks* pending_tasks) {
33 DCHECK(IsMainThread()); 36 DCHECK(IsMainThread());
34 global_scope_->FetchAndInvokeScript(module_url_record, credentials_mode, 37 global_scope_->FetchAndInvokeScript(module_url_record, credentials_mode,
35 pending_tasks); 38 pending_tasks);
36 } 39 }
(...skipping 11 matching lines...) Expand all
48 // Nullify the global scope to cut a potential reference cycle. 51 // Nullify the global scope to cut a potential reference cycle.
49 global_scope_ = nullptr; 52 global_scope_ = nullptr;
50 } 53 }
51 54
52 CSSPaintDefinition* PaintWorkletGlobalScopeProxy::FindDefinition( 55 CSSPaintDefinition* PaintWorkletGlobalScopeProxy::FindDefinition(
53 const String& name) { 56 const String& name) {
54 DCHECK(IsMainThread()); 57 DCHECK(IsMainThread());
55 return global_scope_->FindDefinition(name); 58 return global_scope_->FindDefinition(name);
56 } 59 }
57 60
58 void PaintWorkletGlobalScopeProxy::AddPendingGenerator(
59 const String& name,
60 CSSPaintImageGeneratorImpl* generator) {
61 DCHECK(IsMainThread());
62 global_scope_->AddPendingGenerator(name, generator);
63 }
64
65 } // namespace blink 61 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698