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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2151243002: Using wrapWeakPersistent for VisibilityCallback in HTMLMediaElement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: prepare to land Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index d1df73ea7a01981c75a55126bda93136a0de210c..cfaf41dcb7afde74517f1a51494277f26884e2db 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -1638,7 +1638,7 @@ void HTMLMediaElement::setReadyState(ReadyState state)
// observer didn't had time to fire yet. We can avoid
// creating a new one in this case.
if (!m_autoplayVisibilityObserver) {
- m_autoplayVisibilityObserver = new ElementVisibilityObserver(this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapPersistent(this)));
+ m_autoplayVisibilityObserver = new ElementVisibilityObserver(this, WTF::bind(&HTMLMediaElement::onVisibilityChangedForAutoplay, wrapWeakPersistent(this)));
m_autoplayVisibilityObserver->start();
}
} else {
@@ -3923,6 +3923,9 @@ void HTMLMediaElement::onVisibilityChangedForAutoplay(bool isVisible)
updatePlayState();
}
+ // TODO(zqzhang): There's still flaky leak if onVisibilityChangedForAutoplay() is never called.
+ // The leak comes from either ElementVisibilityObserver or IntersectionObserver. Should keep an eye on it.
+ // See https://crbug.com/627539
m_autoplayVisibilityObserver->stop();
m_autoplayVisibilityObserver = nullptr;
}
« 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