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

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

Issue 1047783002: compositor-worker: Allow registering compositor-frame callbacks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 8 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" 6 #include "modules/compositorworker/CompositorWorkerGlobalScope.h"
7 7
8 #include "bindings/core/v8/SerializedScriptValue.h" 8 #include "bindings/core/v8/SerializedScriptValue.h"
9 #include "core/workers/WorkerObjectProxy.h" 9 #include "core/workers/WorkerObjectProxy.h"
10 #include "core/workers/WorkerThreadStartupData.h" 10 #include "core/workers/WorkerThreadStartupData.h"
11 #include "modules/EventTargetModules.h" 11 #include "modules/EventTargetModules.h"
12 #include "modules/compositorworker/CompositorWorkerThread.h" 12 #include "modules/compositorworker/CompositorWorkerThread.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 PassRefPtrWillBeRawPtr<CompositorWorkerGlobalScope> CompositorWorkerGlobalScope: :create(CompositorWorkerThread* thread, PassOwnPtrWillBeRawPtr<WorkerThreadStart upData> startupData, double timeOrigin) 16 PassRefPtrWillBeRawPtr<CompositorWorkerGlobalScope> CompositorWorkerGlobalScope: :create(CompositorWorkerThread* thread, PassOwnPtrWillBeRawPtr<WorkerThreadStart upData> startupData, double timeOrigin)
17 { 17 {
18 RefPtrWillBeRawPtr<CompositorWorkerGlobalScope> context = adoptRefWillBeNoop (new CompositorWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAg ent, thread, timeOrigin, startupData->m_starterOrigin, startupData->m_workerClie nts.release())); 18 RefPtrWillBeRawPtr<CompositorWorkerGlobalScope> context = adoptRefWillBeNoop (new CompositorWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAg ent, thread, timeOrigin, startupData->m_starterOrigin, startupData->m_workerClie nts.release()));
19 context->applyContentSecurityPolicyFromString(startupData->m_contentSecurity Policy, startupData->m_contentSecurityPolicyType); 19 context->applyContentSecurityPolicyFromString(startupData->m_contentSecurity Policy, startupData->m_contentSecurityPolicyType);
20 return context.release(); 20 return context.release();
21 } 21 }
22 22
23 CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const String& userAgent, CompositorWorkerThread* thread, double timeOrigin, const Secu rityOrigin* starterOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> workerClients) 23 CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const String& userAgent, CompositorWorkerThread* thread, double timeOrigin, const Secu rityOrigin* starterOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> workerClients)
24 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOrigin, worke rClients) 24 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOrigin, worke rClients)
25 , m_callbackCollection(this)
25 { 26 {
26 } 27 }
27 28
28 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope() 29 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope()
29 { 30 {
30 } 31 }
31 32
32 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const 33 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const
33 { 34 {
34 return EventTargetNames::CompositorWorkerGlobalScope; 35 return EventTargetNames::CompositorWorkerGlobalScope;
35 } 36 }
36 37
37 void CompositorWorkerGlobalScope::postMessage(ExecutionContext*, PassRefPtr<Seri alizedScriptValue> message, const MessagePortArray* ports, ExceptionState& excep tionState) 38 void CompositorWorkerGlobalScope::postMessage(ExecutionContext*, PassRefPtr<Seri alizedScriptValue> message, const MessagePortArray* ports, ExceptionState& excep tionState)
38 { 39 {
39 // Disentangle the port in preparation for sending it to the remote context. 40 // Disentangle the port in preparation for sending it to the remote context.
40 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por ts, exceptionState); 41 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por ts, exceptionState);
41 if (exceptionState.hadException()) 42 if (exceptionState.hadException())
42 return; 43 return;
43 thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.re lease()); 44 thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.re lease());
44 } 45 }
45 46
47 int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* cal lback)
48 {
49 return m_callbackCollection.registerCallback(callback);
50 }
51
52 void CompositorWorkerGlobalScope::cancelAnimationFrame(int id)
53 {
54 m_callbackCollection.cancelCallback(id);
55 }
56
57 void CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResT imeNow)
58 {
59 m_callbackCollection.executeCallbacks(highResTimeNow, highResTimeNow);
60 }
61
46 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const 62 CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const
47 { 63 {
48 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread()); 64 return static_cast<CompositorWorkerThread*>(WorkerGlobalScope::thread());
49 } 65 }
50 66
51 } // namespace blink 67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698