gecko/dom/system/gonk/nsVolume.h
Dave Hylands 0b3918ce04 Bug 785124 - Pt 1 - Add VolumeMountLock which allows SDCard to be locked. r=dougt
From 8e39b8e5f3ab7e6344b0a8a5eeabdcf672de8fb4 Mon Sep 17 00:00:00 2001
---
 dom/ipc/ContentChild.cpp                  |   18 +++-
 dom/ipc/ContentChild.h                    |    5 +-
 dom/ipc/ContentParent.cpp                 |   22 +++-
 dom/ipc/ContentParent.h                   |    2 +
 dom/ipc/PContent.ipdl                     |    6 +-
 dom/system/gonk/AutoMounter.cpp           |   19 +++-
 dom/system/gonk/Makefile.in               |    4 +-
 dom/system/gonk/Volume.cpp                |   62 ++++++++++-
 dom/system/gonk/Volume.h                  |   11 +-
 dom/system/gonk/VolumeServiceIOThread.cpp |   11 +-
 dom/system/gonk/VolumeServiceIOThread.h   |    7 +-
 dom/system/gonk/nsIVolume.idl             |   21 +++-
 dom/system/gonk/nsIVolumeMountLock.idl    |   12 +++
 dom/system/gonk/nsIVolumeService.idl      |    9 +-
 dom/system/gonk/nsVolume.cpp              |   96 ++++++++++++++++-
 dom/system/gonk/nsVolume.h                |   43 ++++++--
 dom/system/gonk/nsVolumeMountLock.cpp     |  157 +++++++++++++++++++++++++++
 dom/system/gonk/nsVolumeMountLock.h       |   55 ++++++++++
 dom/system/gonk/nsVolumeService.cpp       |  168 +++++++++++++++++++++++------
 dom/system/gonk/nsVolumeService.h         |   20 +++-
 layout/build/nsLayoutModule.cpp           |    5 +-
 layout/build/nsLayoutStatics.cpp          |    9 ++
 22 files changed, 684 insertions(+), 78 deletions(-)
 create mode 100644 dom/system/gonk/nsIVolumeMountLock.idl
 create mode 100644 dom/system/gonk/nsVolumeMountLock.cpp
 create mode 100644 dom/system/gonk/nsVolumeMountLock.h
2012-12-14 16:01:34 -08:00

94 lines
2.6 KiB
C++

/* 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__
#include "nsCOMPtr.h"
#include "nsIVolume.h"
#include "nsString.h"
#include "nsTArray.h"
namespace mozilla {
namespace system {
class Volume;
class VolumeMountLock;
class nsVolume : public nsIVolume
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIVOLUME
// This constructor is used by the UpdateVolumeRunnable constructor
nsVolume(const Volume *aVolume);
// This constructor is used by ContentChild::RecvFileSystemUpdate
nsVolume(const nsAString &aName, const nsAString &aMountPoint,
const int32_t &aState, const int32_t &aMountGeneration)
: mName(aName),
mMountPoint(aMountPoint),
mState(aState),
mMountGeneration(aMountGeneration),
mMountLocked(false)
{
}
// This constructor is used by nsVolumeService::FindAddVolumeByName, and
// will be followed shortly by a Set call.
nsVolume(const nsAString &aName)
: mName(aName),
mState(STATE_INIT),
mMountGeneration(-1),
mMountLocked(true) // Needs to agree with Volume::Volume
{
}
bool Equals(const nsVolume *aVolume)
{
return mName.Equals(aVolume->mName)
&& mMountPoint.Equals(aVolume->mMountPoint)
&& (mState == aVolume->mState)
&& (mMountGeneration == aVolume->mMountGeneration)
&& (mMountLocked == aVolume->mMountLocked);
}
void Set(const nsVolume *aVolume);
void LogState() const;
const nsString &Name() const { return mName; }
const char *NameStr() const { return NS_LossyConvertUTF16toASCII(mName).get(); }
int32_t MountGeneration() const { return mMountGeneration; }
bool IsMountLocked() const { return mMountLocked; }
const nsString &MountPoint() const { return mMountPoint; }
const char *MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint).get(); }
int32_t State() const { return mState; }
const char *StateStr() const { return NS_VolumeStateStr(mState); }
typedef nsTArray<nsRefPtr<nsVolume> > Array;
private:
~nsVolume() {}
friend class nsVolumeService; // Calls the following XxxMountLock functions
void UpdateMountLock(const nsAString &aMountLockState);
void UpdateMountLock(bool aMountLocked);
nsString mName;
nsString mMountPoint;
int32_t mState;
int32_t mMountGeneration;
bool mMountLocked;
};
} // system
} // mozilla
#endif // mozilla_system_nsvolume_h__