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

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

Issue 1026843003: compositor-worker: Create a separate CompositorWorkerGlobalScope for compositor workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/compositorworker/CompositorWorkerGlobalScope.h"
7
8 #include "core/dom/RequestAnimationFrameCallback.h"
9 #include "core/workers/WorkerThreadStartupData.h"
10 #include "modules/EventTargetModules.h"
11 #include "modules/compositorworker/CompositorWorkerThread.h"
12
13 namespace blink {
14
15 PassRefPtrWillBeRawPtr<CompositorWorkerGlobalScope> CompositorWorkerGlobalScope: :create(CompositorWorkerThread* thread, PassOwnPtrWillBeRawPtr<WorkerThreadStart upData> startupData, double timeOrigin)
16 {
17 RefPtrWillBeRawPtr<CompositorWorkerGlobalScope> context = adoptRefWillBeNoop (new CompositorWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAg ent, thread, timeOrigin, startupData->m_starterOrigin, startupData->m_workerClie nts.release()));
18 context->applyContentSecurityPolicyFromString(startupData->m_contentSecurity Policy, startupData->m_contentSecurityPolicyType);
19 return context.release();
20 }
21
22 CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const String& userAgent, CompositorWorkerThread* thread, double timeOrigin, const Secu rityOrigin* starterOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> workerClients)
23 : DedicatedWorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOrig in, workerClients)
24 , m_nextCallbackId(0)
25 {
26 }
27
28 CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope()
29 {
30 }
31
32 // EventTarget
33 const AtomicString& CompositorWorkerGlobalScope::interfaceName() const
34 {
35 return EventTargetNames::CompositorWorkerGlobalScope;
36 }
37
38 int CompositorWorkerGlobalScope::requestCompositorFrame(RequestAnimationFrameCal lback* callback)
39 {
40 callback->m_cancelled = false;
41 callback->m_id = ++m_nextCallbackId;
42 m_callbacks.append(callback);
43 return callback->m_id;
44 }
45
46 void CompositorWorkerGlobalScope::cancelCompositorFrame(int id)
47 {
48 for (size_t i = 0; i < m_callbacks.size(); ++i) {
49 if (m_callbacks[i]->m_id == id) {
50 m_callbacks.remove(i);
51 return;
52 }
53 }
54 for (size_t i = 0; i < m_callbacksToInvoke.size(); ++i) {
55 if (m_callbacksToInvoke[i]->m_id == id) {
56 m_callbacksToInvoke[i]->m_cancelled = true;
57 // will be removed at the end of executeCallbacks()
58 return;
59 }
60 }
61 }
62
63 void CompositorWorkerGlobalScope::executeCompositorFrameCallbacks(double monoton icTimeNow)
64 {
65 if (!m_callbacks.size())
66 return;
67 // First, generate a list of callbacks to consider. Callbacks registered fr om this point
68 // on are considered only for the "next" frame, not this one.
69 ASSERT(m_callbacksToInvoke.isEmpty());
70 m_callbacksToInvoke.swap(m_callbacks);
71
72 for (size_t i = 0; i < m_callbacksToInvoke.size(); ++i) {
73 RequestAnimationFrameCallback* callback = m_callbacksToInvoke[i].get();
74 if (!callback->m_cancelled)
75 callback->handleEvent(monotonicTimeNow);
76 }
77
78 m_callbacksToInvoke.clear();
79 }
80
81 DEFINE_TRACE(CompositorWorkerGlobalScope)
82 {
83 DedicatedWorkerGlobalScope::trace(visitor);
84 }
85
86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698