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

Side by Side Diff: third_party/WebKit/Source/modules/compositorworker/AnimationWorklet.cpp

Issue 2515363002: Introduce AnimationWorkletProxyClient and necessary plumbing to get it in worklet messaging proxy. (Closed)
Patch Set: address feedback Created 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/compositorworker/AnimationWorklet.h" 5 #include "modules/compositorworker/AnimationWorklet.h"
6 6
7 #include "bindings/core/v8/V8Binding.h" 7 #include "bindings/core/v8/V8Binding.h"
8 #include "core/dom/AnimationWorkletProxyClient.h"
9 #include "core/dom/CompositorProxyClientFactory.h"
8 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
9 #include "core/frame/LocalFrame.h" 11 #include "core/frame/LocalFrame.h"
12 #include "core/page/ChromeClient.h"
10 #include "modules/compositorworker/AnimationWorkletMessagingProxy.h" 13 #include "modules/compositorworker/AnimationWorkletMessagingProxy.h"
11 #include "modules/compositorworker/AnimationWorkletThread.h" 14 #include "modules/compositorworker/AnimationWorkletThread.h"
12 15
13 namespace blink { 16 namespace blink {
14 17
15 // static 18 // static
16 AnimationWorklet* AnimationWorklet::create(LocalFrame* frame) { 19 AnimationWorklet* AnimationWorklet::create(LocalFrame* frame) {
17 AnimationWorklet* worklet = new AnimationWorklet(frame); 20 AnimationWorklet* worklet = new AnimationWorklet(frame);
18 worklet->suspendIfNeeded(); 21 worklet->suspendIfNeeded();
19 return worklet; 22 return worklet;
20 } 23 }
21 24
22 AnimationWorklet::AnimationWorklet(LocalFrame* frame) 25 AnimationWorklet::AnimationWorklet(LocalFrame* frame)
23 : Worklet(frame), m_workletMessagingProxy(nullptr) {} 26 : Worklet(frame), m_workletMessagingProxy(nullptr) {}
24 27
25 AnimationWorklet::~AnimationWorklet() { 28 AnimationWorklet::~AnimationWorklet() {
26 if (m_workletMessagingProxy) 29 if (m_workletMessagingProxy)
27 m_workletMessagingProxy->parentObjectDestroyed(); 30 m_workletMessagingProxy->parentObjectDestroyed();
28 } 31 }
29 32
30 void AnimationWorklet::initialize() { 33 void AnimationWorklet::initialize() {
31 AnimationWorkletThread::ensureSharedBackingThread(); 34 AnimationWorkletThread::ensureSharedBackingThread();
32 35
33 DCHECK(!m_workletMessagingProxy); 36 DCHECK(!m_workletMessagingProxy);
34 DCHECK(getExecutionContext()); 37 DCHECK(getExecutionContext());
38 Document* document = toDocument(getExecutionContext());
39 CompositorProxyClientFactory* clientFactory =
40 document->frame()->chromeClient().compositorProxyClientFactory(
41 document->frame());
42 AnimationWorkletProxyClient* proxyClient =
43 static_cast<AnimationWorkletProxyClient*>(
44 clientFactory->create(CompositorProxyClient::kWorkletClient));
35 45
36 m_workletMessagingProxy = 46 m_workletMessagingProxy =
37 new AnimationWorkletMessagingProxy(getExecutionContext()); 47 new AnimationWorkletMessagingProxy(getExecutionContext(), proxyClient);
38 m_workletMessagingProxy->initialize(); 48 m_workletMessagingProxy->initialize();
39 } 49 }
40 50
41 bool AnimationWorklet::isInitialized() const { 51 bool AnimationWorklet::isInitialized() const {
42 return m_workletMessagingProxy; 52 return m_workletMessagingProxy;
43 } 53 }
44 54
45 WorkletGlobalScopeProxy* AnimationWorklet::workletGlobalScopeProxy() const { 55 WorkletGlobalScopeProxy* AnimationWorklet::workletGlobalScopeProxy() const {
46 DCHECK(m_workletMessagingProxy); 56 DCHECK(m_workletMessagingProxy);
47 return m_workletMessagingProxy; 57 return m_workletMessagingProxy;
48 } 58 }
49 59
50 DEFINE_TRACE(AnimationWorklet) { 60 DEFINE_TRACE(AnimationWorklet) {
51 Worklet::trace(visitor); 61 Worklet::trace(visitor);
52 } 62 }
53 63
54 } // namespace blink 64 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698