| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/AbstractAnimationWorkletThread.h" | 5 #include "modules/compositorworker/AbstractAnimationWorkletThread.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "core/workers/WorkerBackingThread.h" | 8 #include "core/workers/WorkerBackingThread.h" |
| 9 #include "core/workers/WorkletThreadHolder.h" | 9 #include "core/workers/WorkletThreadHolder.h" |
| 10 #include "platform/CrossThreadFunctional.h" | 10 #include "platform/CrossThreadFunctional.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 void AbstractAnimationWorkletThread::collectAllGarbage() { | 40 void AbstractAnimationWorkletThread::collectAllGarbage() { |
| 41 DCHECK(isMainThread()); | 41 DCHECK(isMainThread()); |
| 42 WaitableEvent doneEvent; | 42 WaitableEvent doneEvent; |
| 43 WorkletThreadHolder<AbstractAnimationWorkletThread>* workletThreadHolder = | 43 WorkletThreadHolder<AbstractAnimationWorkletThread>* workletThreadHolder = |
| 44 WorkletThreadHolder<AbstractAnimationWorkletThread>::getInstance(); | 44 WorkletThreadHolder<AbstractAnimationWorkletThread>::getInstance(); |
| 45 if (!workletThreadHolder) | 45 if (!workletThreadHolder) |
| 46 return; | 46 return; |
| 47 workletThreadHolder->thread()->backingThread().postTask( | 47 workletThreadHolder->thread()->backingThread().postTask( |
| 48 BLINK_FROM_HERE, crossThreadBind(&collectAllGarbageOnThread, | 48 BLINK_FROM_HERE, |
| 49 crossThreadUnretained(&doneEvent))); | 49 crossThreadBind(&collectAllGarbageOnThread, |
| 50 crossThreadUnretained(&doneEvent))); |
| 50 doneEvent.wait(); | 51 doneEvent.wait(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void AbstractAnimationWorkletThread::ensureSharedBackingThread() { | 54 void AbstractAnimationWorkletThread::ensureSharedBackingThread() { |
| 54 DCHECK(isMainThread()); | 55 DCHECK(isMainThread()); |
| 55 WorkletThreadHolder<AbstractAnimationWorkletThread>::ensureInstance( | 56 WorkletThreadHolder<AbstractAnimationWorkletThread>::ensureInstance( |
| 56 Platform::current()->compositorThread()); | 57 Platform::current()->compositorThread()); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void AbstractAnimationWorkletThread::clearSharedBackingThread() { | 60 void AbstractAnimationWorkletThread::clearSharedBackingThread() { |
| 60 DCHECK(isMainThread()); | 61 DCHECK(isMainThread()); |
| 61 WorkletThreadHolder<AbstractAnimationWorkletThread>::clearInstance(); | 62 WorkletThreadHolder<AbstractAnimationWorkletThread>::clearInstance(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void AbstractAnimationWorkletThread::createSharedBackingThreadForTest() { | 65 void AbstractAnimationWorkletThread::createSharedBackingThreadForTest() { |
| 65 WorkletThreadHolder<AbstractAnimationWorkletThread>::createForTest( | 66 WorkletThreadHolder<AbstractAnimationWorkletThread>::createForTest( |
| 66 Platform::current()->compositorThread()); | 67 Platform::current()->compositorThread()); |
| 67 } | 68 } |
| 68 | 69 |
| 69 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |