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