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

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

Issue 2607353002: WindowAudioWorklet: gracefully handle detached use. (Closed)
Patch Set: static version Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/WindowAudioWorklet.h" 5 #include "modules/webaudio/WindowAudioWorklet.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/LocalDOMWindow.h" 8 #include "core/frame/LocalDOMWindow.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "modules/webaudio/AudioWorklet.h" 10 #include "modules/webaudio/AudioWorklet.h"
(...skipping 11 matching lines...) Expand all
22 WindowAudioWorklet* supplement = static_cast<WindowAudioWorklet*>( 22 WindowAudioWorklet* supplement = static_cast<WindowAudioWorklet*>(
23 Supplement<LocalDOMWindow>::from(window, supplementName())); 23 Supplement<LocalDOMWindow>::from(window, supplementName()));
24 if (!supplement) { 24 if (!supplement) {
25 supplement = new WindowAudioWorklet(window); 25 supplement = new WindowAudioWorklet(window);
26 provideTo(window, supplementName(), supplement); 26 provideTo(window, supplementName(), supplement);
27 } 27 }
28 return *supplement; 28 return *supplement;
29 } 29 }
30 30
31 Worklet* WindowAudioWorklet::audioWorklet(DOMWindow& window) { 31 Worklet* WindowAudioWorklet::audioWorklet(DOMWindow& window) {
32 if (!window.frame())
33 return nullptr;
32 return from(toLocalDOMWindow(window)).audioWorklet(toLocalDOMWindow(window)); 34 return from(toLocalDOMWindow(window)).audioWorklet(toLocalDOMWindow(window));
33 } 35 }
34 36
35 AudioWorklet* WindowAudioWorklet::audioWorklet(LocalDOMWindow& window) { 37 AudioWorklet* WindowAudioWorklet::audioWorklet(LocalDOMWindow& window) {
36 if (!m_audioWorklet && getExecutionContext()) { 38 if (!m_audioWorklet && getExecutionContext()) {
37 DCHECK(window.frame()); 39 DCHECK(window.frame());
38 m_audioWorklet = AudioWorklet::create(window.frame()); 40 m_audioWorklet = AudioWorklet::create(window.frame());
39 } 41 }
40 return m_audioWorklet.get(); 42 return m_audioWorklet.get();
41 } 43 }
(...skipping 11 matching lines...) Expand all
53 m_audioWorklet = nullptr; 55 m_audioWorklet = nullptr;
54 } 56 }
55 57
56 DEFINE_TRACE(WindowAudioWorklet) { 58 DEFINE_TRACE(WindowAudioWorklet) {
57 visitor->trace(m_audioWorklet); 59 visitor->trace(m_audioWorklet);
58 Supplement<LocalDOMWindow>::trace(visitor); 60 Supplement<LocalDOMWindow>::trace(visitor);
59 ContextLifecycleObserver::trace(visitor); 61 ContextLifecycleObserver::trace(visitor);
60 } 62 }
61 63
62 } // namespace blink 64 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698