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