| 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/webaudio/AudioWorkletThread.h" | 5 #include "modules/webaudio/AudioWorkletThread.h" |
| 6 | 6 |
| 7 #include "core/workers/WorkerBackingThread.h" | 7 #include "core/workers/WorkerBackingThread.h" |
| 8 #include "core/workers/WorkerThreadStartupData.h" | 8 #include "core/workers/WorkerThreadStartupData.h" |
| 9 #include "modules/webaudio/AudioWorkletGlobalScope.h" | 9 #include "modules/webaudio/AudioWorkletGlobalScope.h" |
| 10 #include "platform/CrossThreadFunctional.h" | 10 #include "platform/CrossThreadFunctional.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (!threadHolderInstance) | 56 if (!threadHolderInstance) |
| 57 return; | 57 return; |
| 58 threadHolderInstance->thread()->backingThread().postTask( | 58 threadHolderInstance->thread()->backingThread().postTask( |
| 59 BLINK_FROM_HERE, crossThreadBind(&collectAllGarbageOnAudioWorkletThread, | 59 BLINK_FROM_HERE, crossThreadBind(&collectAllGarbageOnAudioWorkletThread, |
| 60 crossThreadUnretained(&doneEvent))); | 60 crossThreadUnretained(&doneEvent))); |
| 61 doneEvent.wait(); | 61 doneEvent.wait(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void AudioWorkletThread::ensureSharedBackingThread() { | 64 void AudioWorkletThread::ensureSharedBackingThread() { |
| 65 DCHECK(isMainThread()); | 65 DCHECK(isMainThread()); |
| 66 WorkletThreadHolder<AudioWorkletThread>::ensureInstance( | 66 WorkletThreadHolder<AudioWorkletThread>::ensureInstance("AudioWorkletThread"); |
| 67 "AudioWorkletThread", BlinkGC::PerThreadHeapMode); | |
| 68 } | 67 } |
| 69 | 68 |
| 70 void AudioWorkletThread::clearSharedBackingThread() { | 69 void AudioWorkletThread::clearSharedBackingThread() { |
| 71 DCHECK(isMainThread()); | 70 DCHECK(isMainThread()); |
| 72 WorkletThreadHolder<AudioWorkletThread>::clearInstance(); | 71 WorkletThreadHolder<AudioWorkletThread>::clearInstance(); |
| 73 } | 72 } |
| 74 | 73 |
| 75 void AudioWorkletThread::createSharedBackingThreadForTest() { | 74 void AudioWorkletThread::createSharedBackingThreadForTest() { |
| 76 WorkletThreadHolder<AudioWorkletThread>::createForTest( | 75 WorkletThreadHolder<AudioWorkletThread>::createForTest("AudioWorkletThread"); |
| 77 "AudioWorkletThread", BlinkGC::PerThreadHeapMode); | |
| 78 } | 76 } |
| 79 | 77 |
| 80 WorkerOrWorkletGlobalScope* AudioWorkletThread::createWorkerGlobalScope( | 78 WorkerOrWorkletGlobalScope* AudioWorkletThread::createWorkerGlobalScope( |
| 81 std::unique_ptr<WorkerThreadStartupData> startupData) { | 79 std::unique_ptr<WorkerThreadStartupData> startupData) { |
| 82 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("audio-worklet"), | 80 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("audio-worklet"), |
| 83 "AudioWorkletThread::createWorkerGlobalScope"); | 81 "AudioWorkletThread::createWorkerGlobalScope"); |
| 84 | 82 |
| 85 RefPtr<SecurityOrigin> securityOrigin = | 83 RefPtr<SecurityOrigin> securityOrigin = |
| 86 SecurityOrigin::create(startupData->m_scriptURL); | 84 SecurityOrigin::create(startupData->m_scriptURL); |
| 87 if (startupData->m_starterOriginPrivilegeData) { | 85 if (startupData->m_starterOriginPrivilegeData) { |
| 88 securityOrigin->transferPrivilegesFrom( | 86 securityOrigin->transferPrivilegesFrom( |
| 89 std::move(startupData->m_starterOriginPrivilegeData)); | 87 std::move(startupData->m_starterOriginPrivilegeData)); |
| 90 } | 88 } |
| 91 | 89 |
| 92 return AudioWorkletGlobalScope::create( | 90 return AudioWorkletGlobalScope::create( |
| 93 startupData->m_scriptURL, startupData->m_userAgent, | 91 startupData->m_scriptURL, startupData->m_userAgent, |
| 94 securityOrigin.release(), this->isolate(), this); | 92 securityOrigin.release(), this->isolate(), this); |
| 95 } | 93 } |
| 96 | 94 |
| 97 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |