Bug 1140363 - Fire recording-window-ended on gUM failures, like we do on deny. r=jesup, a=lsblakk
authorJan-Ivar Bruaroey <jib@mozilla.com>
Fri, 06 Mar 2015 13:23:33 -0500
changeset 250350 0cd4e38e00b1
parent 250349 14cc1f92c84c
child 250351 7e93dd7c7feb
push id4555
push userryanvm@gmail.com
push date2015-03-11 19:14 +0000
treeherdermozilla-beta@7949e470a547 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, lsblakk
bugs1140363
milestone37.0
Bug 1140363 - Fire recording-window-ended on gUM failures, like we do on deny. r=jesup, a=lsblakk
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1120,16 +1120,18 @@ public:
     nsRefPtr<MediaMgrError> error = new MediaMgrError(aName, aMessage);
     nsRefPtr<ErrorCallbackRunnable> runnable =
       new ErrorCallbackRunnable(mOnSuccess, mOnFailure, *error, mWindowID);
     // These should be empty now
     MOZ_ASSERT(!mOnSuccess);
     MOZ_ASSERT(!mOnFailure);
 
     NS_DispatchToMainThread(runnable);
+    // Do after ErrorCallbackRunnable Run()s, as it checks active window list
+    NS_DispatchToMainThread(new GetUserMediaListenerRemove(mWindowID, mListener));
   }
 
   void
   Run()
   {
     NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
     MOZ_ASSERT(mOnSuccess);
     MOZ_ASSERT(mOnFailure);
@@ -1176,21 +1178,18 @@ public:
                                                                 aName, aMessage);
         onFailure->OnError(error);
       }
       // Should happen *after* error runs for consistency, but may not matter
       nsRefPtr<MediaManager> manager(MediaManager::GetInstance());
       manager->RemoveFromWindowList(mWindowID, mListener);
     } else {
       // This will re-check the window being alive on main-thread
-      // Note: we must remove the listener on MainThread as well
+      // and remove the listener on MainThread as well
       Fail(aName, aMessage);
-
-      // MUST happen after ErrorCallbackRunnable Run()s, as it checks the active window list
-      NS_DispatchToMainThread(new GetUserMediaListenerRemove(mWindowID, mListener));
     }
 
     MOZ_ASSERT(!mOnSuccess);
     MOZ_ASSERT(!mOnFailure);
 
     return NS_OK;
   }