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/InProcessWorkerObjectProxy.h" | 8 #include "core/workers/InProcessWorkerObjectProxy.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 #include <memory> |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 CompositorWorkerGlobalScope* CompositorWorkerGlobalScope::create(CompositorWorke
rThread* thread, PassOwnPtr<WorkerThreadStartupData> startupData, double timeOri
gin) | 16 CompositorWorkerGlobalScope* CompositorWorkerGlobalScope::create(CompositorWorke
rThread* thread, std::unique_ptr<WorkerThreadStartupData> startupData, double ti
meOrigin) |
16 { | 17 { |
17 // Note: startupData is finalized on return. After the relevant parts has be
en | 18 // Note: startupData is finalized on return. After the relevant parts has be
en |
18 // passed along to the created 'context'. | 19 // passed along to the created 'context'. |
19 CompositorWorkerGlobalScope* context = new CompositorWorkerGlobalScope(start
upData->m_scriptURL, startupData->m_userAgent, thread, timeOrigin, std::move(sta
rtupData->m_starterOriginPrivilegeData), startupData->m_workerClients.release())
; | 20 CompositorWorkerGlobalScope* context = new CompositorWorkerGlobalScope(start
upData->m_scriptURL, startupData->m_userAgent, thread, timeOrigin, std::move(sta
rtupData->m_starterOriginPrivilegeData), startupData->m_workerClients.release())
; |
20 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit
yPolicyHeaders); | 21 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit
yPolicyHeaders); |
21 context->setAddressSpace(startupData->m_addressSpace); | 22 context->setAddressSpace(startupData->m_addressSpace); |
22 return context; | 23 return context; |
23 } | 24 } |
24 | 25 |
25 CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const
String& userAgent, CompositorWorkerThread* thread, double timeOrigin, PassOwnPtr
<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, WorkerClients* worke
rClients) | 26 CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const
String& userAgent, CompositorWorkerThread* thread, double timeOrigin, std::uniqu
e_ptr<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, WorkerClients*
workerClients) |
26 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, std::move(starterOri
ginPrivilegeData), workerClients) | 27 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, std::move(starterOri
ginPrivilegeData), workerClients) |
27 , m_executingAnimationFrameCallbacks(false) | 28 , m_executingAnimationFrameCallbacks(false) |
28 , m_callbackCollection(this) | 29 , m_callbackCollection(this) |
29 { | 30 { |
30 CompositorProxyClient::from(clients())->setGlobalScope(this); | 31 CompositorProxyClient::from(clients())->setGlobalScope(this); |
31 } | 32 } |
32 | 33 |
33 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope() | 34 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope() |
34 { | 35 { |
35 } | 36 } |
36 | 37 |
37 DEFINE_TRACE(CompositorWorkerGlobalScope) | 38 DEFINE_TRACE(CompositorWorkerGlobalScope) |
38 { | 39 { |
39 visitor->trace(m_callbackCollection); | 40 visitor->trace(m_callbackCollection); |
40 WorkerGlobalScope::trace(visitor); | 41 WorkerGlobalScope::trace(visitor); |
41 } | 42 } |
42 | 43 |
43 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const | 44 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const |
44 { | 45 { |
45 return EventTargetNames::CompositorWorkerGlobalScope; | 46 return EventTargetNames::CompositorWorkerGlobalScope; |
46 } | 47 } |
47 | 48 |
48 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext
, PassRefPtr<SerializedScriptValue> message, const MessagePortArray& ports, Exce
ptionState& exceptionState) | 49 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext
, PassRefPtr<SerializedScriptValue> message, const MessagePortArray& ports, Exce
ptionState& exceptionState) |
49 { | 50 { |
50 // Disentangle the port in preparation for sending it to the remote context. | 51 // Disentangle the port in preparation for sending it to the remote context. |
51 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(exe
cutionContext, ports, exceptionState); | 52 std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentangle
Ports(executionContext, ports, exceptionState); |
52 if (exceptionState.hadException()) | 53 if (exceptionState.hadException()) |
53 return; | 54 return; |
54 thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(c
hannels)); | 55 thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(c
hannels)); |
55 } | 56 } |
56 | 57 |
57 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) | 58 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) |
58 { | 59 { |
59 const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackC
ollection.isEmpty(); | 60 const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackC
ollection.isEmpty(); |
60 if (shouldSignal) | 61 if (shouldSignal) |
61 CompositorProxyClient::from(clients())->requestAnimationFrame(); | 62 CompositorProxyClient::from(clients())->requestAnimationFrame(); |
(...skipping 11 matching lines...) Expand all Loading... |
73 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); | 74 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); |
74 return !m_callbackCollection.isEmpty(); | 75 return !m_callbackCollection.isEmpty(); |
75 } | 76 } |
76 | 77 |
77 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const | 78 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const |
78 { | 79 { |
79 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); | 80 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); |
80 } | 81 } |
81 | 82 |
82 } // namespace blink | 83 } // namespace blink |
OLD | NEW |