| 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" |
| 11 #include "platform/WaitableEvent.h" | 11 #include "platform/WaitableEvent.h" |
| 12 #include "platform/WebThreadSupportingGC.h" | 12 #include "platform/WebThreadSupportingGC.h" |
| 13 #include "platform/instrumentation/tracing/TraceEvent.h" | 13 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 14 #include "platform/weborigin/SecurityOrigin.h" | 14 #include "platform/weborigin/SecurityOrigin.h" |
| 15 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
| 16 #include "wtf/Assertions.h" | 16 #include "wtf/Assertions.h" |
| 17 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
| 18 #include <memory> | 18 #include <memory> |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 template class WorkletThreadHolder<AudioWorkletThread>; | 22 template class WorkletThreadHolder<AudioWorkletThread>; |
| 23 | 23 |
| 24 std::unique_ptr<AudioWorkletThread> AudioWorkletThread::create( | 24 std::unique_ptr<AudioWorkletThread> AudioWorkletThread::create( |
| 25 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, | 25 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, |
| 26 WorkerReportingProxy& workerReportingProxy) { | 26 WorkerReportingProxy& workerReportingProxy, |
| 27 ParentFrameTaskRunners* parentFrameTaskRunners) { |
| 27 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("audio-worklet"), | 28 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("audio-worklet"), |
| 28 "AudioWorkletThread::create"); | 29 "AudioWorkletThread::create"); |
| 29 DCHECK(isMainThread()); | 30 DCHECK(isMainThread()); |
| 30 return WTF::wrapUnique(new AudioWorkletThread(std::move(workerLoaderProxy), | 31 return WTF::wrapUnique(new AudioWorkletThread(std::move(workerLoaderProxy), |
| 31 workerReportingProxy)); | 32 workerReportingProxy, |
| 33 parentFrameTaskRunners)); |
| 32 } | 34 } |
| 33 | 35 |
| 34 AudioWorkletThread::AudioWorkletThread( | 36 AudioWorkletThread::AudioWorkletThread( |
| 35 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, | 37 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, |
| 36 WorkerReportingProxy& workerReportingProxy) | 38 WorkerReportingProxy& workerReportingProxy, |
| 37 : WorkerThread(std::move(workerLoaderProxy), workerReportingProxy) {} | 39 ParentFrameTaskRunners* parentFrameTaskRunners) |
| 40 : WorkerThread(std::move(workerLoaderProxy), |
| 41 workerReportingProxy, |
| 42 parentFrameTaskRunners) {} |
| 38 | 43 |
| 39 AudioWorkletThread::~AudioWorkletThread() {} | 44 AudioWorkletThread::~AudioWorkletThread() {} |
| 40 | 45 |
| 41 WorkerBackingThread& AudioWorkletThread::workerBackingThread() { | 46 WorkerBackingThread& AudioWorkletThread::workerBackingThread() { |
| 42 return *WorkletThreadHolder<AudioWorkletThread>::getInstance()->thread(); | 47 return *WorkletThreadHolder<AudioWorkletThread>::getInstance()->thread(); |
| 43 } | 48 } |
| 44 | 49 |
| 45 void collectAllGarbageOnAudioWorkletThread(WaitableEvent* doneEvent) { | 50 void collectAllGarbageOnAudioWorkletThread(WaitableEvent* doneEvent) { |
| 46 blink::ThreadState::current()->collectAllGarbage(); | 51 blink::ThreadState::current()->collectAllGarbage(); |
| 47 doneEvent->signal(); | 52 doneEvent->signal(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 securityOrigin->transferPrivilegesFrom( | 90 securityOrigin->transferPrivilegesFrom( |
| 86 std::move(startupData->m_starterOriginPrivilegeData)); | 91 std::move(startupData->m_starterOriginPrivilegeData)); |
| 87 } | 92 } |
| 88 | 93 |
| 89 return AudioWorkletGlobalScope::create( | 94 return AudioWorkletGlobalScope::create( |
| 90 startupData->m_scriptURL, startupData->m_userAgent, | 95 startupData->m_scriptURL, startupData->m_userAgent, |
| 91 securityOrigin.release(), this->isolate(), this); | 96 securityOrigin.release(), this->isolate(), this); |
| 92 } | 97 } |
| 93 | 98 |
| 94 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |