Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioWorklet.cpp

Issue 2793593002: AudioWorklet prototype
Patch Set: Merge changes, AudioParam bug fix Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/AudioWorklet.h" 5 #include "modules/webaudio/AudioWorklet.h"
6 6
7 #include "bindings/core/v8/V8BindingForCore.h" 7 #include "bindings/core/v8/V8BindingForCore.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/workers/WorkerClients.h" 10 #include "core/workers/WorkerClients.h"
11 #include "modules/webaudio/AudioWorkletMessagingProxy.h" 11 #include "modules/webaudio/AudioWorkletMessagingProxy.h"
12 #include "modules/webaudio/AudioWorkletThread.h" 12 #include "modules/webaudio/AudioWorkletThread.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 AudioWorklet* AudioWorklet::Create(LocalFrame* frame) { 16 AudioWorklet* AudioWorklet::Create(LocalFrame* frame) {
17 return new AudioWorklet(frame); 17 return new AudioWorklet(frame);
18 } 18 }
19 19
20 AudioWorklet::AudioWorklet(LocalFrame* frame) : Worklet(frame) {} 20 AudioWorklet::AudioWorklet(LocalFrame* frame) : Worklet(frame) {}
21 21
22 AudioWorklet::~AudioWorklet() {} 22 AudioWorklet::~AudioWorklet() {}
23 23
24 AudioWorkletMessagingProxy* AudioWorklet::GetWorkletMessagingProxy() const {
25 return static_cast<AudioWorkletMessagingProxy*>(
26 FindAvailableGlobalScope());
27 }
28
24 bool AudioWorklet::NeedsToCreateGlobalScope() { 29 bool AudioWorklet::NeedsToCreateGlobalScope() {
25 // For now, create only one global scope per document. 30 // For now, create only one global scope per document.
26 // TODO(nhiroki): Revisit this later. 31 // TODO(nhiroki): Revisit this later.
27 return GetNumberOfGlobalScopes() == 0; 32 return GetNumberOfGlobalScopes() == 0;
28 } 33 }
29 34
30 WorkletGlobalScopeProxy* AudioWorklet::CreateGlobalScope() { 35 WorkletGlobalScopeProxy* AudioWorklet::CreateGlobalScope() {
31 DCHECK(NeedsToCreateGlobalScope()); 36 DCHECK(NeedsToCreateGlobalScope());
32 AudioWorkletThread::EnsureSharedBackingThread(); 37 AudioWorkletThread::EnsureSharedBackingThread();
33 38
34 WorkerClients* worker_clients = WorkerClients::Create(); 39 WorkerClients* worker_clients = WorkerClients::Create();
35 AudioWorkletMessagingProxy* proxy = 40 AudioWorkletMessagingProxy* proxy =
36 new AudioWorkletMessagingProxy(GetExecutionContext(), worker_clients); 41 new AudioWorkletMessagingProxy(GetExecutionContext(), worker_clients);
37 proxy->Initialize(); 42 proxy->Initialize();
38 return proxy; 43 return proxy;
39 } 44 }
40 45
41 DEFINE_TRACE(AudioWorklet) { 46 DEFINE_TRACE(AudioWorklet) {
42 Worklet::Trace(visitor); 47 Worklet::Trace(visitor);
43 } 48 }
44 49
45 } // namespace blink 50 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698