michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_system_nsvolume_h__ michael@0: #define mozilla_system_nsvolume_h__ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIVolume.h" michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: michael@0: namespace mozilla { michael@0: namespace system { michael@0: michael@0: class Volume; michael@0: class VolumeMountLock; michael@0: michael@0: class nsVolume : public nsIVolume michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIVOLUME michael@0: michael@0: // This constructor is used by the UpdateVolumeRunnable constructor michael@0: nsVolume(const Volume* aVolume); michael@0: michael@0: // This constructor is used by ContentChild::RecvFileSystemUpdate which is michael@0: // used to update the volume cache maintained in the child process. michael@0: nsVolume(const nsAString& aName, const nsAString& aMountPoint, michael@0: const int32_t& aState, const int32_t& aMountGeneration, michael@0: const bool& aIsMediaPresent, const bool& aIsSharing, michael@0: const bool& aIsFormatting) michael@0: : mName(aName), michael@0: mMountPoint(aMountPoint), michael@0: mState(aState), michael@0: mMountGeneration(aMountGeneration), michael@0: mMountLocked(false), michael@0: mIsFake(false), michael@0: mIsMediaPresent(aIsMediaPresent), michael@0: mIsSharing(aIsSharing), michael@0: mIsFormatting(aIsFormatting) michael@0: { michael@0: } michael@0: michael@0: // This constructor is used by nsVolumeService::FindAddVolumeByName, and michael@0: // will be followed shortly by a Set call. michael@0: nsVolume(const nsAString& aName) michael@0: : mName(aName), michael@0: mState(STATE_INIT), michael@0: mMountGeneration(-1), michael@0: mMountLocked(true), // Needs to agree with Volume::Volume michael@0: mIsFake(false), michael@0: mIsMediaPresent(false), michael@0: mIsSharing(false), michael@0: mIsFormatting(false) michael@0: { michael@0: } michael@0: michael@0: bool Equals(nsIVolume* aVolume); michael@0: void Set(nsIVolume* aVolume); michael@0: michael@0: void LogState() const; michael@0: michael@0: const nsString& Name() const { return mName; } michael@0: nsCString NameStr() const { return NS_LossyConvertUTF16toASCII(mName); } michael@0: michael@0: int32_t MountGeneration() const { return mMountGeneration; } michael@0: bool IsMountLocked() const { return mMountLocked; } michael@0: michael@0: const nsString& MountPoint() const { return mMountPoint; } michael@0: nsCString MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint); } michael@0: michael@0: int32_t State() const { return mState; } michael@0: const char* StateStr() const { return NS_VolumeStateStr(mState); } michael@0: michael@0: bool IsFake() const { return mIsFake; } michael@0: bool IsMediaPresent() const { return mIsMediaPresent; } michael@0: bool IsSharing() const { return mIsSharing; } michael@0: bool IsFormatting() const { return mIsFormatting; } michael@0: michael@0: typedef nsTArray > Array; michael@0: michael@0: private: michael@0: ~nsVolume() {} michael@0: michael@0: friend class nsVolumeService; // Calls the following XxxMountLock functions michael@0: void UpdateMountLock(const nsAString& aMountLockState); michael@0: void UpdateMountLock(bool aMountLocked); michael@0: michael@0: void SetIsFake(bool aIsFake); michael@0: void SetState(int32_t aState); michael@0: static void FormatVolumeIOThread(const nsCString& aVolume); michael@0: static void MountVolumeIOThread(const nsCString& aVolume); michael@0: static void UnmountVolumeIOThread(const nsCString& aVolume); michael@0: michael@0: nsString mName; michael@0: nsString mMountPoint; michael@0: int32_t mState; michael@0: int32_t mMountGeneration; michael@0: bool mMountLocked; michael@0: bool mIsFake; michael@0: bool mIsMediaPresent; michael@0: bool mIsSharing; michael@0: bool mIsFormatting; michael@0: }; michael@0: michael@0: } // system michael@0: } // mozilla michael@0: michael@0: #endif // mozilla_system_nsvolume_h__