Bug 1419363 - Switch to WeakPtr. r=jib a=gchang
authorAndreas Pehrson <pehrsons@mozilla.com>
Fri, 01 Dec 2017 10:52:18 -0500
changeset 442693 244cb01f9036
parent 442692 aded8e18768e
child 442694 3da0dff84972
push id8301
push userarchaeopteryx@coole-files.de
push dateMon, 04 Dec 2017 14:09:26 +0000
treeherdermozilla-beta@3da0dff84972 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, gchang
bugs1419363
milestone58.0
Bug 1419363 - Switch to WeakPtr. r=jib a=gchang
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5163,21 +5163,24 @@ class HTMLMediaElement::MediaStreamTrack
 public:
   explicit MediaStreamTracksAvailableCallback(HTMLMediaElement* aElement):
       OnTracksAvailableCallback(), mElement(aElement)
     {}
   virtual void NotifyTracksAvailable(DOMMediaStream* aStream)
   {
     NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 
+    if (!mElement) {
+      return;
+    }
     mElement->NotifyMediaStreamTracksAvailable(aStream);
   }
 
 private:
-  HTMLMediaElement* mElement;
+  WeakPtr<HTMLMediaElement> mElement;
 };
 
 class HTMLMediaElement::MediaStreamTrackListener :
   public DOMMediaStream::TrackListener
 {
 public:
   explicit MediaStreamTrackListener(HTMLMediaElement* aElement):
       mElement(aElement) {}