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