Bug 1419363 - Switch to WeakPtr. r=jib a=gchang
authorAndreas Pehrson <pehrsons@mozilla.com>
Fri, 01 Dec 2017 10:52:18 -0500
changeset 356637 0712b6cbbdc87936cee0f15e2142084926eabe69
parent 356636 5e7b162131985dbcb0c34c1afc0c4b1ae14eca66
child 356638 084c427ccf990d185117decb4c52003932eb8b94
push id7448
push userryanvm@gmail.com
push dateTue, 19 Dec 2017 14:40:03 +0000
treeherdermozilla-esr52@0712b6cbbdc8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, gchang
bugs1419363
milestone52.5.3
Bug 1419363 - Switch to WeakPtr. r=jib a=gchang
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4155,21 +4155,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) {}