| OLD | NEW |
| 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/WorkerScriptStartupData.h" |
| 10 #include "modules/EventTargetModules.h" | 10 #include "modules/EventTargetModules.h" |
| 11 #include "modules/compositorworker/CompositorWorkerThread.h" | 11 #include "modules/compositorworker/CompositorWorkerScript.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(CompositorWorkerScript* script, PassOwnPtr<WorkerScriptStartupData> 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, script, 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, CompositorWorkerScript* script, double timeOrigin, PassOwnPtr
<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, PassOwnPtrWillBeRawP
tr<WorkerClients> workerClients) |
| 25 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivile
geData, workerClients) | 25 : WorkerGlobalScope(url, userAgent, script, timeOrigin, starterOriginPrivile
geData, workerClients) |
| 26 , m_callbackCollection(this) | 26 , m_callbackCollection(this) |
| 27 { | 27 { |
| 28 } | 28 } |
| 29 | 29 |
| 30 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope() | 30 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope() |
| 31 { | 31 { |
| 32 } | 32 } |
| 33 | 33 |
| 34 DEFINE_TRACE(CompositorWorkerGlobalScope) | 34 DEFINE_TRACE(CompositorWorkerGlobalScope) |
| 35 { | 35 { |
| 36 visitor->trace(m_callbackCollection); | 36 visitor->trace(m_callbackCollection); |
| 37 WorkerGlobalScope::trace(visitor); | 37 WorkerGlobalScope::trace(visitor); |
| 38 } | 38 } |
| 39 | 39 |
| 40 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const | 40 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const |
| 41 { | 41 { |
| 42 return EventTargetNames::CompositorWorkerGlobalScope; | 42 return EventTargetNames::CompositorWorkerGlobalScope; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext
, PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, Exce
ptionState& exceptionState) | 45 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext
, PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, Exce
ptionState& exceptionState) |
| 46 { | 46 { |
| 47 // Disentangle the port in preparation for sending it to the remote context. | 47 // Disentangle the port in preparation for sending it to the remote context. |
| 48 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(exe
cutionContext, ports, exceptionState); | 48 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(exe
cutionContext, ports, exceptionState); |
| 49 if (exceptionState.hadException()) | 49 if (exceptionState.hadException()) |
| 50 return; | 50 return; |
| 51 thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.re
lease()); | 51 workerScript()->workerObjectProxy().postMessageToWorkerObject(message, chann
els.release()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) | 54 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) |
| 55 { | 55 { |
| 56 return m_callbackCollection.registerCallback(callback); | 56 return m_callbackCollection.registerCallback(callback); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) | 59 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) |
| 60 { | 60 { |
| 61 m_callbackCollection.cancelCallback(id); | 61 m_callbackCollection.cancelCallback(id); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT
imeNow) | 64 void CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT
imeNow) |
| 65 { | 65 { |
| 66 m_callbackCollection.executeCallbacks(highResTimeNow, highResTimeNow); | 66 m_callbackCollection.executeCallbacks(highResTimeNow, highResTimeNow); |
| 67 } | 67 } |
| 68 | 68 |
| 69 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const | 69 CompositorWorkerScript* CompositorWorkerGlobalScope::workerScript() const |
| 70 { | 70 { |
| 71 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); | 71 return static_cast<CompositorWorkerScript*>(WorkerGlobalScope::workerScript(
)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace blink | 74 } // namespace blink |
| OLD | NEW |