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

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

Issue 1625473002: compositor-worker: blink->cc plumbing Base URL: https://chromium.googlesource.com/chromium/src.git@upstream-compositor-worker
Patch Set: Merge with landing of https://codereview.chromium.org/1599673002/ on master Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/CompositorWorkerGlobalScope.h" 5 #include "modules/compositorworker/CompositorWorkerGlobalScope.h"
6 6
7 #include "bindings/core/v8/SerializedScriptValue.h" 7 #include "bindings/core/v8/SerializedScriptValue.h"
8 #include "core/workers/WorkerObjectProxy.h" 8 #include "core/workers/WorkerObjectProxy.h"
9 #include "core/workers/WorkerThreadStartupData.h" 9 #include "core/workers/WorkerThreadStartupData.h"
10 #include "modules/EventTargetModules.h" 10 #include "modules/EventTargetModules.h"
11 #include "modules/compositorworker/CompositorWorkerThread.h" 11 #include "modules/compositorworker/CompositorWorkerThread.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 PassRefPtrWillBeRawPtr<CompositorWorkerGlobalScope> CompositorWorkerGlobalScope: :create(CompositorWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> star tupData, double timeOrigin) 15 PassRefPtrWillBeRawPtr<CompositorWorkerGlobalScope> CompositorWorkerGlobalScope: :create(CompositorWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> star tupData, double timeOrigin)
16 { 16 {
17 // Note: startupData is finalized on return. After the relevant parts has be en 17 // Note: startupData is finalized on return. After the relevant parts has be en
18 // passed along to the created 'context'. 18 // passed along to the created 'context'.
19 RefPtrWillBeRawPtr<CompositorWorkerGlobalScope> context = adoptRefWillBeNoop (new CompositorWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAg ent, thread, timeOrigin, startupData->m_starterOriginPrivilegeData.release(), st artupData->m_workerClients.release())); 19 RefPtrWillBeRawPtr<CompositorWorkerGlobalScope> context = adoptRefWillBeNoop (new CompositorWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAg ent, thread, timeOrigin, startupData->m_starterOriginPrivilegeData.release(), st artupData->m_workerClients.release()));
20 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit yPolicyHeaders); 20 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit yPolicyHeaders);
21 return context.release(); 21 return context.release();
22 } 22 }
23 23
24 CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const String& userAgent, CompositorWorkerThread* thread, double timeOrigin, PassOwnPtr <SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, PassOwnPtrWillBeRawP tr<WorkerClients> workerClients) 24 CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const String& userAgent, CompositorWorkerThread* thread, double timeOrigin, PassOwnPtr <SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, PassOwnPtrWillBeRawP tr<WorkerClients> workerClients)
25 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivile geData, workerClients) 25 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivile geData, workerClients)
26 , m_executingAnimationFrameCallbacks(false)
26 , m_callbackCollection(this) 27 , m_callbackCollection(this)
28 , m_client(CompositorProxyClient::from(clients()))
27 { 29 {
30 m_client->setGlobalScope(this);
28 } 31 }
29 32
30 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope() 33 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope()
31 { 34 {
32 } 35 }
33 36
34 DEFINE_TRACE(CompositorWorkerGlobalScope) 37 DEFINE_TRACE(CompositorWorkerGlobalScope)
35 { 38 {
36 visitor->trace(m_callbackCollection); 39 visitor->trace(m_callbackCollection);
37 WorkerGlobalScope::trace(visitor); 40 WorkerGlobalScope::trace(visitor);
38 } 41 }
39 42
40 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const 43 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const
41 { 44 {
42 return EventTargetNames::CompositorWorkerGlobalScope; 45 return EventTargetNames::CompositorWorkerGlobalScope;
43 } 46 }
44 47
45 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext , PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, Exce ptionState& exceptionState) 48 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext , PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, Exce ptionState& exceptionState)
46 { 49 {
47 // Disentangle the port in preparation for sending it to the remote context. 50 // Disentangle the port in preparation for sending it to the remote context.
48 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(exe cutionContext, ports, exceptionState); 51 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(exe cutionContext, ports, exceptionState);
49 if (exceptionState.hadException()) 52 if (exceptionState.hadException())
50 return; 53 return;
51 thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.re lease()); 54 thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.re lease());
52 } 55 }
53 56
54 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal lback) 57 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal lback)
55 { 58 {
59 const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackC ollection.isEmpty();
60 if (shouldSignal)
61 m_client->requestMutation();
56 return m_callbackCollection.registerCallback(callback); 62 return m_callbackCollection.registerCallback(callback);
57 } 63 }
58 64
59 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) 65 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id)
60 { 66 {
61 m_callbackCollection.cancelCallback(id); 67 m_callbackCollection.cancelCallback(id);
62 } 68 }
63 69
64 void CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT imeNow) 70 bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT imeNow)
65 { 71 {
72 TemporaryChange<bool> temporaryChange(m_executingAnimationFrameCallbacks, tr ue);
66 m_callbackCollection.executeCallbacks(highResTimeNow, highResTimeNow); 73 m_callbackCollection.executeCallbacks(highResTimeNow, highResTimeNow);
74 return !m_callbackCollection.isEmpty();
67 } 75 }
68 76
69 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const 77 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const
70 { 78 {
71 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); 79 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread());
72 } 80 }
73 81
74 } // namespace blink 82 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698