From 4c59db9d252a53d862b12f80facf87665374d24d Mon Sep 17 00:00:00 2001 From: Alastor Wu Date: Tue, 10 Nov 2015 14:43:59 +0800 Subject: [PATCH] Bug 1222902 - Create log system for the AudioChannel. r=baku --- dom/audiochannel/AudioChannelAgent.cpp | 16 +++++++++++++ dom/audiochannel/AudioChannelService.cpp | 23 +++++++++++++++++++ dom/audiochannel/AudioChannelService.h | 3 +++ .../BrowserElementAudioChannel.cpp | 8 +++++++ dom/html/nsBrowserElement.cpp | 3 +++ dom/ipc/TabChild.cpp | 3 +++ 6 files changed, 56 insertions(+) diff --git a/dom/audiochannel/AudioChannelAgent.cpp b/dom/audiochannel/AudioChannelAgent.cpp index 27af43e4a41..01014f153b2 100644 --- a/dom/audiochannel/AudioChannelAgent.cpp +++ b/dom/audiochannel/AudioChannelAgent.cpp @@ -130,6 +130,11 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType, mCallback = aCallback; } + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("AudioChannelAgent, InitInternal, this = %p, type = %d, " + "owner = %p, hasCallback = %d\n", this, mAudioChannelType, + mWindow.get(), (!!mCallback || !!mWeakCallback))); + return NS_OK; } @@ -158,6 +163,10 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(uint32_t aNotifyPlayback, service->GetState(mWindow, mAudioChannelType, aVolume, aMuted); + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("AudioChannelAgent, NotifyStartedPlaying, this = %p, mute = %d, " + "volume = %f\n", this, *aMuted, *aVolume)); + mNotifyPlayback = aNotifyPlayback; mIsRegToService = true; return NS_OK; @@ -170,6 +179,9 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying() return NS_ERROR_FAILURE; } + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("AudioChannelAgent, NotifyStoppedPlaying, this = %p\n", this)); + RefPtr service = AudioChannelService::GetOrCreate(); service->UnregisterAudioChannelAgent(this, mNotifyPlayback); mIsRegToService = false; @@ -200,6 +212,10 @@ AudioChannelAgent::WindowVolumeChanged() RefPtr service = AudioChannelService::GetOrCreate(); service->GetState(mWindow, mAudioChannelType, &volume, &muted); + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %d, " + "volume = %f\n", this, muted, volume)); + callback->WindowVolumeChanged(volume, muted); } diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index b3ef5b8ae6e..18239805a02 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -78,6 +78,11 @@ public: mActive ? MOZ_UTF16("active") : MOZ_UTF16("inactive")); + + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("NotifyChannelActiveRunnable, type = %d, active = %d\n", + mAudioChannel, mActive)); + return NS_OK; } @@ -178,6 +183,16 @@ AudioChannelService::GetOrCreate() return service.forget(); } +/* static */ PRLogModuleInfo* +AudioChannelService::GetAudioChannelLog() +{ + static PRLogModuleInfo *gAudioChannelLog; + if (!gAudioChannelLog) { + gAudioChannelLog = PR_NewLogModule("AudioChannel"); + } + return gAudioChannelLog; +} + void AudioChannelService::Shutdown() { @@ -719,6 +734,10 @@ AudioChannelService::SetAudioChannelVolume(nsPIDOMWindow* aWindow, MOZ_ASSERT(aWindow); MOZ_ASSERT(aWindow->IsOuterWindow()); + MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug, + ("AudioChannelService, SetAudioChannelVolume, window = %p, type = %d, " + "volume = %d\n", aWindow, aAudioChannel, aVolume)); + AudioChannelWindow* winData = GetOrCreateWindowData(aWindow); winData->mChannels[(uint32_t)aAudioChannel].mVolume = aVolume; RefreshAgentsVolume(aWindow); @@ -773,6 +792,10 @@ AudioChannelService::SetAudioChannelMuted(nsPIDOMWindow* aWindow, MOZ_ASSERT(aWindow); MOZ_ASSERT(aWindow->IsOuterWindow()); + MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug, + ("AudioChannelService, SetAudioChannelMuted, window = %p, type = %d, " + "mute = %d\n", aWindow, aAudioChannel, aMuted)); + if (aAudioChannel == AudioChannel::System) { // Workaround for bug1183033, system channel type can always playback. return; diff --git a/dom/audiochannel/AudioChannelService.h b/dom/audiochannel/AudioChannelService.h index 7a5a4728a88..40100c42caf 100644 --- a/dom/audiochannel/AudioChannelService.h +++ b/dom/audiochannel/AudioChannelService.h @@ -19,6 +19,7 @@ class nsIRunnable; class nsPIDOMWindow; +class PRLogModuleInfo; namespace mozilla { namespace dom { @@ -45,6 +46,8 @@ public: static bool IsAudioChannelMutedByDefault(); + static PRLogModuleInfo* GetAudioChannelLog(); + /** * Any audio channel agent that starts playing should register itself to * this service, sharing the AudioChannel. diff --git a/dom/browser-element/BrowserElementAudioChannel.cpp b/dom/browser-element/BrowserElementAudioChannel.cpp index c522b0a10a6..854ad81c50d 100644 --- a/dom/browser-element/BrowserElementAudioChannel.cpp +++ b/dom/browser-element/BrowserElementAudioChannel.cpp @@ -68,6 +68,10 @@ BrowserElementAudioChannel::Create(nsPIDOMWindow* aWindow, return nullptr; } + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("BrowserElementAudioChannel, Create, channel = %p, type = %d\n", + ac.get(), aAudioChannel)); + return ac.forget(); } @@ -608,6 +612,10 @@ BrowserElementAudioChannel::Observe(nsISupports* aSubject, const char* aTopic, void BrowserElementAudioChannel::ProcessStateChanged(const char16_t* aData) { + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("BrowserElementAudioChannel, ProcessStateChanged, this = %p, " + "type = %d\n", this, mAudioChannel)); + nsAutoString value(aData); mState = value.EqualsASCII("active") ? eStateActive : eStateInactive; DispatchTrustedEvent(NS_LITERAL_STRING("activestatechanged")); diff --git a/dom/html/nsBrowserElement.cpp b/dom/html/nsBrowserElement.cpp index 2b268c564c0..f7485c5df34 100644 --- a/dom/html/nsBrowserElement.cpp +++ b/dom/html/nsBrowserElement.cpp @@ -563,6 +563,9 @@ nsBrowserElement::GetAllowedAudioChannels( return; } + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("nsBrowserElement, GetAllowedAudioChannels, this = %p\n", this)); + GenerateAllowedAudioChannels(window, frameLoader, mBrowserElementAPI, manifestURL, mBrowserElementAudioChannels, aRv); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index a8a44a98be6..32a164d7d8f 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -693,6 +693,9 @@ TabChild::Observe(nsISupports *aSubject, // In theory a tabChild should contain just 1 top window, but let's double // check it comparing the windowID. if (window->WindowID() != windowID) { + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug, + ("TabChild, Observe, different windowID, owner ID = %lld, " + "ID from wrapper = %lld", window->WindowID(), windowID)); return NS_OK; }