From ba62cd0f90563beef93d6b88570d2ad1774bfcdd Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 14 Jul 2015 20:16:21 -0400 Subject: [PATCH] Bug 1183925 - Part 2: Clean up the AudioChannelService shutdown; r=baku Right now this function is called after the XPCOM component manager is shut down, so it can never remove any observers. It's better to do this work in response to xpcom-shutdown while we still have a component manager to be able to clean up after ourselves properly. --- dom/audiochannel/AudioChannelService.cpp | 13 ++----------- dom/audiochannel/AudioChannelService.h | 12 +++++------- layout/build/nsLayoutStatics.cpp | 2 -- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index f9431c5dbb1..dc0cb4b17a4 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -207,8 +207,7 @@ NS_IMPL_ADDREF(AudioChannelService) NS_IMPL_RELEASE(AudioChannelService) AudioChannelService::AudioChannelService() - : mDisabled(false) - , mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN) + : mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN) , mTelephonyChannel(false) , mContentOrNormalChannel(false) , mAnyChannel(false) @@ -238,10 +237,6 @@ void AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent, AudioChannel aChannel) { - if (mDisabled) { - return; - } - uint64_t windowID = aAgent->WindowID(); AudioChannelWindow* winData = GetWindowData(windowID); if (!winData) { @@ -272,10 +267,6 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent, void AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent) { - if (mDisabled) { - return; - } - AudioChannelWindow* winData = GetWindowData(aAgent->WindowID()); if (!winData) { return; @@ -466,8 +457,8 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { if (!strcmp(aTopic, "xpcom-shutdown")) { - mDisabled = true; mWindows.Clear(); + Shutdown(); } #ifdef MOZ_WIDGET_GONK diff --git a/dom/audiochannel/AudioChannelService.h b/dom/audiochannel/AudioChannelService.h index 65f312d236b..a0a65d8c737 100644 --- a/dom/audiochannel/AudioChannelService.h +++ b/dom/audiochannel/AudioChannelService.h @@ -43,11 +43,6 @@ public: */ static already_AddRefed GetOrCreate(); - /** - * Shutdown the singleton. - */ - static void Shutdown(); - static bool IsAudioChannelMutedByDefault(); /** @@ -136,6 +131,11 @@ private: AudioChannelService(); ~AudioChannelService(); + /** + * Shutdown the singleton. + */ + static void Shutdown(); + void MaybeSendStatusUpdate(); bool ContentOrNormalChannelIsActive(); @@ -204,8 +204,6 @@ private: nsTArray mSpeakerManager; #endif - bool mDisabled; - nsCOMPtr mRunnable; uint64_t mDefChannelChildID; diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index acd855cbed7..082578d32e9 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -433,8 +433,6 @@ nsLayoutStatics::Shutdown() nsHyphenationManager::Shutdown(); nsDOMMutationObserver::Shutdown(); - AudioChannelService::Shutdown(); - DataStoreService::Shutdown(); ContentParent::ShutDown();