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

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

Issue 2912743002: [WIP] Worklet: Merge MainThreadWorklet and ThreadedWorklet into Worklet
Patch Set: WIP Created 3 years, 6 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 "modules/webaudio/AudioWorkletMessagingProxy.h" 10 #include "modules/webaudio/AudioWorkletMessagingProxy.h"
11 #include "modules/webaudio/AudioWorkletThread.h" 11 #include "modules/webaudio/AudioWorkletThread.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 AudioWorklet* AudioWorklet::Create(LocalFrame* frame) { 15 AudioWorklet* AudioWorklet::Create(LocalFrame* frame) {
16 return new AudioWorklet(frame); 16 return new AudioWorklet(frame);
17 } 17 }
18 18
19 AudioWorklet::AudioWorklet(LocalFrame* frame) 19 AudioWorklet::AudioWorklet(LocalFrame* frame) : Worklet(frame) {}
20 : ThreadedWorklet(frame), worklet_messaging_proxy_(nullptr) {}
21 20
22 AudioWorklet::~AudioWorklet() { 21 AudioWorklet::~AudioWorklet() {
23 if (worklet_messaging_proxy_) 22 // The proxy outlives the worklet as it is used to perform thread shutdown,
24 worklet_messaging_proxy_->ParentObjectDestroyed(); 23 // it deletes itself once this has occurred.
24 // TODO(nhiroki):
25 } 25 }
26 26
27 void AudioWorklet::Initialize() { 27 bool AudioWorklet::NeedsToCreateGlobalScope() {
28 AudioWorkletThread::EnsureSharedBackingThread(); 28 // In the current impl, we create only one global scope.
29 29 return !GetNumberOfGlobalScopes();
30 DCHECK(!worklet_messaging_proxy_);
31 DCHECK(GetExecutionContext());
32
33 worklet_messaging_proxy_ =
34 new AudioWorkletMessagingProxy(GetExecutionContext());
35 worklet_messaging_proxy_->Initialize();
36 } 30 }
37 31
38 bool AudioWorklet::IsInitialized() const { 32 std::unique_ptr<WorkletGlobalScopeProxy> AudioWorklet::CreateGlobalScope() {
39 return worklet_messaging_proxy_; 33 AudioWorkletThread::EnsureSharedBackingThread();
40 } 34 return WTF::MakeUnique<AudioWorkletMessagingProxy>(GetExecutionContext());
41
42 WorkletGlobalScopeProxy* AudioWorklet::GetWorkletGlobalScopeProxy() const {
43 DCHECK(worklet_messaging_proxy_);
44 return worklet_messaging_proxy_;
45 } 35 }
46 36
47 DEFINE_TRACE(AudioWorklet) { 37 DEFINE_TRACE(AudioWorklet) {
48 ThreadedWorklet::Trace(visitor); 38 Worklet::Trace(visitor);
49 } 39 }
50 40
51 } // namespace blink 41 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698