Bug 1363261 - Remove a callId from mCallIds when the corresponding GetUserMediaTask is removed from mActiveCallbacks. r=jib
authorMunro Mengjue Chiang <mchiang@mozilla.com>
Mon, 24 Apr 2017 15:11:51 +0800
changeset 357345 f1f27357f20825726229712eeea15d6d629ecabd
parent 357344 6baa8102c70d55ad18c93728f270663ad6513d77
child 357346 751a52708ddfdeb6363fa6b6faefc4e3a5f43ac1
push id31789
push userkwierso@gmail.com
push dateTue, 09 May 2017 21:36:07 +0000
treeherdermozilla-central@120d8562d4a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1363261
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1363261 - Remove a callId from mCallIds when the corresponding GetUserMediaTask is removed from mActiveCallbacks. r=jib MozReview-Commit-ID: DcSQ8O9MoCb
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1615,16 +1615,22 @@ public:
   nsresult
   SetVideoDevice(VideoDevice* aVideoDevice)
   {
     mVideoDevice = aVideoDevice;
     mDeviceChosen = true;
     return NS_OK;
   }
 
+  uint64_t
+  GetWindowID()
+  {
+    return mWindowID;
+  }
+
 private:
   MediaStreamConstraints mConstraints;
 
   nsCOMPtr<nsIDOMGetUserMediaSuccessCallback> mOnSuccess;
   nsCOMPtr<nsIDOMGetUserMediaErrorCallback> mOnFailure;
   uint64_t mWindowID;
   RefPtr<GetUserMediaWindowListener> mWindowListener;
   RefPtr<SourceListener> mSourceListener;
@@ -3005,16 +3011,22 @@ MediaManager::Observe(nsISupports* aSubj
              !strcmp(aTopic, "getUserMedia:response:allow")) {
     nsString key(aData);
     RefPtr<GetUserMediaTask> task;
     mActiveCallbacks.Remove(key, getter_AddRefs(task));
     if (!task) {
       return NS_OK;
     }
 
+    nsTArray<nsString>* array;
+    if (!mCallIds.Get(task->GetWindowID(), &array)) {
+      return NS_OK;
+    }
+    array->RemoveElement(key);
+
     if (aSubject) {
       // A particular device or devices were chosen by the user.
       // NOTE: does not allow setting a device to null; assumes nullptr
       nsCOMPtr<nsIArray> array(do_QueryInterface(aSubject));
       MOZ_ASSERT(array);
       uint32_t len = 0;
       array->GetLength(&len);
       bool videoFound = false, audioFound = false;
@@ -3069,16 +3081,21 @@ MediaManager::Observe(nsISupports* aSubj
         errorMessage.AssignLiteral(u"InternalError");
     }
 
     nsString key(aData);
     RefPtr<GetUserMediaTask> task;
     mActiveCallbacks.Remove(key, getter_AddRefs(task));
     if (task) {
       task->Denied(errorMessage);
+      nsTArray<nsString>* array;
+      if (!mCallIds.Get(task->GetWindowID(), &array)) {
+        return NS_OK;
+      }
+      array->RemoveElement(key);
     }
     return NS_OK;
 
   } else if (!strcmp(aTopic, "getUserMedia:revoke")) {
     nsresult rv;
     // may be windowid or screen:windowid
     nsDependentString data(aData);
     if (Substring(data, 0, strlen("screen:")).EqualsLiteral("screen:")) {