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

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaControlsOrientationLockDelegate.cpp

Issue 2725873002: Media: fix memory leak because of the document holding on an EventListener. (Closed)
Patch Set: event-based Created 3 years, 10 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/core/html/shadow/MediaControlsOrientationLockDelegate.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlsOrientationLockDelegate.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlsOrientationLockDelegate.cpp
index 624bb9d699665c15f24c9a04de2425fe35b4b8a1..f29c4c5e96961e78a9d3f10d87f856742bdb2348 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlsOrientationLockDelegate.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsOrientationLockDelegate.cpp
@@ -64,12 +64,25 @@ class DummyScreenOrientationCallback : public WebLockOrientationCallback {
MediaControlsOrientationLockDelegate::MediaControlsOrientationLockDelegate(
HTMLVideoElement& video)
: EventListener(CPPEventListenerType), m_videoElement(video) {
+ if (videoElement().isConnected())
+ attach();
+}
+
+void MediaControlsOrientationLockDelegate::attach() {
document().addEventListener(EventTypeNames::fullscreenchange, this, true);
videoElement().addEventListener(EventTypeNames::webkitfullscreenchange, this,
true);
videoElement().addEventListener(EventTypeNames::loadedmetadata, this, true);
}
+void MediaControlsOrientationLockDelegate::detach() {
+ document().removeEventListener(EventTypeNames::fullscreenchange, this, true);
+ videoElement().removeEventListener(EventTypeNames::webkitfullscreenchange,
+ this, true);
+ videoElement().removeEventListener(EventTypeNames::loadedmetadata, this,
+ true);
+}
+
bool MediaControlsOrientationLockDelegate::operator==(
const EventListener& other) const {
return this == &other;

Powered by Google App Engine
This is Rietveld 408576698