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

Unified Diff: third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp

Issue 2571753002: WindowAnimationWorklet should use ContextLifecycleObserver instead of DOMWindowProperty (Closed)
Patch Set: temp 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/compositorworker/WindowAnimationWorklet.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/compositorworker/WindowAnimationWorklet.cpp
diff --git a/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp b/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp
index 3512051bf191613a1f4e16497cccfa9af04b78cf..15a4803470a2130d95c6714f60942b265463d471 100644
--- a/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp
+++ b/third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.cpp
@@ -4,6 +4,7 @@
#include "modules/compositorworker/WindowAnimationWorklet.h"
+#include "core/dom/Document.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "modules/compositorworker/AnimationWorklet.h"
@@ -11,7 +12,7 @@
namespace blink {
WindowAnimationWorklet::WindowAnimationWorklet(LocalDOMWindow& window)
- : DOMWindowProperty(window.frame()) {}
+ : ContextLifecycleObserver(window.frame()->document()) {}
const char* WindowAnimationWorklet::supplementName() {
return "WindowAnimationWorklet";
@@ -30,24 +31,36 @@ WindowAnimationWorklet& WindowAnimationWorklet::from(LocalDOMWindow& window) {
// static
Worklet* WindowAnimationWorklet::animationWorklet(DOMWindow& window) {
- return from(toLocalDOMWindow(window)).animationWorklet();
+ return from(toLocalDOMWindow(window))
+ .animationWorklet(toLocalDOMWindow(window));
}
-AnimationWorklet* WindowAnimationWorklet::animationWorklet() {
- if (!m_animationWorklet && frame())
- m_animationWorklet = AnimationWorklet::create(frame());
+AnimationWorklet* WindowAnimationWorklet::animationWorklet(
+ LocalDOMWindow& window) {
+ if (!m_animationWorklet && getExecutionContext()) {
+ DCHECK(window.frame());
+ m_animationWorklet = AnimationWorklet::create(window.frame());
+ }
return m_animationWorklet.get();
}
-void WindowAnimationWorklet::frameDestroyed() {
- m_animationWorklet.clear();
- DOMWindowProperty::frameDestroyed();
+// Break the following cycle when the context gets detached.
+// Otherwise, the worklet object will leak.
+//
+// window => window.animationWorklet
+// => WindowAnimationWorklet
+// => AnimationWorklet <--- break this reference
+// => ThreadedWorkletMessagingProxy
+// => Document
+// => ... => window
+void WindowAnimationWorklet::contextDestroyed() {
+ m_animationWorklet = nullptr;
}
DEFINE_TRACE(WindowAnimationWorklet) {
visitor->trace(m_animationWorklet);
Supplement<LocalDOMWindow>::trace(visitor);
- DOMWindowProperty::trace(visitor);
+ ContextLifecycleObserver::trace(visitor);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/compositorworker/WindowAnimationWorklet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698