mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 873391 - Volume state changes may get processed out of order in child processes. r=qDot
This commit is contained in:
parent
5b065dbbfb
commit
a70d0d649d
@ -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<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState,
|
||||
aMountGeneration);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
NS_ConvertUTF8toUTF16 stateStr(volume->StateStr());
|
||||
obs->NotifyObservers(volume, NS_VOLUME_STATE_CHANGED, stateStr.get());
|
||||
nsRefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
|
||||
if (vs) {
|
||||
vs->UpdateVolume(volume);
|
||||
}
|
||||
#else
|
||||
// Remove warnings about unused arguments
|
||||
unused << aFsName;
|
||||
|
@ -39,6 +39,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
EXPORTS += [
|
||||
'GonkGPSGeolocationProvider.h',
|
||||
'nsVolume.h',
|
||||
'nsVolumeService.h',
|
||||
]
|
||||
|
||||
if CONFIG['ENABLE_TESTS']:
|
||||
|
@ -66,8 +66,6 @@ nsVolumeService::Shutdown()
|
||||
return;
|
||||
}
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
nsCOMPtr<nsIObserverService> 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<nsIObserverService> 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<nsIVolume> 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<nsIObserverService> obs = GetObserverService();
|
||||
if (!obs) {
|
||||
return;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user