2012-07-16 20:38:18 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_system_nsvolumeservice_h__
|
|
|
|
#define mozilla_system_nsvolumeservice_h__
|
|
|
|
|
2013-04-18 18:13:23 +04:00
|
|
|
#include "mozilla/Monitor.h"
|
2012-12-15 04:01:34 +04:00
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
2012-07-16 20:38:18 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2012-12-15 04:01:34 +04:00
|
|
|
#include "nsIDOMWakeLockListener.h"
|
2013-04-02 23:52:17 +04:00
|
|
|
#include "nsIObserver.h"
|
2012-07-16 20:38:18 +04:00
|
|
|
#include "nsIVolume.h"
|
|
|
|
#include "nsIVolumeService.h"
|
|
|
|
#include "nsVolume.h"
|
|
|
|
#include "Volume.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace system {
|
|
|
|
|
2012-12-15 04:01:34 +04:00
|
|
|
class WakeLockCallback;
|
|
|
|
|
2012-07-16 20:38:18 +04:00
|
|
|
/***************************************************************************
|
|
|
|
* The nsVolumeData class encapsulates the data that is updated/maintained
|
|
|
|
* on the main thread in order to support the nsIVolume and nsIVolumeService
|
|
|
|
* classes.
|
|
|
|
*/
|
|
|
|
|
2012-12-15 04:01:34 +04:00
|
|
|
class nsVolumeService MOZ_FINAL : public nsIVolumeService,
|
2013-04-02 23:52:17 +04:00
|
|
|
public nsIObserver,
|
2012-12-15 04:01:34 +04:00
|
|
|
public nsIDOMMozWakeLockListener
|
2012-07-16 20:38:18 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2013-04-02 23:52:17 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
2012-07-16 20:38:18 +04:00
|
|
|
NS_DECL_NSIVOLUMESERVICE
|
2012-12-15 04:01:34 +04:00
|
|
|
NS_DECL_NSIDOMMOZWAKELOCKLISTENER
|
2012-07-16 20:38:18 +04:00
|
|
|
|
|
|
|
nsVolumeService();
|
|
|
|
|
2012-12-15 04:01:34 +04:00
|
|
|
static already_AddRefed<nsVolumeService> GetSingleton();
|
2013-01-07 20:43:02 +04:00
|
|
|
//static nsVolumeService* GetSingleton();
|
2012-12-15 04:01:34 +04:00
|
|
|
static void Shutdown();
|
|
|
|
|
2013-04-02 23:52:17 +04:00
|
|
|
void UpdateVolume(nsIVolume* aVolume);
|
2013-01-07 20:43:02 +04:00
|
|
|
void UpdateVolumeIOThread(const Volume* aVolume);
|
2012-07-16 20:38:18 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
~nsVolumeService();
|
|
|
|
|
2013-04-18 18:13:23 +04:00
|
|
|
void CheckMountLock(const nsAString& aMountLockName,
|
|
|
|
const nsAString& aMountLockState);
|
|
|
|
already_AddRefed<nsVolume> FindVolumeByMountLockName(const nsAString& aMountLockName);
|
|
|
|
already_AddRefed<nsVolume> FindVolumeByName(const nsAString& aName);
|
|
|
|
already_AddRefed<nsVolume> CreateOrFindVolumeByName(const nsAString& aName);
|
|
|
|
|
|
|
|
Monitor mArrayMonitor;
|
2012-12-15 04:01:34 +04:00
|
|
|
nsVolume::Array mVolumeArray;
|
|
|
|
|
|
|
|
static StaticRefPtr<nsVolumeService> sSingleton;
|
2012-07-16 20:38:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // system
|
|
|
|
} // mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_system_nsvolumeservice_h__
|