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

Unified Diff: third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp

Issue 2567243005: WindowAudioWorklet should use ContextLifecycleObserver instead of DOMWindowProperty (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp b/third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp
index 3f6255407670558bc0608397ac552b11f34816c3..106c562eb847b48de321c2434447897f7327229e 100644
--- a/third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp
@@ -4,6 +4,7 @@
#include "modules/webaudio/WindowAudioWorklet.h"
+#include "core/dom/Document.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "modules/webaudio/AudioWorklet.h"
@@ -11,7 +12,7 @@
namespace blink {
WindowAudioWorklet::WindowAudioWorklet(LocalDOMWindow& window)
- : DOMWindowProperty(window.frame()) {}
+ : ContextLifecycleObserver(window.frame()->document()) {}
const char* WindowAudioWorklet::supplementName() {
return "WindowAudioWorklet";
@@ -28,24 +29,34 @@ WindowAudioWorklet& WindowAudioWorklet::from(LocalDOMWindow& window) {
}
Worklet* WindowAudioWorklet::audioWorklet(DOMWindow& window) {
- return from(toLocalDOMWindow(window)).audioWorklet();
+ return from(toLocalDOMWindow(window)).audioWorklet(toLocalDOMWindow(window));
}
-AudioWorklet* WindowAudioWorklet::audioWorklet() {
- if (!m_audioWorklet && frame())
- m_audioWorklet = AudioWorklet::create(frame());
+AudioWorklet* WindowAudioWorklet::audioWorklet(LocalDOMWindow& window) {
+ if (!m_audioWorklet && getExecutionContext()) {
+ DCHECK(window.frame());
+ m_audioWorklet = AudioWorklet::create(window.frame());
+ }
return m_audioWorklet.get();
}
-void WindowAudioWorklet::frameDestroyed() {
- m_audioWorklet.clear();
- DOMWindowProperty::frameDestroyed();
+// Break the following cycle when the context gets detached.
+// Otherwise, the worklet object will leak.
+//
+// window => window.audioWorklet
+// => WindowAudioWorklet
+// => AudioWorklet <--- break this reference
+// => ThreadedWorkletMessagingProxy
+// => Document
+// => ... => window
+void WindowAudioWorklet::contextDestroyed() {
+ m_audioWorklet = nullptr;
}
DEFINE_TRACE(WindowAudioWorklet) {
visitor->trace(m_audioWorklet);
Supplement<LocalDOMWindow>::trace(visitor);
- DOMWindowProperty::trace(visitor);
+ ContextLifecycleObserver::trace(visitor);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698