Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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_nsvolume_h__ |
michael@0 | 6 | #define mozilla_system_nsvolume_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "nsCOMPtr.h" |
michael@0 | 9 | #include "nsIVolume.h" |
michael@0 | 10 | #include "nsString.h" |
michael@0 | 11 | #include "nsTArray.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace system { |
michael@0 | 15 | |
michael@0 | 16 | class Volume; |
michael@0 | 17 | class VolumeMountLock; |
michael@0 | 18 | |
michael@0 | 19 | class nsVolume : public nsIVolume |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 23 | NS_DECL_NSIVOLUME |
michael@0 | 24 | |
michael@0 | 25 | // This constructor is used by the UpdateVolumeRunnable constructor |
michael@0 | 26 | nsVolume(const Volume* aVolume); |
michael@0 | 27 | |
michael@0 | 28 | // This constructor is used by ContentChild::RecvFileSystemUpdate which is |
michael@0 | 29 | // used to update the volume cache maintained in the child process. |
michael@0 | 30 | nsVolume(const nsAString& aName, const nsAString& aMountPoint, |
michael@0 | 31 | const int32_t& aState, const int32_t& aMountGeneration, |
michael@0 | 32 | const bool& aIsMediaPresent, const bool& aIsSharing, |
michael@0 | 33 | const bool& aIsFormatting) |
michael@0 | 34 | : mName(aName), |
michael@0 | 35 | mMountPoint(aMountPoint), |
michael@0 | 36 | mState(aState), |
michael@0 | 37 | mMountGeneration(aMountGeneration), |
michael@0 | 38 | mMountLocked(false), |
michael@0 | 39 | mIsFake(false), |
michael@0 | 40 | mIsMediaPresent(aIsMediaPresent), |
michael@0 | 41 | mIsSharing(aIsSharing), |
michael@0 | 42 | mIsFormatting(aIsFormatting) |
michael@0 | 43 | { |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | // This constructor is used by nsVolumeService::FindAddVolumeByName, and |
michael@0 | 47 | // will be followed shortly by a Set call. |
michael@0 | 48 | nsVolume(const nsAString& aName) |
michael@0 | 49 | : mName(aName), |
michael@0 | 50 | mState(STATE_INIT), |
michael@0 | 51 | mMountGeneration(-1), |
michael@0 | 52 | mMountLocked(true), // Needs to agree with Volume::Volume |
michael@0 | 53 | mIsFake(false), |
michael@0 | 54 | mIsMediaPresent(false), |
michael@0 | 55 | mIsSharing(false), |
michael@0 | 56 | mIsFormatting(false) |
michael@0 | 57 | { |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | bool Equals(nsIVolume* aVolume); |
michael@0 | 61 | void Set(nsIVolume* aVolume); |
michael@0 | 62 | |
michael@0 | 63 | void LogState() const; |
michael@0 | 64 | |
michael@0 | 65 | const nsString& Name() const { return mName; } |
michael@0 | 66 | nsCString NameStr() const { return NS_LossyConvertUTF16toASCII(mName); } |
michael@0 | 67 | |
michael@0 | 68 | int32_t MountGeneration() const { return mMountGeneration; } |
michael@0 | 69 | bool IsMountLocked() const { return mMountLocked; } |
michael@0 | 70 | |
michael@0 | 71 | const nsString& MountPoint() const { return mMountPoint; } |
michael@0 | 72 | nsCString MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint); } |
michael@0 | 73 | |
michael@0 | 74 | int32_t State() const { return mState; } |
michael@0 | 75 | const char* StateStr() const { return NS_VolumeStateStr(mState); } |
michael@0 | 76 | |
michael@0 | 77 | bool IsFake() const { return mIsFake; } |
michael@0 | 78 | bool IsMediaPresent() const { return mIsMediaPresent; } |
michael@0 | 79 | bool IsSharing() const { return mIsSharing; } |
michael@0 | 80 | bool IsFormatting() const { return mIsFormatting; } |
michael@0 | 81 | |
michael@0 | 82 | typedef nsTArray<nsRefPtr<nsVolume> > Array; |
michael@0 | 83 | |
michael@0 | 84 | private: |
michael@0 | 85 | ~nsVolume() {} |
michael@0 | 86 | |
michael@0 | 87 | friend class nsVolumeService; // Calls the following XxxMountLock functions |
michael@0 | 88 | void UpdateMountLock(const nsAString& aMountLockState); |
michael@0 | 89 | void UpdateMountLock(bool aMountLocked); |
michael@0 | 90 | |
michael@0 | 91 | void SetIsFake(bool aIsFake); |
michael@0 | 92 | void SetState(int32_t aState); |
michael@0 | 93 | static void FormatVolumeIOThread(const nsCString& aVolume); |
michael@0 | 94 | static void MountVolumeIOThread(const nsCString& aVolume); |
michael@0 | 95 | static void UnmountVolumeIOThread(const nsCString& aVolume); |
michael@0 | 96 | |
michael@0 | 97 | nsString mName; |
michael@0 | 98 | nsString mMountPoint; |
michael@0 | 99 | int32_t mState; |
michael@0 | 100 | int32_t mMountGeneration; |
michael@0 | 101 | bool mMountLocked; |
michael@0 | 102 | bool mIsFake; |
michael@0 | 103 | bool mIsMediaPresent; |
michael@0 | 104 | bool mIsSharing; |
michael@0 | 105 | bool mIsFormatting; |
michael@0 | 106 | }; |
michael@0 | 107 | |
michael@0 | 108 | } // system |
michael@0 | 109 | } // mozilla |
michael@0 | 110 | |
michael@0 | 111 | #endif // mozilla_system_nsvolume_h__ |