| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 { | 48 { |
| 49 return EventTargetNames::CompositorWorkerGlobalScope; | 49 return EventTargetNames::CompositorWorkerGlobalScope; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext
, PassRefPtr<SerializedScriptValue> message, const MessagePortArray& ports, Exce
ptionState& exceptionState) | 52 void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext
, PassRefPtr<SerializedScriptValue> message, const MessagePortArray& ports, Exce
ptionState& exceptionState) |
| 53 { | 53 { |
| 54 // Disentangle the port in preparation for sending it to the remote context. | 54 // Disentangle the port in preparation for sending it to the remote context. |
| 55 std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentangle
Ports(executionContext, ports, exceptionState); | 55 std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentangle
Ports(executionContext, ports, exceptionState); |
| 56 if (exceptionState.hadException()) | 56 if (exceptionState.hadException()) |
| 57 return; | 57 return; |
| 58 thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(c
hannels)); | 58 thread()->workerObjectProxy().postMessageToWorkerObject(std::move(message),
std::move(channels)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) | 61 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal
lback) |
| 62 { | 62 { |
| 63 const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackC
ollection.isEmpty(); | 63 const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackC
ollection.isEmpty(); |
| 64 if (shouldSignal) | 64 if (shouldSignal) |
| 65 CompositorProxyClient::from(clients())->requestAnimationFrame(); | 65 CompositorProxyClient::from(clients())->requestAnimationFrame(); |
| 66 return m_callbackCollection.registerCallback(callback); | 66 return m_callbackCollection.registerCallback(callback); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) | 69 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) |
| 70 { | 70 { |
| 71 m_callbackCollection.cancelCallback(id); | 71 m_callbackCollection.cancelCallback(id); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT
imeMs) | 74 bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT
imeMs) |
| 75 { | 75 { |
| 76 AutoReset<bool> temporaryChange(&m_executingAnimationFrameCallbacks, true); | 76 AutoReset<bool> temporaryChange(&m_executingAnimationFrameCallbacks, true); |
| 77 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); | 77 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); |
| 78 return !m_callbackCollection.isEmpty(); | 78 return !m_callbackCollection.isEmpty(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const | 81 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const |
| 82 { | 82 { |
| 83 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); | 83 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace blink | 86 } // namespace blink |
| OLD | NEW |