2012-07-16 09:38:18 -07: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_nsvolume_h__
|
|
|
|
#define mozilla_system_nsvolume_h__
|
|
|
|
|
2012-12-14 16:01:34 -08:00
|
|
|
#include "nsCOMPtr.h"
|
2012-07-16 09:38:18 -07:00
|
|
|
#include "nsIVolume.h"
|
2012-08-03 16:48:58 -07:00
|
|
|
#include "nsString.h"
|
2012-12-14 16:01:34 -08:00
|
|
|
#include "nsTArray.h"
|
2012-07-16 09:38:18 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace system {
|
|
|
|
|
2012-08-03 16:48:58 -07:00
|
|
|
class Volume;
|
2012-12-14 16:01:34 -08:00
|
|
|
class VolumeMountLock;
|
2012-08-03 16:48:58 -07:00
|
|
|
|
2012-07-16 09:38:18 -07:00
|
|
|
class nsVolume : public nsIVolume
|
|
|
|
{
|
|
|
|
public:
|
2013-07-18 19:21:20 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-07-16 09:38:18 -07:00
|
|
|
NS_DECL_NSIVOLUME
|
|
|
|
|
2012-12-14 16:01:34 -08:00
|
|
|
// This constructor is used by the UpdateVolumeRunnable constructor
|
2013-01-07 08:43:02 -08:00
|
|
|
nsVolume(const Volume* aVolume);
|
2012-08-03 16:48:58 -07:00
|
|
|
|
2013-08-22 16:12:25 -07:00
|
|
|
// This constructor is used by ContentChild::RecvFileSystemUpdate which is
|
|
|
|
// used to update the volume cache maintained in the child process.
|
2013-01-07 08:43:02 -08:00
|
|
|
nsVolume(const nsAString& aName, const nsAString& aMountPoint,
|
2013-08-22 16:12:25 -07:00
|
|
|
const int32_t& aState, const int32_t& aMountGeneration,
|
2013-12-03 01:32:56 -08:00
|
|
|
const bool& aIsMediaPresent, const bool& aIsSharing,
|
2014-05-13 15:48:04 -07:00
|
|
|
const bool& aIsFormatting, const bool& aIsFake)
|
2012-12-14 16:01:34 -08:00
|
|
|
: mName(aName),
|
|
|
|
mMountPoint(aMountPoint),
|
|
|
|
mState(aState),
|
|
|
|
mMountGeneration(aMountGeneration),
|
2013-07-08 23:37:47 -07:00
|
|
|
mMountLocked(false),
|
2014-05-13 15:48:04 -07:00
|
|
|
mIsFake(aIsFake),
|
2013-08-22 16:12:25 -07:00
|
|
|
mIsMediaPresent(aIsMediaPresent),
|
2013-09-05 23:11:58 -07:00
|
|
|
mIsSharing(aIsSharing),
|
2013-12-03 01:32:56 -08:00
|
|
|
mIsFormatting(aIsFormatting)
|
2012-07-16 09:38:18 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-14 16:01:34 -08:00
|
|
|
// This constructor is used by nsVolumeService::FindAddVolumeByName, and
|
|
|
|
// will be followed shortly by a Set call.
|
2013-01-07 08:43:02 -08:00
|
|
|
nsVolume(const nsAString& aName)
|
2012-07-16 09:38:18 -07:00
|
|
|
: mName(aName),
|
2012-12-14 16:01:34 -08:00
|
|
|
mState(STATE_INIT),
|
|
|
|
mMountGeneration(-1),
|
2013-07-08 23:37:47 -07:00
|
|
|
mMountLocked(true), // Needs to agree with Volume::Volume
|
2013-08-22 16:12:25 -07:00
|
|
|
mIsFake(false),
|
|
|
|
mIsMediaPresent(false),
|
2013-09-05 23:11:58 -07:00
|
|
|
mIsSharing(false),
|
|
|
|
mIsFormatting(false)
|
2012-07-16 09:38:18 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-02 12:52:17 -07:00
|
|
|
bool Equals(nsIVolume* aVolume);
|
|
|
|
void Set(nsIVolume* aVolume);
|
2012-12-14 16:01:34 -08:00
|
|
|
|
|
|
|
void LogState() const;
|
2012-07-16 09:38:18 -07:00
|
|
|
|
2013-01-07 08:43:02 -08:00
|
|
|
const nsString& Name() const { return mName; }
|
2013-01-28 14:34:30 -08:00
|
|
|
nsCString NameStr() const { return NS_LossyConvertUTF16toASCII(mName); }
|
2012-12-14 16:01:34 -08:00
|
|
|
|
2012-12-14 16:01:34 -08:00
|
|
|
int32_t MountGeneration() const { return mMountGeneration; }
|
|
|
|
bool IsMountLocked() const { return mMountLocked; }
|
|
|
|
|
2013-01-07 08:43:02 -08:00
|
|
|
const nsString& MountPoint() const { return mMountPoint; }
|
2013-01-28 14:34:30 -08:00
|
|
|
nsCString MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint); }
|
2012-07-16 09:38:18 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t State() const { return mState; }
|
2013-01-07 08:43:02 -08:00
|
|
|
const char* StateStr() const { return NS_VolumeStateStr(mState); }
|
2012-07-16 09:38:18 -07:00
|
|
|
|
2013-10-18 20:21:52 -07:00
|
|
|
bool IsFake() const { return mIsFake; }
|
|
|
|
bool IsMediaPresent() const { return mIsMediaPresent; }
|
|
|
|
bool IsSharing() const { return mIsSharing; }
|
2013-09-05 23:11:58 -07:00
|
|
|
bool IsFormatting() const { return mIsFormatting; }
|
2013-10-18 20:21:52 -07:00
|
|
|
|
2012-07-16 09:38:18 -07:00
|
|
|
typedef nsTArray<nsRefPtr<nsVolume> > Array;
|
|
|
|
|
|
|
|
private:
|
2014-05-13 15:48:04 -07:00
|
|
|
virtual ~nsVolume() {} // MozExternalRefCountType complains if this is non-virtual
|
2012-07-16 09:38:18 -07:00
|
|
|
|
2012-12-14 16:01:34 -08:00
|
|
|
friend class nsVolumeService; // Calls the following XxxMountLock functions
|
2013-01-07 08:43:02 -08:00
|
|
|
void UpdateMountLock(const nsAString& aMountLockState);
|
2012-12-14 16:01:34 -08:00
|
|
|
void UpdateMountLock(bool aMountLocked);
|
|
|
|
|
2013-08-22 16:12:25 -07:00
|
|
|
void SetIsFake(bool aIsFake);
|
2013-07-08 23:37:47 -07:00
|
|
|
void SetState(int32_t aState);
|
2013-09-05 23:11:58 -07:00
|
|
|
static void FormatVolumeIOThread(const nsCString& aVolume);
|
2014-03-04 03:24:19 -08:00
|
|
|
static void MountVolumeIOThread(const nsCString& aVolume);
|
|
|
|
static void UnmountVolumeIOThread(const nsCString& aVolume);
|
2013-07-08 23:37:47 -07:00
|
|
|
|
2012-07-16 09:38:18 -07:00
|
|
|
nsString mName;
|
|
|
|
nsString mMountPoint;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mState;
|
2012-12-14 16:01:34 -08:00
|
|
|
int32_t mMountGeneration;
|
|
|
|
bool mMountLocked;
|
2013-07-08 23:37:47 -07:00
|
|
|
bool mIsFake;
|
2013-08-22 16:12:25 -07:00
|
|
|
bool mIsMediaPresent;
|
|
|
|
bool mIsSharing;
|
2013-09-05 23:11:58 -07:00
|
|
|
bool mIsFormatting;
|
2012-07-16 09:38:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // system
|
|
|
|
} // mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_system_nsvolume_h__
|