gecko/dom/system/gonk/Volume.h
Dave Hylands 782c100040 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

95 lines
3.3 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_volume_h__
#define mozilla_system_volume_h__
#include "VolumeCommand.h"
#include "nsIVolume.h"
#include "nsString.h"
#include "mozilla/Observer.h"
#include "mozilla/RefPtr.h"
#include "nsWhitespaceTokenizer.h"
namespace mozilla {
namespace system {
/***************************************************************************
*
* There is an instance of the Volume class for each volume reported
* from vold.
*
* Each volume originates from the /system/etv/vold.fstab file.
*
***************************************************************************/
class Volume : public RefCounted<Volume>
{
public:
Volume(const nsCSubstring &aVolumeName);
typedef long STATE; // States are now defined in nsIVolume.idl
static const char *StateStr(STATE aState) { return NS_VolumeStateStr(aState); }
const char *StateStr() const { return StateStr(mState); }
STATE State() const { return mState; }
const nsCString &Name() const { return mName; }
const char *NameStr() const { return mName.get(); }
// The mount point is the name of the directory where the volume is mounted.
// (i.e. path that leads to the files stored on the volume).
const nsCString &MountPoint() const { return mMountPoint; }
int32_t MountGeneration() const { return mMountGeneration; }
bool IsMountLocked() const { return mMountLocked; }
bool MediaPresent() const { return mMediaPresent; }
typedef mozilla::Observer<Volume *> EventObserver;
typedef mozilla::ObserverList<Volume *> EventObserverList;
// NOTE: that observers must live in the IOThread.
static void RegisterObserver(EventObserver *aObserver);
static void UnregisterObserver(EventObserver *aObserver);
private:
friend class AutoMounter; // Calls StartXxx
friend class nsVolume; // Calls UpdateMountLock
friend class VolumeManager; // Calls HandleVoldResponse
friend class VolumeListCallback; // Calls SetMountPoint, SetState
// The StartXxx functions will queue up a command to the VolumeManager.
// You can queue up as many commands as you like, and aCallback will
// be called as each one completes.
void StartMount(VolumeResponseCallback *aCallback);
void StartUnmount(VolumeResponseCallback *aCallback);
void StartShare(VolumeResponseCallback *aCallback);
void StartUnshare(VolumeResponseCallback *aCallback);
void SetState(STATE aNewState);
void SetMediaPresent(bool aMediaPresent);
void SetMountPoint(const nsCSubstring &aMountPoint);
void StartCommand(VolumeCommand *aCommand);
void HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer &aTokenizer);
static void UpdateMountLock(const nsACString &aVolumeName,
const int32_t &aMountGeneration,
const bool &aMountLocked);
bool mMediaPresent;
STATE mState;
const nsCString mName;
nsCString mMountPoint;
int32_t mMountGeneration;
bool mMountLocked;
static EventObserverList mEventObserverList;
};
} // system
} // mozilla
#endif // mozilla_system_volumemanager_h__