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) { | |
28 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("audio-worklet"), | 27 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("audio-worklet"), |
29 "AudioWorkletThread::create"); | 28 "AudioWorkletThread::create"); |
30 DCHECK(isMainThread()); | 29 DCHECK(isMainThread()); |
31 return WTF::wrapUnique(new AudioWorkletThread(std::move(workerLoaderProxy), | 30 return WTF::wrapUnique(new AudioWorkletThread(std::move(workerLoaderProxy), |
32 workerReportingProxy, | 31 workerReportingProxy)); |
33 parentFrameTaskRunners)); | |
34 } | 32 } |
35 | 33 |
36 AudioWorkletThread::AudioWorkletThread( | 34 AudioWorkletThread::AudioWorkletThread( |
37 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, | 35 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, |
38 WorkerReportingProxy& workerReportingProxy, | 36 WorkerReportingProxy& workerReportingProxy) |
39 ParentFrameTaskRunners* parentFrameTaskRunners) | 37 : WorkerThread(std::move(workerLoaderProxy), workerReportingProxy) {} |
40 : WorkerThread(std::move(workerLoaderProxy), | |
41 workerReportingProxy, | |
42 parentFrameTaskRunners) {} | |
43 | 38 |
44 AudioWorkletThread::~AudioWorkletThread() {} | 39 AudioWorkletThread::~AudioWorkletThread() {} |
45 | 40 |
46 WorkerBackingThread& AudioWorkletThread::workerBackingThread() { | 41 WorkerBackingThread& AudioWorkletThread::workerBackingThread() { |
47 return *WorkletThreadHolder<AudioWorkletThread>::getInstance()->thread(); | 42 return *WorkletThreadHolder<AudioWorkletThread>::getInstance()->thread(); |
48 } | 43 } |
49 | 44 |
50 void collectAllGarbageOnAudioWorkletThread(WaitableEvent* doneEvent) { | 45 void collectAllGarbageOnAudioWorkletThread(WaitableEvent* doneEvent) { |
51 blink::ThreadState::current()->collectAllGarbage(); | 46 blink::ThreadState::current()->collectAllGarbage(); |
52 doneEvent->signal(); | 47 doneEvent->signal(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 securityOrigin->transferPrivilegesFrom( | 85 securityOrigin->transferPrivilegesFrom( |
91 std::move(startupData->m_starterOriginPrivilegeData)); | 86 std::move(startupData->m_starterOriginPrivilegeData)); |
92 } | 87 } |
93 | 88 |
94 return AudioWorkletGlobalScope::create( | 89 return AudioWorkletGlobalScope::create( |
95 startupData->m_scriptURL, startupData->m_userAgent, | 90 startupData->m_scriptURL, startupData->m_userAgent, |
96 securityOrigin.release(), this->isolate(), this); | 91 securityOrigin.release(), this->isolate(), this); |
97 } | 92 } |
98 | 93 |
99 } // namespace blink | 94 } // namespace blink |
OLD | NEW |