Bug 1299390 - part 2: Remove AudioChannelService methods required by BrowserElementAudioChannel only. r=alwu,baku

Changes:
- remove nsIAudioChannelService methods
- remove method AudioChannelService::RefreshAgentsVolumeAndPropagate and IPC method AudioChannelChangeNotification
- remove workaround for bug 1183033

MozReview-Commit-ID: BqlXYVhgrat

--HG--
extra : rebase_source : 64905901d645aea801b93e742472ac67ff7fb49e
This commit is contained in:
btian 2017-05-18 09:31:00 +08:00
Родитель a3d3d85da1
Коммит eb73e59657
12 изменённых файлов: 3 добавлений и 397 удалений

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

@ -330,8 +330,7 @@ AudioChannelService::IsEnableAudioCompeting()
}
NS_INTERFACE_MAP_BEGIN(AudioChannelService)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAudioChannelService)
NS_INTERFACE_MAP_ENTRY(nsIAudioChannelService)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_END
@ -666,32 +665,6 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
void
AudioChannelService::RefreshAgentsVolumeAndPropagate(AudioChannel aAudioChannel,
nsPIDOMWindowOuter* aWindow)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
nsCOMPtr<nsPIDOMWindowOuter> topWindow = aWindow->GetScriptableTop();
if (!topWindow) {
return;
}
AudioChannelWindow* winData = GetWindowData(topWindow->WindowID());
if (!winData) {
return;
}
for (uint32_t i = 0; i < mTabParents.Length(); ++i) {
mTabParents[i]->AudioChannelChangeNotification(aWindow, aAudioChannel,
winData->mChannels[(uint32_t)aAudioChannel].mVolume,
winData->mChannels[(uint32_t)aAudioChannel].mMuted);
}
RefreshAgentsVolume(aWindow);
}
void
AudioChannelService::RefreshAgents(nsPIDOMWindowOuter* aWindow,
const std::function<void(AudioChannelAgent*)>& aFunc)
@ -869,162 +842,6 @@ AudioChannelService::GetWindowData(uint64_t aWindowID) const
return nullptr;
}
float
AudioChannelService::GetAudioChannelVolume(nsPIDOMWindowOuter* aWindow,
AudioChannel aAudioChannel)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
return winData->mChannels[(uint32_t)aAudioChannel].mVolume;
}
NS_IMETHODIMP
AudioChannelService::GetAudioChannelVolume(mozIDOMWindowProxy* aWindow,
unsigned short aAudioChannel,
float* aVolume)
{
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
*aVolume = 0.f;
return NS_ERROR_FAILURE;
}
*aVolume = GetAudioChannelVolume(window, (AudioChannel)aAudioChannel);
return NS_OK;
}
void
AudioChannelService::SetAudioChannelVolume(nsPIDOMWindowOuter* aWindow,
AudioChannel aAudioChannel,
float aVolume)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelService, SetAudioChannelVolume, window = %p, type = %" PRIu32 ", "
"volume = %f\n", aWindow, static_cast<uint32_t>(aAudioChannel), aVolume));
AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
winData->mChannels[(uint32_t)aAudioChannel].mVolume = aVolume;
RefreshAgentsVolumeAndPropagate(aAudioChannel, aWindow);
}
NS_IMETHODIMP
AudioChannelService::SetAudioChannelVolume(mozIDOMWindowProxy* aWindow,
unsigned short aAudioChannel,
float aVolume)
{
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
return NS_ERROR_FAILURE;
}
SetAudioChannelVolume(window, (AudioChannel)aAudioChannel, aVolume);
return NS_OK;
}
bool
AudioChannelService::GetAudioChannelMuted(nsPIDOMWindowOuter* aWindow,
AudioChannel aAudioChannel)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
return winData->mChannels[(uint32_t)aAudioChannel].mMuted;
}
NS_IMETHODIMP
AudioChannelService::GetAudioChannelMuted(mozIDOMWindowProxy* aWindow,
unsigned short aAudioChannel,
bool* aMuted)
{
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
*aMuted = false;
return NS_ERROR_FAILURE;
}
*aMuted = GetAudioChannelMuted(window, (AudioChannel)aAudioChannel);
return NS_OK;
}
void
AudioChannelService::SetAudioChannelMuted(nsPIDOMWindowOuter* aWindow,
AudioChannel aAudioChannel,
bool aMuted)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelService, SetAudioChannelMuted, window = %p, type = %" PRIu32 ", "
"mute = %s\n", aWindow, static_cast<uint32_t>(aAudioChannel),
aMuted ? "true" : "false"));
if (aAudioChannel == AudioChannel::System) {
// Workaround for bug1183033, system channel type can always playback.
return;
}
AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
winData->mChannels[(uint32_t)aAudioChannel].mMuted = aMuted;
RefreshAgentsVolumeAndPropagate(aAudioChannel, aWindow);
}
NS_IMETHODIMP
AudioChannelService::SetAudioChannelMuted(mozIDOMWindowProxy* aWindow,
unsigned short aAudioChannel,
bool aMuted)
{
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
return NS_ERROR_FAILURE;
}
SetAudioChannelMuted(window, (AudioChannel)aAudioChannel, aMuted);
return NS_OK;
}
bool
AudioChannelService::IsAudioChannelActive(nsPIDOMWindowOuter* aWindow,
AudioChannel aAudioChannel)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
AudioChannelWindow* winData = GetOrCreateWindowData(aWindow);
return !!winData->mChannels[(uint32_t)aAudioChannel].mNumberOfAgents;
}
NS_IMETHODIMP
AudioChannelService::IsAudioChannelActive(mozIDOMWindowProxy* aWindow,
unsigned short aAudioChannel,
bool* aActive)
{
MOZ_ASSERT(NS_IsMainThread());
auto* window = nsPIDOMWindowOuter::From(aWindow)->GetScriptableTop();
if (!window) {
*aActive = false;
return NS_ERROR_FAILURE;
}
*aActive = IsAudioChannelActive(window, (AudioChannel)aAudioChannel);
return NS_OK;
}
bool
AudioChannelService::IsWindowActive(nsPIDOMWindowOuter* aWindow)
{

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

@ -7,7 +7,6 @@
#ifndef mozilla_dom_audiochannelservice_h__
#define mozilla_dom_audiochannelservice_h__
#include "nsIAudioChannelService.h"
#include "nsAutoPtr.h"
#include "nsIObserver.h"
#include "nsTObserverArray.h"
@ -58,13 +57,11 @@ public:
uint32_t mSuspend;
};
class AudioChannelService final : public nsIAudioChannelService
, public nsIObserver
class AudioChannelService final : public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSIAUDIOCHANNELSERVICE
/**
* eNotAudible : agent is not audible
@ -142,19 +139,6 @@ public:
AudibleState aAudible,
AudibleChangedReasons aReason);
/* Methods for the BrowserElementAudioChannel */
float GetAudioChannelVolume(nsPIDOMWindowOuter* aWindow, AudioChannel aChannel);
void SetAudioChannelVolume(nsPIDOMWindowOuter* aWindow, AudioChannel aChannel,
float aVolume);
bool GetAudioChannelMuted(nsPIDOMWindowOuter* aWindow, AudioChannel aChannel);
void SetAudioChannelMuted(nsPIDOMWindowOuter* aWindow, AudioChannel aChannel,
bool aMuted);
bool IsAudioChannelActive(nsPIDOMWindowOuter* aWindow, AudioChannel aChannel);
bool IsWindowActive(nsPIDOMWindowOuter* aWindow);
/**
@ -184,9 +168,6 @@ public:
void RefreshAgentsSuspend(nsPIDOMWindowOuter* aWindow,
nsSuspendedTypes aSuspend);
void RefreshAgentsVolumeAndPropagate(AudioChannel aAudioChannel,
nsPIDOMWindowOuter* aWindow);
// This method needs to know the inner window that wants to capture audio. We
// group agents per top outer window, but we can have multiple innerWindow per
// top outerWindow (subiframes, etc.) and we have to identify all the agents
@ -254,10 +235,7 @@ private:
, mIsAudioCaptured(false)
, mOwningAudioFocus(!AudioChannelService::IsEnableAudioCompeting())
, mShouldSendBlockStopEvent(false)
{
// Workaround for bug1183033, system channel type can always playback.
mChannels[(int16_t)AudioChannel::System].mMuted = false;
}
{}
void AudioFocusChanged(AudioChannelAgent* aNewPlayingAgent);
void AudioAudibleChanged(AudioChannelAgent* aAgent,

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

@ -9,7 +9,6 @@ with Files("**"):
XPIDL_SOURCES += [
'nsIAudioChannelAgent.idl',
'nsIAudioChannelService.idl',
]
XPIDL_MODULE = 'dom_audiochannel'

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

@ -1,29 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 mozIDOMWindowProxy;
[scriptable, builtinclass, uuid(5cb24dbc-36c7-46a4-9966-ac73141dc795)]
interface nsIAudioChannelService : nsISupports
{
float getAudioChannelVolume(in mozIDOMWindowProxy window,
in unsigned short audioChannel);
void setAudioChannelVolume(in mozIDOMWindowProxy window,
in unsigned short audioChannel,
in float volume);
boolean getAudioChannelMuted(in mozIDOMWindowProxy window,
in unsigned short audioChannel);
void setAudioChannelMuted(in mozIDOMWindowProxy window,
in unsigned short audioChannel,
in boolean muted);
boolean isAudioChannelActive(in mozIDOMWindowProxy window,
in unsigned short audioChannel);
};

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

@ -18,9 +18,6 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/BrowserElementPromptService.jsm");
Cu.import("resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "acs",
"@mozilla.org/audiochannel/service;1",
"nsIAudioChannelService");
XPCOMUtils.defineLazyModuleGetter(this, "ManifestFinder",
"resource://gre/modules/ManifestFinder.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ManifestObtainer",
@ -316,11 +313,6 @@ BrowserElementChild.prototype = {
"find-next": this._recvFindNext,
"clear-match": this._recvClearMatch,
"execute-script": this._recvExecuteScript,
"get-audio-channel-volume": this._recvGetAudioChannelVolume,
"set-audio-channel-volume": this._recvSetAudioChannelVolume,
"get-audio-channel-muted": this._recvGetAudioChannelMuted,
"set-audio-channel-muted": this._recvSetAudioChannelMuted,
"get-is-audio-channel-active": this._recvIsAudioChannelActive,
"get-web-manifest": this._recvGetWebManifest,
}
@ -1381,54 +1373,6 @@ BrowserElementChild.prototype = {
docShell.contentViewer.fullZoom = data.json.zoom;
},
_recvGetAudioChannelVolume: function(data) {
debug("Received getAudioChannelVolume message: (" + data.json.id + ")");
let volume = acs.getAudioChannelVolume(content,
data.json.args.audioChannel);
sendAsyncMsg('got-audio-channel-volume', {
id: data.json.id, successRv: volume
});
},
_recvSetAudioChannelVolume: function(data) {
debug("Received setAudioChannelVolume message: (" + data.json.id + ")");
acs.setAudioChannelVolume(content,
data.json.args.audioChannel,
data.json.args.volume);
sendAsyncMsg('got-set-audio-channel-volume', {
id: data.json.id, successRv: true
});
},
_recvGetAudioChannelMuted: function(data) {
debug("Received getAudioChannelMuted message: (" + data.json.id + ")");
let muted = acs.getAudioChannelMuted(content, data.json.args.audioChannel);
sendAsyncMsg('got-audio-channel-muted', {
id: data.json.id, successRv: muted
});
},
_recvSetAudioChannelMuted: function(data) {
debug("Received setAudioChannelMuted message: (" + data.json.id + ")");
acs.setAudioChannelMuted(content, data.json.args.audioChannel,
data.json.args.muted);
sendAsyncMsg('got-set-audio-channel-muted', {
id: data.json.id, successRv: true
});
},
_recvIsAudioChannelActive: function(data) {
debug("Received isAudioChannelActive message: (" + data.json.id + ")");
let active = acs.isAudioChannelActive(content, data.json.args.audioChannel);
sendAsyncMsg('got-is-audio-channel-active', {
id: data.json.id, successRv: active
});
},
_recvGetWebManifest: Task.async(function* (data) {
debug(`Received GetWebManifest message: (${data.json.id})`);
let manifest = null;

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

@ -180,11 +180,6 @@ BrowserElementParent.prototype = {
"caretstatechanged": this._handleCaretStateChanged,
"findchange": this._handleFindChange,
"execute-script-done": this._gotDOMRequestResult,
"got-audio-channel-volume": this._gotDOMRequestResult,
"got-set-audio-channel-volume": this._gotDOMRequestResult,
"got-audio-channel-muted": this._gotDOMRequestResult,
"got-set-audio-channel-muted": this._gotDOMRequestResult,
"got-is-audio-channel-active": this._gotDOMRequestResult,
"got-web-manifest": this._gotDOMRequestResult,
};
@ -896,33 +891,6 @@ BrowserElementParent.prototype = {
}
},
getAudioChannelVolume: function(aAudioChannel) {
return this._sendDOMRequest('get-audio-channel-volume',
{audioChannel: aAudioChannel});
},
setAudioChannelVolume: function(aAudioChannel, aVolume) {
return this._sendDOMRequest('set-audio-channel-volume',
{audioChannel: aAudioChannel,
volume: aVolume});
},
getAudioChannelMuted: function(aAudioChannel) {
return this._sendDOMRequest('get-audio-channel-muted',
{audioChannel: aAudioChannel});
},
setAudioChannelMuted: function(aAudioChannel, aMuted) {
return this._sendDOMRequest('set-audio-channel-muted',
{audioChannel: aAudioChannel,
muted: aMuted});
},
isAudioChannelActive: function(aAudioChannel) {
return this._sendDOMRequest('get-is-audio-channel-active',
{audioChannel: aAudioChannel});
},
getWebManifest: defineDOMRequestMethod('get-web-manifest'),
/**
* Called when the visibility of the window which owns this iframe changes.

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

@ -92,14 +92,6 @@ interface nsIBrowserElementAPI : nsISupports
void addNextPaintListener(in nsIBrowserElementNextPaintListener listener);
void removeNextPaintListener(in nsIBrowserElementNextPaintListener listener);
nsIDOMDOMRequest getAudioChannelVolume(in uint32_t audioChannel);
nsIDOMDOMRequest setAudioChannelVolume(in uint32_t audioChannel, in float volume);
nsIDOMDOMRequest getAudioChannelMuted(in uint32_t audioChannel);
nsIDOMDOMRequest setAudioChannelMuted(in uint32_t audioChannel, in bool muted);
nsIDOMDOMRequest isAudioChannelActive(in uint32_t audioChannel);
nsIDOMDOMRequest executeScript(in DOMString script, in jsval options);
/**

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

@ -827,13 +827,6 @@ child:
async HandleAccessKey(WidgetKeyboardEvent event,
uint32_t[] charCodes, int32_t modifierMask);
/**
* Propagate a refresh to the child process
*/
async AudioChannelChangeNotification(uint32_t aAudioChannel,
float aVolume,
bool aMuted);
/**
* Tells the root child docShell whether or not to use
* global history. This is sent right after the PBrowser

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

@ -2321,27 +2321,6 @@ TabChild::RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent,
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvAudioChannelChangeNotification(const uint32_t& aAudioChannel,
const float& aVolume,
const bool& aMuted)
{
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
if (window) {
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
MOZ_ASSERT(service);
service->SetAudioChannelVolume(window,
static_cast<AudioChannel>(aAudioChannel),
aVolume);
service->SetAudioChannelMuted(window,
static_cast<AudioChannel>(aAudioChannel),
aMuted);
}
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvSetUseGlobalHistory(const bool& aUse)
{

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

@ -590,10 +590,6 @@ public:
nsTArray<uint32_t>&& aCharCodes,
const int32_t& aModifierMask) override;
virtual mozilla::ipc::IPCResult RecvAudioChannelChangeNotification(const uint32_t& aAudioChannel,
const float& aVolume,
const bool& aMuted) override;
virtual mozilla::ipc::IPCResult RecvSetUseGlobalHistory(const bool& aUse) override;
virtual mozilla::ipc::IPCResult RecvHandledWindowedPluginKeyEvent(

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

@ -3217,33 +3217,6 @@ TabParent::GetShowInfo()
false, mDPI, mRounding, mDefaultScale.scale);
}
void
TabParent::AudioChannelChangeNotification(nsPIDOMWindowOuter* aWindow,
AudioChannel aAudioChannel,
float aVolume,
bool aMuted)
{
if (!mFrameElement || !mFrameElement->OwnerDoc()) {
return;
}
nsCOMPtr<nsPIDOMWindowOuter> window = mFrameElement->OwnerDoc()->GetWindow();
while (window) {
if (window == aWindow) {
Unused << SendAudioChannelChangeNotification(static_cast<uint32_t>(aAudioChannel),
aVolume, aMuted);
break;
}
nsCOMPtr<nsPIDOMWindowOuter> win = window->GetScriptableParentOrNull();
if (!win) {
break;
}
window = win;
}
}
mozilla::ipc::IPCResult
TabParent::RecvGetTabCount(uint32_t* aValue)
{

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

@ -577,10 +577,6 @@ public:
layout::RenderFrameParent* GetRenderFrame();
void AudioChannelChangeNotification(nsPIDOMWindowOuter* aWindow,
AudioChannel aAudioChannel,
float aVolume,
bool aMuted);
bool SetRenderFrame(PRenderFrameParent* aRFParent);
bool GetRenderFrameInfo(TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId);