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:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
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
|
|
|
|
2012-12-14 16:01:34 -08:00
|
|
|
// This constructor is used by ContentChild::RecvFileSystemUpdate
|
2013-01-07 08:43:02 -08:00
|
|
|
nsVolume(const nsAString& aName, const nsAString& aMountPoint,
|
|
|
|
const int32_t& aState, const int32_t& aMountGeneration)
|
2012-12-14 16:01:34 -08:00
|
|
|
: mName(aName),
|
|
|
|
mMountPoint(aMountPoint),
|
|
|
|
mState(aState),
|
|
|
|
mMountGeneration(aMountGeneration),
|
2013-07-09 11:21:02 -07:00
|
|
|
mMountLocked(false)
|
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-09 11:21:02 -07:00
|
|
|
mMountLocked(true) // Needs to agree with Volume::Volume
|
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
|
|
|
|
|
|
|
typedef nsTArray<nsRefPtr<nsVolume> > Array;
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsVolume() {}
|
|
|
|
|
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);
|
|
|
|
|
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;
|
2012-07-16 09:38:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // system
|
|
|
|
} // mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_system_nsvolume_h__
|