OLD | NEW |
(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 |
OLD | NEW |