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

Side by Side Diff: Source/core/wawwa/RemotePlayer.cpp

Issue 491053004: Expose Web Animations API to Web Workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Exposing the Web Animations API to Web Workers Created 6 years, 3 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES{
25
26 } LOSS OF USE,
27 * DATA, OR PROFITS{
28
29 } OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "config.h"
36 #include "core/wawwa/RemotePlayer.h"
37
38 #include "core/page/Page.h"
39 #include "core/wawwa/ProxyMap.h"
40
41 namespace blink {
42
43 RemotePlayer::RemotePlayer(String inputID, PassRefPtr<DedicatedWorkerGlobalScope > workerGlobalScope, const Vector<ProxyKeyframe> keyframes, const Timing timingI nputDictionary)
44 : m_workerGlobalScope(workerGlobalScope)
45 {
46 m_id = inputID;
47 startTime = std::numeric_limits<double>::quiet_NaN();
48 for (size_t i = 0; i < keyframes.size(); i++) {
49 m_keyframes.append(keyframes[i]);
50 }
51 m_timingInputDictionary = timingInputDictionary;
52 String temp = m_id.isolatedCopy();
53 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
54 Page* page = doc->page();
55 m_workerGlobalScope->thread()->workerObjectProxy().postTaskToMainExecutionCo ntext(createCrossThreadTask(&ProxyMap::addtoMapRemotePlayer, AllowCrossThreadAcc ess(page->m_ProxyMap.get()), temp, this));
56 }
57
58 PassRefPtrWillBeRawPtr<RemotePlayer> RemotePlayer::create(String inputID, PassRe fPtr<DedicatedWorkerGlobalScope> workerGlobalScope, const Vector<ProxyKeyframe> keyframes, const Timing timingInputDictionary)
59 {
60 return adoptRef(new RemotePlayer(inputID, workerGlobalScope, keyframes, timi ngInputDictionary));
61 }
62
63 void RemotePlayer::pause(ExceptionState & es)
64 {
65 String temp = m_id.isolatedCopy();
66 ASSERT(temp.isSafeToSendToAnotherThread());
67 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
68 Page* page = doc->page();
69 WorkerObjectProxy wop = m_workerGlobalScope->thread()->workerObjectProxy();
70 wop.postTaskToMainExecutionContext(createCrossThreadTask(&ProxyMap::execute, AllowCrossThreadAccess(page->m_ProxyMap.get()), Pause, temp, m_keyframes, m_tim ingInputDictionary));
71 }
72
73 void RemotePlayer::play(ExceptionState & es)
74 {
75 String temp = m_id.isolatedCopy();
76 ASSERT(temp.isSafeToSendToAnotherThread());
77 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
78 Page* page = doc->page();
79 WorkerObjectProxy wop = m_workerGlobalScope->thread()->workerObjectProxy();
80 wop.postTaskToMainExecutionContext(createCrossThreadTask(&ProxyMap::execute, AllowCrossThreadAccess(page->m_ProxyMap.get()), Play, temp, m_keyframes, m_timi ngInputDictionary));
81 }
82
83 void RemotePlayer::cancel(ExceptionState & es)
84 {
85 String temp = m_id.isolatedCopy();
86 ASSERT(temp.isSafeToSendToAnotherThread());
87 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
88 Page* page = doc->page();
89 WorkerObjectProxy wop = m_workerGlobalScope->thread()->workerObjectProxy();
90 wop.postTaskToMainExecutionContext(createCrossThreadTask(&ProxyMap::execute, AllowCrossThreadAccess(page->m_ProxyMap.get()), Cancel, temp, m_keyframes, m_ti mingInputDictionary));
91 }
92
93 void RemotePlayer::finish(ExceptionState & es)
94 {
95 String temp = m_id.isolatedCopy();
96 ASSERT(temp.isSafeToSendToAnotherThread());
97 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
98 Page* page = doc->page();
99 WorkerObjectProxy wop = m_workerGlobalScope->thread()->workerObjectProxy();
100 wop.postTaskToMainExecutionContext(createCrossThreadTask(&ProxyMap::execute, AllowCrossThreadAccess(page->m_ProxyMap.get()), Finish, temp, m_keyframes, m_ti mingInputDictionary));
101 }
102
103 void RemotePlayer::reverse(ExceptionState & es)
104 {
105 String temp = m_id.isolatedCopy();
106 ASSERT(temp.isSafeToSendToAnotherThread());
107 Document* doc = static_cast<Document*>(m_workerGlobalScope->thread()->worker ObjectProxy().context());
108 Page* page = doc->page();
109 WorkerObjectProxy wop = m_workerGlobalScope->thread()->workerObjectProxy();
110 wop.postTaskToMainExecutionContext(createCrossThreadTask(&ProxyMap::execute, AllowCrossThreadAccess(page->m_ProxyMap.get()), Reverse, temp, m_keyframes, m_t imingInputDictionary));
111 }
112
113 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698