Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef mozilla_system_nsvolumeservice_h__ |
michael@0 | 6 | #define mozilla_system_nsvolumeservice_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "mozilla/Monitor.h" |
michael@0 | 9 | #include "mozilla/RefPtr.h" |
michael@0 | 10 | #include "mozilla/StaticPtr.h" |
michael@0 | 11 | #include "nsCOMPtr.h" |
michael@0 | 12 | #include "nsIDOMWakeLockListener.h" |
michael@0 | 13 | #include "nsIVolume.h" |
michael@0 | 14 | #include "nsIVolumeService.h" |
michael@0 | 15 | #include "nsVolume.h" |
michael@0 | 16 | |
michael@0 | 17 | namespace mozilla { |
michael@0 | 18 | namespace system { |
michael@0 | 19 | |
michael@0 | 20 | class WakeLockCallback; |
michael@0 | 21 | class Volume; |
michael@0 | 22 | |
michael@0 | 23 | /*************************************************************************** |
michael@0 | 24 | * The nsVolumeData class encapsulates the data that is updated/maintained |
michael@0 | 25 | * on the main thread in order to support the nsIVolume and nsIVolumeService |
michael@0 | 26 | * classes. |
michael@0 | 27 | */ |
michael@0 | 28 | |
michael@0 | 29 | class nsVolumeService MOZ_FINAL : public nsIVolumeService, |
michael@0 | 30 | public nsIDOMMozWakeLockListener |
michael@0 | 31 | { |
michael@0 | 32 | public: |
michael@0 | 33 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 34 | NS_DECL_NSIVOLUMESERVICE |
michael@0 | 35 | NS_DECL_NSIDOMMOZWAKELOCKLISTENER |
michael@0 | 36 | |
michael@0 | 37 | nsVolumeService(); |
michael@0 | 38 | |
michael@0 | 39 | static already_AddRefed<nsVolumeService> GetSingleton(); |
michael@0 | 40 | //static nsVolumeService* GetSingleton(); |
michael@0 | 41 | static void Shutdown(); |
michael@0 | 42 | |
michael@0 | 43 | void UpdateVolume(nsIVolume* aVolume); |
michael@0 | 44 | void UpdateVolumeIOThread(const Volume* aVolume); |
michael@0 | 45 | |
michael@0 | 46 | private: |
michael@0 | 47 | ~nsVolumeService(); |
michael@0 | 48 | |
michael@0 | 49 | void CheckMountLock(const nsAString& aMountLockName, |
michael@0 | 50 | const nsAString& aMountLockState); |
michael@0 | 51 | already_AddRefed<nsVolume> FindVolumeByMountLockName(const nsAString& aMountLockName); |
michael@0 | 52 | already_AddRefed<nsVolume> FindVolumeByName(const nsAString& aName); |
michael@0 | 53 | already_AddRefed<nsVolume> CreateOrFindVolumeByName(const nsAString& aName, bool aIsFake = false); |
michael@0 | 54 | |
michael@0 | 55 | Monitor mArrayMonitor; |
michael@0 | 56 | nsVolume::Array mVolumeArray; |
michael@0 | 57 | |
michael@0 | 58 | static StaticRefPtr<nsVolumeService> sSingleton; |
michael@0 | 59 | }; |
michael@0 | 60 | |
michael@0 | 61 | } // system |
michael@0 | 62 | } // mozilla |
michael@0 | 63 | |
michael@0 | 64 | #endif // mozilla_system_nsvolumeservice_h__ |