Backed out 2 changesets (bug 1308615) for failures in browser_devices_get_user_media.js
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 07 Oct 2016 19:42:01 -0700
changeset 317102 b89630e40c018a02e6e615eefd6abde52b364d94
parent 317101 ef962d8857009eff3a2df14c06e4bc72acb13691
child 317103 61aed24ee7e7d856f0a3bee895dc85b443f69d91
push id20681
push userphilringnalda@gmail.com
push dateSat, 08 Oct 2016 23:57:20 +0000
treeherderfx-team@7a7ba250bb2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1308615
milestone52.0a1
backs out85689c52301c33d2993965f1682cc5099fb2d334
ec8e67234efb742177801b60c146429a2f129703
Backed out 2 changesets (bug 1308615) for failures in browser_devices_get_user_media.js CLOSED TREE Backed out changeset 85689c52301c (bug 1308615) Backed out changeset ec8e67234efb (bug 1308615)
browser/modules/ContentWebRTC.jsm
dom/media/MediaManager.cpp
dom/media/nsIMediaManager.idl
mobile/android/chrome/content/WebrtcUI.js
--- a/browser/modules/ContentWebRTC.jsm
+++ b/browser/modules/ContentWebRTC.jsm
@@ -256,18 +256,18 @@ function forgetPendingListsEventually(aC
     return;
   }
   aContentWindow.pendingGetUserMediaRequests = null;
   aContentWindow.pendingPeerConnectionRequests = null;
   aContentWindow.removeEventListener("unload", ContentWebRTC);
 }
 
 function updateIndicators() {
-  let contentWindowArray = MediaManagerService.activeMediaCaptureWindows;
-  let count = contentWindowArray.length;
+  let contentWindowSupportsArray = MediaManagerService.activeMediaCaptureWindows;
+  let count = contentWindowSupportsArray.Count();
 
   let state = {
     showGlobalIndicator: count > 0,
     showCameraIndicator: false,
     showMicrophoneIndicator: false,
     showScreenSharingIndicator: ""
   };
 
@@ -275,17 +275,17 @@ function updateIndicators() {
                .getService(Ci.nsIMessageSender);
   cpmm.sendAsyncMessage("webrtc:UpdatingIndicators");
 
   // If several iframes in the same page use media streams, it's possible to
   // have the same top level window several times. We use a Set to avoid
   // sending duplicate notifications.
   let contentWindows = new Set();
   for (let i = 0; i < count; ++i) {
-    contentWindows.add(contentWindowArray.queryElementAt(i, Ci.nsISupports).top);
+    contentWindows.add(contentWindowSupportsArray.GetElementAt(i).top);
   }
 
   for (let contentWindow of contentWindows) {
     let tabState = getTabStateForContentWindow(contentWindow);
     if (tabState.camera)
       state.showCameraIndicator = true;
     if (tabState.microphone)
       state.showMicrophoneIndicator = true;
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -5,27 +5,27 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaManager.h"
 
 #include "MediaStreamGraph.h"
 #include "mozilla/dom/MediaStreamTrack.h"
 #include "GetUserMediaRequest.h"
 #include "MediaStreamListener.h"
-#include "nsArray.h"
 #include "nsContentUtils.h"
 #include "nsHashPropertyBag.h"
 #ifdef MOZ_WIDGET_GONK
 #include "nsIAudioManager.h"
 #endif
 #include "nsIEventTarget.h"
 #include "nsIUUIDGenerator.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIPermissionManager.h"
 #include "nsIPopupWindowManager.h"
+#include "nsISupportsArray.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIIDNService.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsPrincipal.h"
@@ -2406,20 +2406,24 @@ if (privileged) {
       }
       if (!(*devices)->Length()) {
         RefPtr<MediaStreamError> error =
             new MediaStreamError(window, NS_LITERAL_STRING("NotFoundError"));
         onFailure->OnError(error);
         return;
       }
 
-      nsCOMPtr<nsIMutableArray> devicesCopy = nsArray::Create(); // before we give up devices below
+      nsCOMPtr<nsISupportsArray> devicesCopy; // before we give up devices below
       if (!askPermission) {
+        nsresult rv = NS_NewISupportsArray(getter_AddRefs(devicesCopy));
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+          return;
+        }
         for (auto& device : **devices) {
-          nsresult rv = devicesCopy->AppendElement(device, /*weak =*/ false);
+          rv = devicesCopy->AppendElement(device);
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return;
           }
         }
       }
 
       // Pass callbacks and MediaStreamListener along to GetUserMediaTask.
       RefPtr<GetUserMediaTask> task (new GetUserMediaTask(c, onSuccess.forget(),
@@ -3027,25 +3031,25 @@ MediaManager::Observe(nsISupports* aSubj
     mActiveCallbacks.Remove(key, getter_AddRefs(task));
     if (!task) {
       return NS_OK;
     }
 
     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));
+      nsCOMPtr<nsISupportsArray> array(do_QueryInterface(aSubject));
       MOZ_ASSERT(array);
       uint32_t len = 0;
-      array->GetLength(&len);
+      array->Count(&len);
       bool videoFound = false, audioFound = false;
       for (uint32_t i = 0; i < len; i++) {
-        nsCOMPtr<nsIMediaDevice> device;
-        array->QueryElementAt(i, NS_GET_IID(nsIMediaDevice),
-                              getter_AddRefs(device));
+        nsCOMPtr<nsISupports> supports;
+        array->GetElementAt(i,getter_AddRefs(supports));
+        nsCOMPtr<nsIMediaDevice> device(do_QueryInterface(supports));
         MOZ_ASSERT(device); // shouldn't be returning anything else...
         if (device) {
           nsString type;
           device->GetType(type);
           if (type.EqualsLiteral("video")) {
             if (!videoFound) {
               task->SetVideoDevice(static_cast<VideoDevice*>(device.get()));
               videoFound = true;
@@ -3129,21 +3133,24 @@ MediaManager::Observe(nsISupports* aSubj
     return NS_OK;
   }
 #endif
 
   return NS_OK;
 }
 
 nsresult
-MediaManager::GetActiveMediaCaptureWindows(nsIArray** aArray)
+MediaManager::GetActiveMediaCaptureWindows(nsISupportsArray** aArray)
 {
   MOZ_ASSERT(aArray);
-
-  nsCOMPtr<nsIMutableArray> array = nsArray::Create();
+  nsISupportsArray* array;
+  nsresult rv = NS_NewISupportsArray(&array); // AddRefs
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
 
   for (auto iter = mActiveWindows.Iter(); !iter.Done(); iter.Next()) {
     const uint64_t& id = iter.Key();
     StreamListeners* listeners = iter.UserData();
 
     nsPIDOMWindowInner* window =
       nsGlobalWindow::GetInnerWindowWithId(id)->AsInner();
     MOZ_ASSERT(window);
@@ -3164,21 +3171,21 @@ MediaManager::GetActiveMediaCaptureWindo
             listener->CapturingScreen() || listener->CapturingWindow() ||
             listener->CapturingApplication()) {
           capturing = true;
           break;
         }
       }
     }
     if (capturing) {
-      array->AppendElement(window, /*weak =*/ false);
+      array->AppendElement(window);
     }
   }
 
-  array.forget(aArray);
+  *aArray = array;
   return NS_OK;
 }
 
 // XXX flags might be better...
 struct CaptureWindowStateData {
   bool *mVideo;
   bool *mAudio;
   bool *mScreenShare;
@@ -3327,43 +3334,43 @@ MediaManager::IterateWindowListeners(nsP
     }
   }
 }
 
 
 void
 MediaManager::StopMediaStreams()
 {
-  nsCOMPtr<nsIArray> array;
+  nsCOMPtr<nsISupportsArray> array;
   GetActiveMediaCaptureWindows(getter_AddRefs(array));
   uint32_t len;
-  array->GetLength(&len);
+  array->Count(&len);
   for (uint32_t i = 0; i < len; i++) {
-    nsCOMPtr<nsPIDOMWindowInner> win;
-    array->QueryElementAt(i, NS_GET_IID(nsPIDOMWindowInner),
-                          getter_AddRefs(win));
+    nsCOMPtr<nsISupports> window;
+    array->GetElementAt(i, getter_AddRefs(window));
+    nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(window));
     if (win) {
       OnNavigation(win->WindowID());
     }
   }
 }
 
 bool
 MediaManager::IsActivelyCapturingOrHasAPermission(uint64_t aWindowId)
 {
   // Does page currently have a gUM stream active?
 
-  nsCOMPtr<nsIArray> array;
+  nsCOMPtr<nsISupportsArray> array;
   GetActiveMediaCaptureWindows(getter_AddRefs(array));
   uint32_t len;
-  array->GetLength(&len);
+  array->Count(&len);
   for (uint32_t i = 0; i < len; i++) {
-    nsCOMPtr<nsPIDOMWindowInner> win;
-    array->QueryElementAt(i, NS_GET_IID(nsPIDOMWindowInner),
-                          getter_AddRefs(win));
+    nsCOMPtr<nsISupports> window;
+    array->GetElementAt(i, getter_AddRefs(window));
+    nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(window));
     if (win && win->WindowID() == aWindowId) {
       return true;
     }
   }
 
   // Or are persistent permissions (audio or video) granted?
 
   auto* window = nsGlobalWindow::GetInnerWindowWithId(aWindowId);
--- a/dom/media/nsIMediaManager.idl
+++ b/dom/media/nsIMediaManager.idl
@@ -1,27 +1,27 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsIArray;
+interface nsISupportsArray;
 interface nsIDOMWindow;
 
 %{C++
 #define NS_MEDIAMANAGERSERVICE_CID {0xabc622ea, 0x9655, 0x4123, {0x80, 0xd9, 0x22, 0x62, 0x1b, 0xdd, 0x54, 0x65}}
 #define MEDIAMANAGERSERVICE_CONTRACTID "@mozilla.org/mediaManagerService;1"
 %}
 
 [scriptable, builtinclass, uuid(24b23e01-33fd-401f-ba25-6e52658750b0)]
 interface nsIMediaManagerService : nsISupports
 {
   /* return a array of inner windows that have active captures */
-  readonly attribute nsIArray activeMediaCaptureWindows;
+  readonly attribute nsISupportsArray activeMediaCaptureWindows;
 
   /* Get the capture state for the given window and all descendant windows (iframes, etc) */
   void mediaCaptureWindowState(in nsIDOMWindow aWindow, out boolean aVideo, out boolean aAudio,
                                [optional] out boolean aScreenShare, [optional] out boolean aWindowShare,
                                [optional] out boolean aAppShare, [optional] out boolean aBrowserShare);
 
   /* Clear per-orgin list of persistent DeviceIds stored for enumerateDevices
      sinceTime is milliseconds since 1 January 1970 00:00:00 UTC. 0 = clear all */
--- a/mobile/android/chrome/content/WebrtcUI.js
+++ b/mobile/android/chrome/content/WebrtcUI.js
@@ -53,17 +53,17 @@ var WebrtcUI = {
       }
     } else if (aTopic === "VideoCapture:Resumed") {
       this.notify();
     }
   },
 
   notify: function() {
     let windows = MediaManagerService.activeMediaCaptureWindows;
-    let count = windows.length;
+    let count = windows.Count();
     let msg = {};
     if (count == 0) {
       if (this._notificationId) {
         Notifications.cancel(this._notificationId);
         this._notificationId = null;
       }
     } else {
       let notificationOptions = {
@@ -71,17 +71,17 @@ var WebrtcUI = {
         when: null, // hide the date row
         light: [0xFF9500FF, 1000, 1000],
         ongoing: true
       };
 
       let cameraActive = false;
       let audioActive = false;
       for (let i = 0; i < count; i++) {
-        let win = windows.queryElementAt(i, Ci.nsIDOMWindow);
+        let win = windows.GetElementAt(i);
         let hasAudio = {};
         let hasVideo = {};
         MediaManagerService.mediaCaptureWindowState(win, hasVideo, hasAudio);
         if (hasVideo.value) cameraActive = true;
         if (hasAudio.value) audioActive = true;
       }
 
       if (cameraActive && audioActive) {