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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2725873002: Media: fix memory leak because of the document holding on an EventListener. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h " 93 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h "
94 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" 94 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h"
95 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" 95 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h"
96 #include "wtf/AutoReset.h" 96 #include "wtf/AutoReset.h"
97 #include "wtf/CurrentTime.h" 97 #include "wtf/CurrentTime.h"
98 #include "wtf/MathExtras.h" 98 #include "wtf/MathExtras.h"
99 #include "wtf/PtrUtil.h" 99 #include "wtf/PtrUtil.h"
100 #include "wtf/text/CString.h" 100 #include "wtf/text/CString.h"
101 101
102 #ifndef BLINK_MEDIA_LOG 102 #ifndef BLINK_MEDIA_LOG
103 #define BLINK_MEDIA_LOG DVLOG(3) 103 #define BLINK_MEDIA_LOG LOG(INFO)
104 #endif 104 #endif
105 105
106 #ifndef LOG_MEDIA_EVENTS 106 #ifndef LOG_MEDIA_EVENTS
107 // Default to not logging events because so many are generated they can 107 // Default to not logging events because so many are generated they can
108 // overwhelm the rest of the logging. 108 // overwhelm the rest of the logging.
109 #define LOG_MEDIA_EVENTS 0 109 #define LOG_MEDIA_EVENTS 0
110 #endif 110 #endif
111 111
112 #ifndef LOG_OFFICIAL_TIME_STATUS 112 #ifndef LOG_OFFICIAL_TIME_STATUS
113 // Default to not logging status of official time because it adds a fair amount 113 // Default to not logging status of official time because it adds a fair amount
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // m_audioSourceNode is explicitly cleared by AudioNode::dispose(). 489 // m_audioSourceNode is explicitly cleared by AudioNode::dispose().
490 // Since AudioNode::dispose() is guaranteed to be always called before 490 // Since AudioNode::dispose() is guaranteed to be always called before
491 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared 491 // the AudioNode is destructed, m_audioSourceNode is explicitly cleared
492 // even if the AudioNode and the HTMLMediaElement die together. 492 // even if the AudioNode and the HTMLMediaElement die together.
493 DCHECK(!m_audioSourceNode); 493 DCHECK(!m_audioSourceNode);
494 } 494 }
495 495
496 void HTMLMediaElement::dispose() { 496 void HTMLMediaElement::dispose() {
497 closeMediaSource(); 497 closeMediaSource();
498 498
499 LOG(INFO) << "HTMLMediaElement::dispose";
500
499 // Destroying the player may cause a resource load to be canceled, 501 // Destroying the player may cause a resource load to be canceled,
500 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being 502 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being
501 // called via ResourceFetch::didLoadResource(), then 503 // called via ResourceFetch::didLoadResource(), then
502 // FrameLoader::checkCompleted(). But it's guaranteed that the load event 504 // FrameLoader::checkCompleted(). But it's guaranteed that the load event
503 // doesn't get dispatched during the object destruction. 505 // doesn't get dispatched during the object destruction.
504 // See Document::isDelayingLoadEvent(). 506 // See Document::isDelayingLoadEvent().
505 // Also see http://crbug.com/275223 for more details. 507 // Also see http://crbug.com/275223 for more details.
506 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); 508 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking();
507 } 509 }
508 510
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 m_networkState == kNetworkEmpty) { 649 m_networkState == kNetworkEmpty) {
648 m_ignorePreloadNone = false; 650 m_ignorePreloadNone = false;
649 invokeLoadAlgorithm(); 651 invokeLoadAlgorithm();
650 } 652 }
651 } 653 }
652 654
653 return InsertionShouldCallDidNotifySubtreeInsertions; 655 return InsertionShouldCallDidNotifySubtreeInsertions;
654 } 656 }
655 657
656 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() { 658 void HTMLMediaElement::didNotifySubtreeInsertionsToDocument() {
659 BLINK_MEDIA_LOG << "didNotifySubtreeInsertionsToDocument()";
657 updateControlsVisibility(); 660 updateControlsVisibility();
658 } 661 }
659 662
660 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) { 663 void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint) {
661 BLINK_MEDIA_LOG << "removedFrom(" << (void*)this << ", " << insertionPoint 664 BLINK_MEDIA_LOG << "removedFrom(" << (void*)this << ", " << insertionPoint
662 << ")"; 665 << ")";
663 666
664 HTMLElement::removedFrom(insertionPoint); 667 HTMLElement::removedFrom(insertionPoint);
665 if (insertionPoint->inActiveDocument()) { 668 if (insertionPoint->inActiveDocument()) {
666 updateControlsVisibility(); 669 updateControlsVisibility();
670 m_mediaControls->detach();
671 m_mediaControls = nullptr;
667 if (m_networkState > kNetworkEmpty) 672 if (m_networkState > kNetworkEmpty)
668 pauseInternal(); 673 pauseInternal();
669 } 674 }
670 } 675 }
671 676
672 void HTMLMediaElement::attachLayoutTree(const AttachContext& context) { 677 void HTMLMediaElement::attachLayoutTree(const AttachContext& context) {
673 HTMLElement::attachLayoutTree(context); 678 HTMLElement::attachLayoutTree(context);
674 679
675 if (layoutObject()) 680 if (layoutObject())
676 layoutObject()->updateFromElement(); 681 layoutObject()->updateFromElement();
(...skipping 3120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3797 void HTMLMediaElement::mediaSourceOpened(WebMediaSource* webMediaSource) { 3802 void HTMLMediaElement::mediaSourceOpened(WebMediaSource* webMediaSource) {
3798 setShouldDelayLoadEvent(false); 3803 setShouldDelayLoadEvent(false);
3799 m_mediaSource->setWebMediaSourceAndOpen(WTF::wrapUnique(webMediaSource)); 3804 m_mediaSource->setWebMediaSourceAndOpen(WTF::wrapUnique(webMediaSource));
3800 } 3805 }
3801 3806
3802 bool HTMLMediaElement::isInteractiveContent() const { 3807 bool HTMLMediaElement::isInteractiveContent() const {
3803 return fastHasAttribute(controlsAttr); 3808 return fastHasAttribute(controlsAttr);
3804 } 3809 }
3805 3810
3806 DEFINE_TRACE(HTMLMediaElement) { 3811 DEFINE_TRACE(HTMLMediaElement) {
3812 LOG(INFO) << "HTMLMediaElement::trace";
3807 visitor->trace(m_playedTimeRanges); 3813 visitor->trace(m_playedTimeRanges);
3808 visitor->trace(m_asyncEventQueue); 3814 visitor->trace(m_asyncEventQueue);
3809 visitor->trace(m_error); 3815 visitor->trace(m_error);
3810 visitor->trace(m_currentSourceNode); 3816 visitor->trace(m_currentSourceNode);
3811 visitor->trace(m_nextChildNodeToConsider); 3817 visitor->trace(m_nextChildNodeToConsider);
3812 visitor->trace(m_mediaSource); 3818 visitor->trace(m_mediaSource);
3813 visitor->trace(m_audioTracks); 3819 visitor->trace(m_audioTracks);
3814 visitor->trace(m_videoTracks); 3820 visitor->trace(m_videoTracks);
3815 visitor->trace(m_cueTimeline); 3821 visitor->trace(m_cueTimeline);
3816 visitor->trace(m_textTracks); 3822 visitor->trace(m_textTracks);
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
4175 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE); 4181 kMostlyFillViewportBecomeStableSeconds, BLINK_FROM_HERE);
4176 } 4182 }
4177 4183
4178 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) { 4184 void HTMLMediaElement::viewportFillDebouncerTimerFired(TimerBase*) {
4179 m_mostlyFillingViewport = true; 4185 m_mostlyFillingViewport = true;
4180 if (m_webMediaPlayer) 4186 if (m_webMediaPlayer)
4181 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport); 4187 m_webMediaPlayer->becameDominantVisibleContent(m_mostlyFillingViewport);
4182 } 4188 }
4183 4189
4184 } // namespace blink 4190 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698