зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1308615 - Part 2: Stop using nsISupportsArray for observer messages. r=jesup
This removes the rest of the usage of nsISupportsArray in MediaManager. MozReview-Commit-ID: EqXTRNyKiva
This commit is contained in:
Родитель
b9acba878d
Коммит
e4b0439502
|
@ -73,10 +73,10 @@ this.ContentWebRTC = {
|
|||
let devices = contentWindow.pendingGetUserMediaRequests.get(callID);
|
||||
forgetGUMRequest(contentWindow, callID);
|
||||
|
||||
let allowedDevices = Cc["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Ci.nsISupportsArray);
|
||||
let allowedDevices = Cc["@mozilla.org/array;1"]
|
||||
.createInstance(Ci.nsIMutableArray);
|
||||
for (let deviceIndex of aMessage.data.devices)
|
||||
allowedDevices.AppendElement(devices[deviceIndex]);
|
||||
allowedDevices.appendElement(devices[deviceIndex], /*weak =*/ false);
|
||||
|
||||
Services.obs.notifyObservers(allowedDevices, "getUserMedia:response:allow", callID);
|
||||
break;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIPopupWindowManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -2407,14 +2406,10 @@ if (privileged) {
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> devicesCopy; // before we give up devices below
|
||||
nsCOMPtr<nsIMutableArray> devicesCopy = nsArray::Create(); // 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) {
|
||||
rv = devicesCopy->AppendElement(device);
|
||||
nsresult rv = devicesCopy->AppendElement(device, /*weak =*/ false);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
@ -3032,15 +3027,15 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
if (aSubject) {
|
||||
// A particular device or devices were chosen by the user.
|
||||
// NOTE: does not allow setting a device to null; assumes nullptr
|
||||
nsCOMPtr<nsISupportsArray> array(do_QueryInterface(aSubject));
|
||||
nsCOMPtr<nsIArray> array(do_QueryInterface(aSubject));
|
||||
MOZ_ASSERT(array);
|
||||
uint32_t len = 0;
|
||||
array->Count(&len);
|
||||
array->GetLength(&len);
|
||||
bool videoFound = false, audioFound = false;
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
array->GetElementAt(i,getter_AddRefs(supports));
|
||||
nsCOMPtr<nsIMediaDevice> device(do_QueryInterface(supports));
|
||||
nsCOMPtr<nsIMediaDevice> device;
|
||||
array->QueryElementAt(i, NS_GET_IID(nsIMediaDevice),
|
||||
getter_AddRefs(device));
|
||||
MOZ_ASSERT(device); // shouldn't be returning anything else...
|
||||
if (device) {
|
||||
nsString type;
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
#include "MediaManager.h"
|
||||
#include "MediaPermissionGonk.h"
|
||||
|
||||
#include "nsArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContentPermissionPrompt.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMNavigatorUserMedia.h"
|
||||
#include "nsIStringEnumerator.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -67,12 +67,10 @@ static nsresult
|
|||
NotifyPermissionAllow(const nsAString &aCallID, nsTArray<nsCOMPtr<nsIMediaDevice> > &aDevices)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(array));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIMutableArray> array = nsArray::Create();
|
||||
|
||||
for (uint32_t i = 0; i < aDevices.Length(); ++i) {
|
||||
rv = array->AppendElement(aDevices.ElementAt(i));
|
||||
rv = array->AppendElement(aDevices.ElementAt(i), /*weak =*/ false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,19 +150,19 @@ var WebrtcUI = {
|
|||
{
|
||||
label: Strings.browser.GetStringFromName("getUserMedia.shareRequest.label"),
|
||||
callback: function(checked /* ignored */, inputs) {
|
||||
let allowedDevices = Cc["@mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray);
|
||||
let allowedDevices = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
||||
|
||||
let audioId = 0;
|
||||
if (inputs && inputs.audioDevice != undefined)
|
||||
audioId = inputs.audioDevice;
|
||||
if (audioDevices[audioId])
|
||||
allowedDevices.AppendElement(audioDevices[audioId]);
|
||||
allowedDevices.appendElement(audioDevices[audioId], /*weak =*/ false);
|
||||
|
||||
let videoId = 0;
|
||||
if (inputs && inputs.videoSource != undefined)
|
||||
videoId = inputs.videoSource;
|
||||
if (videoDevices[videoId]) {
|
||||
allowedDevices.AppendElement(videoDevices[videoId]);
|
||||
allowedDevices.appendElement(videoDevices[videoId], /*weak =*/ false);
|
||||
let perms = Services.perms;
|
||||
// Although the lifetime is "session" it will be removed upon
|
||||
// use so it's more of a one-shot.
|
||||
|
|
Загрузка…
Ссылка в новой задаче