Backed out changeset 6a4cf8732cb1 (bug 1308615) for failing browser-chrome tests like browser_devices_get_user_media.js. r=backout on a CLOSED TREE

This commit is contained in:
Sebastian Hengst 2016-10-14 01:17:08 +02:00
Родитель 47dffb47bc
Коммит 83c48072d6
4 изменённых файлов: 25 добавлений и 23 удалений

Просмотреть файл

@ -261,8 +261,8 @@ function forgetPendingListsEventually(aContentWindow) {
} }
function updateIndicators() { function updateIndicators() {
let contentWindowArray = MediaManagerService.activeMediaCaptureWindows; let contentWindowSupportsArray = MediaManagerService.activeMediaCaptureWindows;
let count = contentWindowArray.length; let count = contentWindowSupportsArray.Count();
let state = { let state = {
showGlobalIndicator: count > 0, showGlobalIndicator: count > 0,
@ -280,7 +280,7 @@ function updateIndicators() {
// sending duplicate notifications. // sending duplicate notifications.
let contentWindows = new Set(); let contentWindows = new Set();
for (let i = 0; i < count; ++i) { 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) { for (let contentWindow of contentWindows) {

Просмотреть файл

@ -10,7 +10,6 @@
#include "mozilla/dom/MediaStreamTrack.h" #include "mozilla/dom/MediaStreamTrack.h"
#include "GetUserMediaRequest.h" #include "GetUserMediaRequest.h"
#include "MediaStreamListener.h" #include "MediaStreamListener.h"
#include "nsArray.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsHashPropertyBag.h" #include "nsHashPropertyBag.h"
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
@ -3134,11 +3133,14 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
} }
nsresult nsresult
MediaManager::GetActiveMediaCaptureWindows(nsIArray** aArray) MediaManager::GetActiveMediaCaptureWindows(nsISupportsArray** aArray)
{ {
MOZ_ASSERT(aArray); MOZ_ASSERT(aArray);
nsISupportsArray* array;
nsCOMPtr<nsIMutableArray> array = nsArray::Create(); nsresult rv = NS_NewISupportsArray(&array); // AddRefs
if (NS_FAILED(rv)) {
return rv;
}
for (auto iter = mActiveWindows.Iter(); !iter.Done(); iter.Next()) { for (auto iter = mActiveWindows.Iter(); !iter.Done(); iter.Next()) {
const uint64_t& id = iter.Key(); const uint64_t& id = iter.Key();
@ -3169,11 +3171,11 @@ MediaManager::GetActiveMediaCaptureWindows(nsIArray** aArray)
} }
} }
if (capturing) { if (capturing) {
array->AppendElement(window, /*weak =*/ false); array->AppendElement(window);
} }
} }
array.forget(aArray); *aArray = array;
return NS_OK; return NS_OK;
} }
@ -3332,14 +3334,14 @@ MediaManager::IterateWindowListeners(nsPIDOMWindowInner* aWindow,
void void
MediaManager::StopMediaStreams() MediaManager::StopMediaStreams()
{ {
nsCOMPtr<nsIArray> array; nsCOMPtr<nsISupportsArray> array;
GetActiveMediaCaptureWindows(getter_AddRefs(array)); GetActiveMediaCaptureWindows(getter_AddRefs(array));
uint32_t len; uint32_t len;
array->GetLength(&len); array->Count(&len);
for (uint32_t i = 0; i < len; i++) { for (uint32_t i = 0; i < len; i++) {
nsCOMPtr<nsPIDOMWindowInner> win; nsCOMPtr<nsISupports> window;
array->QueryElementAt(i, NS_GET_IID(nsPIDOMWindowInner), array->GetElementAt(i, getter_AddRefs(window));
getter_AddRefs(win)); nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(window));
if (win) { if (win) {
OnNavigation(win->WindowID()); OnNavigation(win->WindowID());
} }
@ -3351,14 +3353,14 @@ MediaManager::IsActivelyCapturingOrHasAPermission(uint64_t aWindowId)
{ {
// Does page currently have a gUM stream active? // Does page currently have a gUM stream active?
nsCOMPtr<nsIArray> array; nsCOMPtr<nsISupportsArray> array;
GetActiveMediaCaptureWindows(getter_AddRefs(array)); GetActiveMediaCaptureWindows(getter_AddRefs(array));
uint32_t len; uint32_t len;
array->GetLength(&len); array->Count(&len);
for (uint32_t i = 0; i < len; i++) { for (uint32_t i = 0; i < len; i++) {
nsCOMPtr<nsPIDOMWindowInner> win; nsCOMPtr<nsISupports> window;
array->QueryElementAt(i, NS_GET_IID(nsPIDOMWindowInner), array->GetElementAt(i, getter_AddRefs(window));
getter_AddRefs(win)); nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(window));
if (win && win->WindowID() == aWindowId) { if (win && win->WindowID() == aWindowId) {
return true; return true;
} }

Просмотреть файл

@ -4,7 +4,7 @@
#include "nsISupports.idl" #include "nsISupports.idl"
interface nsIArray; interface nsISupportsArray;
interface nsIDOMWindow; interface nsIDOMWindow;
%{C++ %{C++
@ -16,7 +16,7 @@ interface nsIDOMWindow;
interface nsIMediaManagerService : nsISupports interface nsIMediaManagerService : nsISupports
{ {
/* return a array of inner windows that have active captures */ /* 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) */ /* 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, void mediaCaptureWindowState(in nsIDOMWindow aWindow, out boolean aVideo, out boolean aAudio,

Просмотреть файл

@ -58,7 +58,7 @@ var WebrtcUI = {
notify: function() { notify: function() {
let windows = MediaManagerService.activeMediaCaptureWindows; let windows = MediaManagerService.activeMediaCaptureWindows;
let count = windows.length; let count = windows.Count();
let msg = {}; let msg = {};
if (count == 0) { if (count == 0) {
if (this._notificationId) { if (this._notificationId) {
@ -76,7 +76,7 @@ var WebrtcUI = {
let cameraActive = false; let cameraActive = false;
let audioActive = false; let audioActive = false;
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
let win = windows.queryElementAt(i, Ci.nsIDOMWindow); let win = windows.GetElementAt(i);
let hasAudio = {}; let hasAudio = {};
let hasVideo = {}; let hasVideo = {};
MediaManagerService.mediaCaptureWindowState(win, hasVideo, hasAudio); MediaManagerService.mediaCaptureWindowState(win, hasVideo, hasAudio);