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

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

Issue 2481843003: Worker: Add WorkerOrWorkletGlobalScope::thread() interface (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void CompositorWorkerGlobalScope::postMessage( 69 void CompositorWorkerGlobalScope::postMessage(
70 ExecutionContext* executionContext, 70 ExecutionContext* executionContext,
71 PassRefPtr<SerializedScriptValue> message, 71 PassRefPtr<SerializedScriptValue> message,
72 const MessagePortArray& ports, 72 const MessagePortArray& ports,
73 ExceptionState& exceptionState) { 73 ExceptionState& exceptionState) {
74 // Disentangle the port in preparation for sending it to the remote context. 74 // Disentangle the port in preparation for sending it to the remote context.
75 std::unique_ptr<MessagePortChannelArray> channels = 75 std::unique_ptr<MessagePortChannelArray> channels =
76 MessagePort::disentanglePorts(executionContext, ports, exceptionState); 76 MessagePort::disentanglePorts(executionContext, ports, exceptionState);
77 if (exceptionState.hadException()) 77 if (exceptionState.hadException())
78 return; 78 return;
79 thread()->workerObjectProxy().postMessageToWorkerObject(std::move(message), 79 workerObjectProxy().postMessageToWorkerObject(std::move(message),
80 std::move(channels)); 80 std::move(channels));
81 } 81 }
82 82
83 int CompositorWorkerGlobalScope::requestAnimationFrame( 83 int CompositorWorkerGlobalScope::requestAnimationFrame(
84 FrameRequestCallback* callback) { 84 FrameRequestCallback* callback) {
85 const bool shouldSignal = 85 const bool shouldSignal =
86 !m_executingAnimationFrameCallbacks && m_callbackCollection.isEmpty(); 86 !m_executingAnimationFrameCallbacks && m_callbackCollection.isEmpty();
87 if (shouldSignal) 87 if (shouldSignal)
88 CompositorProxyClient::from(clients())->requestAnimationFrame(); 88 CompositorProxyClient::from(clients())->requestAnimationFrame();
89 return m_callbackCollection.registerCallback(callback); 89 return m_callbackCollection.registerCallback(callback);
90 } 90 }
91 91
92 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) { 92 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id) {
93 m_callbackCollection.cancelCallback(id); 93 m_callbackCollection.cancelCallback(id);
94 } 94 }
95 95
96 bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks( 96 bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(
97 double highResTimeMs) { 97 double highResTimeMs) {
98 AutoReset<bool> temporaryChange(&m_executingAnimationFrameCallbacks, true); 98 AutoReset<bool> temporaryChange(&m_executingAnimationFrameCallbacks, true);
99 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs); 99 m_callbackCollection.executeCallbacks(highResTimeMs, highResTimeMs);
100 return !m_callbackCollection.isEmpty(); 100 return !m_callbackCollection.isEmpty();
101 } 101 }
102 102
103 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const { 103 InProcessWorkerObjectProxy& CompositorWorkerGlobalScope::workerObjectProxy()
104 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); 104 const {
105 return static_cast<CompositorWorkerThread*>(thread())->workerObjectProxy();
105 } 106 }
106 107
107 } // namespace blink 108 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698