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

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

Issue 2668753006: Special-case LocalDOMWindow for same-origin access in bindings. (Closed)
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
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 4aa08ad30d7841caab43cbab65828947d2b76d68..b19ebadbd868866c6e25e0369de668fd8a8f6566 100644
--- a/third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/WindowAudioWorklet.cpp
@@ -7,43 +7,18 @@
#include "core/dom/Document.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
-#include "modules/webaudio/AudioWorklet.h"
namespace blink {
-WindowAudioWorklet::WindowAudioWorklet(LocalDOMWindow& window)
- : ContextLifecycleObserver(window.frame()->document()) {}
-
-const char* WindowAudioWorklet::supplementName() {
- return "WindowAudioWorklet";
-}
-
-WindowAudioWorklet& WindowAudioWorklet::from(LocalDOMWindow& window) {
- WindowAudioWorklet* supplement = static_cast<WindowAudioWorklet*>(
- Supplement<LocalDOMWindow>::from(window, supplementName()));
- if (!supplement) {
- supplement = new WindowAudioWorklet(window);
- provideTo(window, supplementName(), supplement);
- }
- return *supplement;
-}
-
-Worklet* WindowAudioWorklet::audioWorklet(DOMWindow& window) {
+AudioWorklet* WindowAudioWorklet::audioWorklet(LocalDOMWindow& window) {
if (!window.frame())
return nullptr;
- return from(toLocalDOMWindow(window)).audioWorklet(toLocalDOMWindow(window));
-}
-
-AudioWorklet* WindowAudioWorklet::audioWorklet(LocalDOMWindow& window) {
- if (!m_audioWorklet && getExecutionContext()) {
- DCHECK(window.frame());
- m_audioWorklet = AudioWorklet::create(window.frame());
- }
- return m_audioWorklet.get();
+ return from(window).m_audioWorklet.get();
}
// Break the following cycle when the context gets detached.
// Otherwise, the worklet object will leak.
+// TODO(dcheng): Why isn't this just all on the Oilpan heap?
//
// window => window.audioWorklet
// => WindowAudioWorklet
@@ -61,4 +36,22 @@ DEFINE_TRACE(WindowAudioWorklet) {
ContextLifecycleObserver::trace(visitor);
}
+WindowAudioWorklet& WindowAudioWorklet::from(LocalDOMWindow& window) {
+ WindowAudioWorklet* supplement = static_cast<WindowAudioWorklet*>(
+ Supplement<LocalDOMWindow>::from(window, supplementName()));
+ if (!supplement) {
+ supplement = new WindowAudioWorklet(window);
+ provideTo(window, supplementName(), supplement);
+ }
+ return *supplement;
+}
+
+WindowAudioWorklet::WindowAudioWorklet(LocalDOMWindow& window)
+ : ContextLifecycleObserver(window.frame()->document()),
+ m_audioWorklet(AudioWorklet::create(window.frame())) {}
+
+const char* WindowAudioWorklet::supplementName() {
+ return "WindowAudioWorklet";
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698