diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index e49d1a12baa..18fa5637c4c 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -77,6 +77,7 @@ #if defined(MOZ_WIDGET_GONK) #include "nsVolume.h" +#include "nsVolumeService.h" #endif #ifdef XP_WIN @@ -1186,9 +1187,10 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName, nsRefPtr volume = new nsVolume(aFsName, aVolumeName, aState, aMountGeneration); - nsCOMPtr obs = mozilla::services::GetObserverService(); - NS_ConvertUTF8toUTF16 stateStr(volume->StateStr()); - obs->NotifyObservers(volume, NS_VOLUME_STATE_CHANGED, stateStr.get()); + nsRefPtr vs = nsVolumeService::GetSingleton(); + if (vs) { + vs->UpdateVolume(volume); + } #else // Remove warnings about unused arguments unused << aFsName; diff --git a/dom/system/gonk/moz.build b/dom/system/gonk/moz.build index 7fee24e8954..b1e1398a7f7 100644 --- a/dom/system/gonk/moz.build +++ b/dom/system/gonk/moz.build @@ -39,6 +39,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': EXPORTS += [ 'GonkGPSGeolocationProvider.h', 'nsVolume.h', + 'nsVolumeService.h', ] if CONFIG['ENABLE_TESTS']: diff --git a/dom/system/gonk/nsVolumeService.cpp b/dom/system/gonk/nsVolumeService.cpp index d34163b57cf..51209c18c89 100644 --- a/dom/system/gonk/nsVolumeService.cpp +++ b/dom/system/gonk/nsVolumeService.cpp @@ -66,8 +66,6 @@ nsVolumeService::Shutdown() return; } if (XRE_GetProcessType() != GeckoProcessType_Default) { - nsCOMPtr obs = GetObserverService(); - obs->RemoveObserver(sSingleton.get(), NS_VOLUME_STATE_CHANGED); sSingleton = nullptr; return; } @@ -91,10 +89,6 @@ nsVolumeService::nsVolumeService() sSingleton = this; if (XRE_GetProcessType() != GeckoProcessType_Default) { - // For child processes, we keep a cache of the volume state. - nsCOMPtr obs = GetObserverService(); - obs->AddObserver(this, NS_VOLUME_STATE_CHANGED, false /*weak*/); - // Request the initial state for all volumes. ContentChild::GetSingleton()->SendBroadcastVolume(NS_LITERAL_STRING("")); return; @@ -347,21 +341,6 @@ nsVolumeService::CreateOrFindVolumeByName(const nsAString& aName) return vol.forget(); } -NS_IMETHODIMP -nsVolumeService::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData) -{ - if (strcmp(aTopic, NS_VOLUME_STATE_CHANGED) != 0) { - return NS_OK; - } - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default); - nsCOMPtr vol = do_QueryInterface(aSubject); - if (!vol) { - return NS_OK; - } - UpdateVolume(vol); - return NS_OK; -} - void nsVolumeService::UpdateVolume(nsIVolume* aVolume) { @@ -375,10 +354,6 @@ nsVolumeService::UpdateVolume(nsIVolume* aVolume) return; } vol->Set(aVolume); - if (XRE_GetProcessType() != GeckoProcessType_Default) { - // Only the parent broadcasts the state changes - return; - } nsCOMPtr obs = GetObserverService(); if (!obs) { return; diff --git a/dom/system/gonk/nsVolumeService.h b/dom/system/gonk/nsVolumeService.h index 5cfaed1f5b7..34eb710cf0a 100644 --- a/dom/system/gonk/nsVolumeService.h +++ b/dom/system/gonk/nsVolumeService.h @@ -10,16 +10,15 @@ #include "mozilla/StaticPtr.h" #include "nsCOMPtr.h" #include "nsIDOMWakeLockListener.h" -#include "nsIObserver.h" #include "nsIVolume.h" #include "nsIVolumeService.h" #include "nsVolume.h" -#include "Volume.h" namespace mozilla { namespace system { class WakeLockCallback; +class Volume; /*************************************************************************** * The nsVolumeData class encapsulates the data that is updated/maintained @@ -28,12 +27,10 @@ class WakeLockCallback; */ class nsVolumeService MOZ_FINAL : public nsIVolumeService, - public nsIObserver, public nsIDOMMozWakeLockListener { public: NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER NS_DECL_NSIVOLUMESERVICE NS_DECL_NSIDOMMOZWAKELOCKLISTENER