зеркало из https://github.com/mozilla/gecko-dev.git
Bug 785124 - Pt 4 - Whitespace only change. Change "type &var" to "type& var" and ptrs. r=dougt
This commit is contained in:
Родитель
6e678052db
Коммит
0569240c40
|
@ -96,7 +96,7 @@ static const nsDependentCString sAutoVolumeName[] = { NS_LITERAL_CSTRING("sdcard
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ReadSysFile(const char *aFilename, char *aBuf, size_t aBufSize)
|
ReadSysFile(const char* aFilename, char* aBuf, size_t aBufSize)
|
||||||
{
|
{
|
||||||
int fd = open(aFilename, O_RDONLY);
|
int fd = open(aFilename, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -117,7 +117,7 @@ ReadSysFile(const char *aFilename, char *aBuf, size_t aBufSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ReadSysFile(const char *aFilename, bool *aVal)
|
ReadSysFile(const char* aFilename, bool* aVal)
|
||||||
{
|
{
|
||||||
char valBuf[20];
|
char valBuf[20];
|
||||||
if (!ReadSysFile(aFilename, valBuf, sizeof(valBuf))) {
|
if (!ReadSysFile(aFilename, valBuf, sizeof(valBuf))) {
|
||||||
|
@ -133,7 +133,7 @@ ReadSysFile(const char *aFilename, bool *aVal)
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
inline const char *SwitchStateStr(const SwitchEvent &aEvent)
|
inline const char* SwitchStateStr(const SwitchEvent& aEvent)
|
||||||
{
|
{
|
||||||
return aEvent.status() == SWITCH_STATE_ON ? "plugged" : "unplugged";
|
return aEvent.status() == SWITCH_STATE_ON ? "plugged" : "unplugged";
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ IsUsbCablePluggedIn()
|
||||||
class AutoVolumeManagerStateObserver : public VolumeManager::StateObserver
|
class AutoVolumeManagerStateObserver : public VolumeManager::StateObserver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Notify(const VolumeManager::StateChangedEvent &aEvent);
|
virtual void Notify(const VolumeManager::StateChangedEvent& aEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The AutoVolumeEventObserver allows the AutoMounter to know about card
|
// The AutoVolumeEventObserver allows the AutoMounter to know about card
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
class AutoVolumeEventObserver : public Volume::EventObserver
|
class AutoVolumeEventObserver : public Volume::EventObserver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Notify(Volume * const &aEvent);
|
virtual void Notify(Volume * const & aEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
class AutoMounterResponseCallback : public VolumeResponseCallback
|
class AutoMounterResponseCallback : public VolumeResponseCallback
|
||||||
|
@ -188,7 +188,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ResponseReceived(const VolumeCommand *aCommand);
|
virtual void ResponseReceived(const VolumeCommand* aCommand);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const static int kMaxErrorCount = 3; // Max number of errors before we give up
|
const static int kMaxErrorCount = 3; // Max number of errors before we give up
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
|
|
||||||
void UpdateState();
|
void UpdateState();
|
||||||
|
|
||||||
const char *ModeStr(int32_t aMode)
|
const char* ModeStr(int32_t aMode)
|
||||||
{
|
{
|
||||||
switch (aMode) {
|
switch (aMode) {
|
||||||
case AUTOMOUNTER_DISABLE: return "Disable";
|
case AUTOMOUNTER_DISABLE: return "Disable";
|
||||||
|
@ -313,7 +313,7 @@ AutoVolumeEventObserver::Notify(Volume * const &)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AutoMounterResponseCallback::ResponseReceived(const VolumeCommand *aCommand)
|
AutoMounterResponseCallback::ResponseReceived(const VolumeCommand* aCommand)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (WasSuccessful()) {
|
if (WasSuccessful()) {
|
||||||
|
@ -487,7 +487,7 @@ ShutdownAutoMounterIOThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SetAutoMounterModeIOThread(const int32_t &aMode)
|
SetAutoMounterModeIOThread(const int32_t& aMode)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
||||||
MOZ_ASSERT(sAutoMounter);
|
MOZ_ASSERT(sAutoMounter);
|
||||||
|
@ -530,7 +530,7 @@ public:
|
||||||
UnregisterSwitchObserver(SWITCH_USB, this);
|
UnregisterSwitchObserver(SWITCH_USB, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Notify(const SwitchEvent &aEvent)
|
virtual void Notify(const SwitchEvent& aEvent)
|
||||||
{
|
{
|
||||||
DBG("UsbCable switch device: %d state: %s\n",
|
DBG("UsbCable switch device: %d state: %s\n",
|
||||||
aEvent.device(), SwitchStateStr(aEvent));
|
aEvent.device(), SwitchStateStr(aEvent));
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
SettingsServiceCallback() {}
|
SettingsServiceCallback() {}
|
||||||
|
|
||||||
NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult) {
|
NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult) {
|
||||||
if (JSVAL_IS_INT(aResult)) {
|
if (JSVAL_IS_INT(aResult)) {
|
||||||
int32_t mode = JSVAL_TO_INT(aResult);
|
int32_t mode = JSVAL_TO_INT(aResult);
|
||||||
SetAutoMounterMode(mode);
|
SetAutoMounterMode(mode);
|
||||||
|
@ -43,7 +43,7 @@ public:
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHOD HandleError(const nsAString &aName) {
|
NS_IMETHOD HandleError(const nsAString& aName) {
|
||||||
ERR("SettingsCallback::HandleError: %s\n", NS_LossyConvertUTF16toASCII(aName).get());
|
ERR("SettingsCallback::HandleError: %s\n", NS_LossyConvertUTF16toASCII(aName).get());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,9 @@ AutoMounterSetting::~AutoMounterSetting()
|
||||||
NS_IMPL_ISUPPORTS1(AutoMounterSetting, nsIObserver)
|
NS_IMPL_ISUPPORTS1(AutoMounterSetting, nsIObserver)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
AutoMounterSetting::Observe(nsISupports *aSubject,
|
AutoMounterSetting::Observe(nsISupports* aSubject,
|
||||||
const char *aTopic,
|
const char* aTopic,
|
||||||
const PRUnichar *aData)
|
const PRUnichar* aData)
|
||||||
{
|
{
|
||||||
if (strcmp(aTopic, MOZSETTINGS_CHANGED) != 0) {
|
if (strcmp(aTopic, MOZSETTINGS_CHANGED) != 0) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -115,7 +115,7 @@ AutoMounterSetting::Observe(nsISupports *aSubject,
|
||||||
ERR("Failed to get JSContextStack");
|
ERR("Failed to get JSContextStack");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
JSContext *cx = stack->GetSafeJSContext();
|
JSContext* cx = stack->GetSafeJSContext();
|
||||||
if (!cx) {
|
if (!cx) {
|
||||||
ERR("Failed to GetSafeJSContext");
|
ERR("Failed to GetSafeJSContext");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -126,7 +126,7 @@ AutoMounterSetting::Observe(nsISupports *aSubject,
|
||||||
!val.isObject()) {
|
!val.isObject()) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
JSObject &obj(val.toObject());
|
JSObject& obj(val.toObject());
|
||||||
JS::Value key;
|
JS::Value key;
|
||||||
if (!JS_GetProperty(cx, &obj, "key", &key) ||
|
if (!JS_GetProperty(cx, &obj, "key", &key) ||
|
||||||
!key.isString()) {
|
!key.isString()) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ static int32_t sMountGeneration = 0;
|
||||||
|
|
||||||
// We don't get media inserted/removed events at startup. So we
|
// We don't get media inserted/removed events at startup. So we
|
||||||
// assume it's present, and we'll be told that it's missing.
|
// assume it's present, and we'll be told that it's missing.
|
||||||
Volume::Volume(const nsCSubstring &aName)
|
Volume::Volume(const nsCSubstring& aName)
|
||||||
: mMediaPresent(true),
|
: mMediaPresent(true),
|
||||||
mState(nsIVolume::STATE_INIT),
|
mState(nsIVolume::STATE_INIT),
|
||||||
mName(aName),
|
mName(aName),
|
||||||
|
@ -125,7 +125,7 @@ Volume::SetState(Volume::STATE aNewState)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::SetMountPoint(const nsCSubstring &aMountPoint)
|
Volume::SetMountPoint(const nsCSubstring& aMountPoint)
|
||||||
{
|
{
|
||||||
if (mMountPoint.Equals(aMountPoint)) {
|
if (mMountPoint.Equals(aMountPoint)) {
|
||||||
return;
|
return;
|
||||||
|
@ -135,38 +135,38 @@ Volume::SetMountPoint(const nsCSubstring &aMountPoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::StartMount(VolumeResponseCallback *aCallback)
|
Volume::StartMount(VolumeResponseCallback* aCallback)
|
||||||
{
|
{
|
||||||
StartCommand(new VolumeActionCommand(this, "mount", "", aCallback));
|
StartCommand(new VolumeActionCommand(this, "mount", "", aCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::StartUnmount(VolumeResponseCallback *aCallback)
|
Volume::StartUnmount(VolumeResponseCallback* aCallback)
|
||||||
{
|
{
|
||||||
StartCommand(new VolumeActionCommand(this, "unmount", "force", aCallback));
|
StartCommand(new VolumeActionCommand(this, "unmount", "force", aCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::StartShare(VolumeResponseCallback *aCallback)
|
Volume::StartShare(VolumeResponseCallback* aCallback)
|
||||||
{
|
{
|
||||||
StartCommand(new VolumeActionCommand(this, "share", "ums", aCallback));
|
StartCommand(new VolumeActionCommand(this, "share", "ums", aCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::StartUnshare(VolumeResponseCallback *aCallback)
|
Volume::StartUnshare(VolumeResponseCallback* aCallback)
|
||||||
{
|
{
|
||||||
StartCommand(new VolumeActionCommand(this, "unshare", "ums", aCallback));
|
StartCommand(new VolumeActionCommand(this, "unshare", "ums", aCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::StartCommand(VolumeCommand *aCommand)
|
Volume::StartCommand(VolumeCommand* aCommand)
|
||||||
{
|
{
|
||||||
VolumeManager::PostCommand(aCommand);
|
VolumeManager::PostCommand(aCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void
|
void
|
||||||
Volume::RegisterObserver(Volume::EventObserver *aObserver)
|
Volume::RegisterObserver(Volume::EventObserver* aObserver)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ Volume::RegisterObserver(Volume::EventObserver *aObserver)
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void
|
void
|
||||||
Volume::UnregisterObserver(Volume::EventObserver *aObserver)
|
Volume::UnregisterObserver(Volume::EventObserver* aObserver)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
||||||
|
|
||||||
|
@ -190,9 +190,9 @@ Volume::UnregisterObserver(Volume::EventObserver *aObserver)
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void
|
void
|
||||||
Volume::UpdateMountLock(const nsACString &aVolumeName,
|
Volume::UpdateMountLock(const nsACString& aVolumeName,
|
||||||
const int32_t &aMountGeneration,
|
const int32_t& aMountGeneration,
|
||||||
const bool &aMountLocked)
|
const bool& aMountLocked)
|
||||||
{
|
{
|
||||||
RefPtr<Volume> vol = VolumeManager::FindVolumeByName(aVolumeName);
|
RefPtr<Volume> vol = VolumeManager::FindVolumeByName(aVolumeName);
|
||||||
if (!vol || (vol->mMountGeneration != aMountGeneration)) {
|
if (!vol || (vol->mMountGeneration != aMountGeneration)) {
|
||||||
|
@ -206,7 +206,7 @@ Volume::UpdateMountLock(const nsACString &aVolumeName,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Volume::HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer &aTokenizer)
|
Volume::HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer& aTokenizer)
|
||||||
{
|
{
|
||||||
// The volume name will have already been parsed, and the tokenizer will point
|
// The volume name will have already been parsed, and the tokenizer will point
|
||||||
// to the token after the volume name
|
// to the token after the volume name
|
||||||
|
|
|
@ -27,20 +27,20 @@ namespace system {
|
||||||
class Volume : public RefCounted<Volume>
|
class Volume : public RefCounted<Volume>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Volume(const nsCSubstring &aVolumeName);
|
Volume(const nsCSubstring& aVolumeName);
|
||||||
|
|
||||||
typedef long STATE; // States are now defined in nsIVolume.idl
|
typedef long STATE; // States are now defined in nsIVolume.idl
|
||||||
|
|
||||||
static const char *StateStr(STATE aState) { return NS_VolumeStateStr(aState); }
|
static const char* StateStr(STATE aState) { return NS_VolumeStateStr(aState); }
|
||||||
const char *StateStr() const { return StateStr(mState); }
|
const char* StateStr() const { return StateStr(mState); }
|
||||||
STATE State() const { return mState; }
|
STATE State() const { return mState; }
|
||||||
|
|
||||||
const nsCString &Name() const { return mName; }
|
const nsCString& Name() const { return mName; }
|
||||||
const char *NameStr() const { return mName.get(); }
|
const char* NameStr() const { return mName.get(); }
|
||||||
|
|
||||||
// The mount point is the name of the directory where the volume is mounted.
|
// 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).
|
// (i.e. path that leads to the files stored on the volume).
|
||||||
const nsCString &MountPoint() const { return mMountPoint; }
|
const nsCString& MountPoint() const { return mMountPoint; }
|
||||||
|
|
||||||
int32_t MountGeneration() const { return mMountGeneration; }
|
int32_t MountGeneration() const { return mMountGeneration; }
|
||||||
bool IsMountLocked() const { return mMountLocked; }
|
bool IsMountLocked() const { return mMountLocked; }
|
||||||
|
@ -50,8 +50,8 @@ public:
|
||||||
typedef mozilla::ObserverList<Volume *> EventObserverList;
|
typedef mozilla::ObserverList<Volume *> EventObserverList;
|
||||||
|
|
||||||
// NOTE: that observers must live in the IOThread.
|
// NOTE: that observers must live in the IOThread.
|
||||||
static void RegisterObserver(EventObserver *aObserver);
|
static void RegisterObserver(EventObserver* aObserver);
|
||||||
static void UnregisterObserver(EventObserver *aObserver);
|
static void UnregisterObserver(EventObserver* aObserver);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AutoMounter; // Calls StartXxx
|
friend class AutoMounter; // Calls StartXxx
|
||||||
|
@ -62,21 +62,21 @@ private:
|
||||||
// The StartXxx functions will queue up a command to the VolumeManager.
|
// The StartXxx functions will queue up a command to the VolumeManager.
|
||||||
// You can queue up as many commands as you like, and aCallback will
|
// You can queue up as many commands as you like, and aCallback will
|
||||||
// be called as each one completes.
|
// be called as each one completes.
|
||||||
void StartMount(VolumeResponseCallback *aCallback);
|
void StartMount(VolumeResponseCallback* aCallback);
|
||||||
void StartUnmount(VolumeResponseCallback *aCallback);
|
void StartUnmount(VolumeResponseCallback* aCallback);
|
||||||
void StartShare(VolumeResponseCallback *aCallback);
|
void StartShare(VolumeResponseCallback* aCallback);
|
||||||
void StartUnshare(VolumeResponseCallback *aCallback);
|
void StartUnshare(VolumeResponseCallback* aCallback);
|
||||||
|
|
||||||
void SetState(STATE aNewState);
|
void SetState(STATE aNewState);
|
||||||
void SetMediaPresent(bool aMediaPresent);
|
void SetMediaPresent(bool aMediaPresent);
|
||||||
void SetMountPoint(const nsCSubstring &aMountPoint);
|
void SetMountPoint(const nsCSubstring& aMountPoint);
|
||||||
void StartCommand(VolumeCommand *aCommand);
|
void StartCommand(VolumeCommand* aCommand);
|
||||||
|
|
||||||
void HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer &aTokenizer);
|
void HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer& aTokenizer);
|
||||||
|
|
||||||
static void UpdateMountLock(const nsACString &aVolumeName,
|
static void UpdateMountLock(const nsACString& aVolumeName,
|
||||||
const int32_t &aMountGeneration,
|
const int32_t& aMountGeneration,
|
||||||
const bool &aMountLocked);
|
const bool& aMountLocked);
|
||||||
|
|
||||||
bool mMediaPresent;
|
bool mMediaPresent;
|
||||||
STATE mState;
|
STATE mState;
|
||||||
|
|
|
@ -39,10 +39,10 @@ namespace system {
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
VolumeActionCommand::VolumeActionCommand(Volume *aVolume,
|
VolumeActionCommand::VolumeActionCommand(Volume* aVolume,
|
||||||
const char *aAction,
|
const char* aAction,
|
||||||
const char *aExtraArgs,
|
const char* aExtraArgs,
|
||||||
VolumeResponseCallback *aCallback)
|
VolumeResponseCallback* aCallback)
|
||||||
: VolumeCommand(aCallback),
|
: VolumeCommand(aCallback),
|
||||||
mVolume(aVolume)
|
mVolume(aVolume)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ VolumeActionCommand::VolumeActionCommand(Volume *aVolume,
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
VolumeListCommand::VolumeListCommand(VolumeResponseCallback *aCallback)
|
VolumeListCommand::VolumeListCommand(VolumeResponseCallback* aCallback)
|
||||||
: VolumeCommand(NS_LITERAL_CSTRING("volume list"), aCallback)
|
: VolumeCommand(NS_LITERAL_CSTRING("volume list"), aCallback)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,14 +59,14 @@ public:
|
||||||
const nsCString &ResponseStr() const { return mResponseStr; }
|
const nsCString &ResponseStr() const { return mResponseStr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ResponseReceived(const VolumeCommand *aCommand) = 0;
|
virtual void ResponseReceived(const VolumeCommand* aCommand) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class VolumeCommand; // Calls HandleResponse and SetPending
|
friend class VolumeCommand; // Calls HandleResponse and SetPending
|
||||||
|
|
||||||
void HandleResponse(const VolumeCommand *aCommand,
|
void HandleResponse(const VolumeCommand* aCommand,
|
||||||
int aResponseCode,
|
int aResponseCode,
|
||||||
nsACString &aResponseStr)
|
nsACString& aResponseStr)
|
||||||
{
|
{
|
||||||
mResponseCode = aResponseCode;
|
mResponseCode = aResponseCode;
|
||||||
mResponseStr = aResponseStr;
|
mResponseStr = aResponseStr;
|
||||||
|
@ -102,14 +102,14 @@ private:
|
||||||
class VolumeCommand : public RefCounted<VolumeCommand>
|
class VolumeCommand : public RefCounted<VolumeCommand>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VolumeCommand(VolumeResponseCallback *aCallback)
|
VolumeCommand(VolumeResponseCallback* aCallback)
|
||||||
: mBytesConsumed(0),
|
: mBytesConsumed(0),
|
||||||
mCallback(aCallback)
|
mCallback(aCallback)
|
||||||
{
|
{
|
||||||
SetCmd(NS_LITERAL_CSTRING(""));
|
SetCmd(NS_LITERAL_CSTRING(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumeCommand(const nsACString &aCommand, VolumeResponseCallback *aCallback)
|
VolumeCommand(const nsACString& aCommand, VolumeResponseCallback* aCallback)
|
||||||
: mBytesConsumed(0),
|
: mBytesConsumed(0),
|
||||||
mCallback(aCallback)
|
mCallback(aCallback)
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ public:
|
||||||
|
|
||||||
virtual ~VolumeCommand() {}
|
virtual ~VolumeCommand() {}
|
||||||
|
|
||||||
void SetCmd(const nsACString &aCommand)
|
void SetCmd(const nsACString& aCommand)
|
||||||
{
|
{
|
||||||
mCmd = aCommand;
|
mCmd = aCommand;
|
||||||
// Add a null character. We want this to be included in the length since
|
// Add a null character. We want this to be included in the length since
|
||||||
|
@ -126,8 +126,8 @@ public:
|
||||||
mCmd.Append('\0');
|
mCmd.Append('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CmdStr() const { return mCmd.get(); }
|
const char* CmdStr() const { return mCmd.get(); }
|
||||||
const char *Data() const { return mCmd.Data() + mBytesConsumed; }
|
const char* Data() const { return mCmd.Data() + mBytesConsumed; }
|
||||||
size_t BytesConsumed() const { return mBytesConsumed; }
|
size_t BytesConsumed() const { return mBytesConsumed; }
|
||||||
|
|
||||||
size_t BytesRemaining() const
|
size_t BytesRemaining() const
|
||||||
|
@ -150,7 +150,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleResponse(int aResponseCode, nsACString &aResponseStr)
|
void HandleResponse(int aResponseCode, nsACString& aResponseStr)
|
||||||
{
|
{
|
||||||
if (mCallback) {
|
if (mCallback) {
|
||||||
mCallback->HandleResponse(this, aResponseCode, aResponseStr);
|
mCallback->HandleResponse(this, aResponseCode, aResponseStr);
|
||||||
|
@ -167,8 +167,8 @@ private:
|
||||||
class VolumeActionCommand : public VolumeCommand
|
class VolumeActionCommand : public VolumeCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VolumeActionCommand(Volume *aVolume, const char *aAction,
|
VolumeActionCommand(Volume* aVolume, const char* aAction,
|
||||||
const char *aExtraArgs, VolumeResponseCallback *aCallback);
|
const char* aExtraArgs, VolumeResponseCallback* aCallback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<Volume> mVolume;
|
RefPtr<Volume> mVolume;
|
||||||
|
@ -177,7 +177,7 @@ private:
|
||||||
class VolumeListCommand : public VolumeCommand
|
class VolumeListCommand : public VolumeCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VolumeListCommand(VolumeResponseCallback *aCallback);
|
VolumeListCommand(VolumeResponseCallback* aCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // system
|
} // system
|
||||||
|
|
|
@ -95,20 +95,20 @@ VolumeManager::SetState(STATE aNewState)
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void
|
void
|
||||||
VolumeManager::RegisterStateObserver(StateObserver *aObserver)
|
VolumeManager::RegisterStateObserver(StateObserver* aObserver)
|
||||||
{
|
{
|
||||||
mStateObserverList.AddObserver(aObserver);
|
mStateObserverList.AddObserver(aObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void VolumeManager::UnregisterStateObserver(StateObserver *aObserver)
|
void VolumeManager::UnregisterStateObserver(StateObserver* aObserver)
|
||||||
{
|
{
|
||||||
mStateObserverList.RemoveObserver(aObserver);
|
mStateObserverList.RemoveObserver(aObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
TemporaryRef<Volume>
|
TemporaryRef<Volume>
|
||||||
VolumeManager::FindVolumeByName(const nsCSubstring &aName)
|
VolumeManager::FindVolumeByName(const nsCSubstring& aName)
|
||||||
{
|
{
|
||||||
if (!sVolumeManager) {
|
if (!sVolumeManager) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -126,7 +126,7 @@ VolumeManager::FindVolumeByName(const nsCSubstring &aName)
|
||||||
|
|
||||||
//static
|
//static
|
||||||
TemporaryRef<Volume>
|
TemporaryRef<Volume>
|
||||||
VolumeManager::FindAddVolumeByName(const nsCSubstring &aName)
|
VolumeManager::FindAddVolumeByName(const nsCSubstring& aName)
|
||||||
{
|
{
|
||||||
RefPtr<Volume> vol = FindVolumeByName(aName);
|
RefPtr<Volume> vol = FindVolumeByName(aName);
|
||||||
if (vol) {
|
if (vol) {
|
||||||
|
@ -140,7 +140,7 @@ VolumeManager::FindAddVolumeByName(const nsCSubstring &aName)
|
||||||
|
|
||||||
class VolumeListCallback : public VolumeResponseCallback
|
class VolumeListCallback : public VolumeResponseCallback
|
||||||
{
|
{
|
||||||
virtual void ResponseReceived(const VolumeCommand *aCommand)
|
virtual void ResponseReceived(const VolumeCommand* aCommand)
|
||||||
{
|
{
|
||||||
switch (ResponseCode()) {
|
switch (ResponseCode()) {
|
||||||
case ResponseCode::VolumeListResult: {
|
case ResponseCode::VolumeListResult: {
|
||||||
|
@ -206,7 +206,7 @@ VolumeManager::OpenSocket()
|
||||||
|
|
||||||
//static
|
//static
|
||||||
void
|
void
|
||||||
VolumeManager::PostCommand(VolumeCommand *aCommand)
|
VolumeManager::PostCommand(VolumeCommand* aCommand)
|
||||||
{
|
{
|
||||||
if (!sVolumeManager) {
|
if (!sVolumeManager) {
|
||||||
ERR("VolumeManager not initialized. Dropping command '%s'", aCommand->Data());
|
ERR("VolumeManager not initialized. Dropping command '%s'", aCommand->Data());
|
||||||
|
@ -241,7 +241,7 @@ VolumeManager::WriteCommandData()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumeCommand *cmd = mCommands.front();
|
VolumeCommand* cmd = mCommands.front();
|
||||||
if (cmd->BytesRemaining() == 0) {
|
if (cmd->BytesRemaining() == 0) {
|
||||||
// All bytes have been written. We're waiting for a response.
|
// All bytes have been written. We're waiting for a response.
|
||||||
return;
|
return;
|
||||||
|
@ -275,7 +275,7 @@ void
|
||||||
VolumeManager::OnLineRead(int aFd, nsDependentCSubstring& aMessage)
|
VolumeManager::OnLineRead(int aFd, nsDependentCSubstring& aMessage)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aFd == mSocket.get());
|
MOZ_ASSERT(aFd == mSocket.get());
|
||||||
char *endPtr;
|
char* endPtr;
|
||||||
int responseCode = strtol(aMessage.Data(), &endPtr, 10);
|
int responseCode = strtol(aMessage.Data(), &endPtr, 10);
|
||||||
if (*endPtr == ' ') {
|
if (*endPtr == ' ') {
|
||||||
endPtr++;
|
endPtr++;
|
||||||
|
@ -292,7 +292,7 @@ VolumeManager::OnLineRead(int aFd, nsDependentCSubstring& aMessage)
|
||||||
} else {
|
} else {
|
||||||
// Everything else is considered to be part of the command response.
|
// Everything else is considered to be part of the command response.
|
||||||
if (mCommands.size() > 0) {
|
if (mCommands.size() > 0) {
|
||||||
VolumeCommand *cmd = mCommands.front();
|
VolumeCommand* cmd = mCommands.front();
|
||||||
cmd->HandleResponse(responseCode, responseLine);
|
cmd->HandleResponse(responseCode, responseLine);
|
||||||
if (responseCode >= ResponseCode::CommandOkay) {
|
if (responseCode >= ResponseCode::CommandOkay) {
|
||||||
// That's a terminating response. We can remove the command.
|
// That's a terminating response. We can remove the command.
|
||||||
|
@ -315,7 +315,7 @@ VolumeManager::OnFileCanWriteWithoutBlocking(int aFd)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeManager::HandleBroadcast(int aResponseCode, nsCString &aResponseLine)
|
VolumeManager::HandleBroadcast(int aResponseCode, nsCString& aResponseLine)
|
||||||
{
|
{
|
||||||
// Format of the line is something like:
|
// Format of the line is something like:
|
||||||
//
|
//
|
||||||
|
|
|
@ -103,8 +103,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static STATE State();
|
static STATE State();
|
||||||
static const char *StateStr(STATE aState);
|
static const char* StateStr(STATE aState);
|
||||||
static const char *StateStr() { return StateStr(State()); }
|
static const char* StateStr() { return StateStr(State()); }
|
||||||
|
|
||||||
class StateChangedEvent
|
class StateChangedEvent
|
||||||
{
|
{
|
||||||
|
@ -115,8 +115,8 @@ public:
|
||||||
typedef mozilla::Observer<StateChangedEvent> StateObserver;
|
typedef mozilla::Observer<StateChangedEvent> StateObserver;
|
||||||
typedef mozilla::ObserverList<StateChangedEvent> StateObserverList;
|
typedef mozilla::ObserverList<StateChangedEvent> StateObserverList;
|
||||||
|
|
||||||
static void RegisterStateObserver(StateObserver *aObserver);
|
static void RegisterStateObserver(StateObserver* aObserver);
|
||||||
static void UnregisterStateObserver(StateObserver *aObserver);
|
static void UnregisterStateObserver(StateObserver* aObserver);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -124,10 +124,10 @@ public:
|
||||||
|
|
||||||
static VolumeArray::size_type NumVolumes();
|
static VolumeArray::size_type NumVolumes();
|
||||||
static TemporaryRef<Volume> GetVolume(VolumeArray::index_type aIndex);
|
static TemporaryRef<Volume> GetVolume(VolumeArray::index_type aIndex);
|
||||||
static TemporaryRef<Volume> FindVolumeByName(const nsCSubstring &aName);
|
static TemporaryRef<Volume> FindVolumeByName(const nsCSubstring& aName);
|
||||||
static TemporaryRef<Volume> FindAddVolumeByName(const nsCSubstring &aName);
|
static TemporaryRef<Volume> FindAddVolumeByName(const nsCSubstring& aName);
|
||||||
|
|
||||||
static void PostCommand(VolumeCommand *aCommand);
|
static void PostCommand(VolumeCommand* aCommand);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ private:
|
||||||
|
|
||||||
void Restart();
|
void Restart();
|
||||||
void WriteCommandData();
|
void WriteCommandData();
|
||||||
void HandleBroadcast(int aResponseCode, nsCString &aResponseLine);
|
void HandleBroadcast(int aResponseCode, nsCString& aResponseLine);
|
||||||
|
|
||||||
typedef std::queue<RefPtr<VolumeCommand> > CommandQueue;
|
typedef std::queue<RefPtr<VolumeCommand> > CommandQueue;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace system {
|
namespace system {
|
||||||
|
|
||||||
VolumeServiceIOThread::VolumeServiceIOThread(nsVolumeService *aVolumeService)
|
VolumeServiceIOThread::VolumeServiceIOThread(nsVolumeService* aVolumeService)
|
||||||
: mVolumeService(aVolumeService)
|
: mVolumeService(aVolumeService)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
||||||
|
@ -30,7 +30,7 @@ VolumeServiceIOThread::~VolumeServiceIOThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeServiceIOThread::Notify(Volume * const &aVolume)
|
VolumeServiceIOThread::Notify(Volume* const & aVolume)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
||||||
if (VolumeManager::State() != VolumeManager::VOLUMES_READY) {
|
if (VolumeManager::State() != VolumeManager::VOLUMES_READY) {
|
||||||
|
@ -40,7 +40,7 @@ VolumeServiceIOThread::Notify(Volume * const &aVolume)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VolumeServiceIOThread::Notify(const VolumeManager::StateChangedEvent &aEvent)
|
VolumeServiceIOThread::Notify(const VolumeManager::StateChangedEvent& aEvent)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
||||||
UpdateAllVolumes();
|
UpdateAllVolumes();
|
||||||
|
@ -65,7 +65,7 @@ VolumeServiceIOThread::UpdateAllVolumes()
|
||||||
static StaticRefPtr<VolumeServiceIOThread> sVolumeServiceIOThread;
|
static StaticRefPtr<VolumeServiceIOThread> sVolumeServiceIOThread;
|
||||||
|
|
||||||
void
|
void
|
||||||
InitVolumeServiceIOThread(nsVolumeService * const &aVolumeService)
|
InitVolumeServiceIOThread(nsVolumeService* const & aVolumeService)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
|
||||||
sVolumeServiceIOThread = new VolumeServiceIOThread(aVolumeService);
|
sVolumeServiceIOThread = new VolumeServiceIOThread(aVolumeService);
|
||||||
|
|
|
@ -23,19 +23,19 @@ class VolumeServiceIOThread : public VolumeManager::StateObserver,
|
||||||
public RefCounted<VolumeServiceIOThread>
|
public RefCounted<VolumeServiceIOThread>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VolumeServiceIOThread(nsVolumeService *aVolumeService);
|
VolumeServiceIOThread(nsVolumeService* aVolumeService);
|
||||||
~VolumeServiceIOThread();
|
~VolumeServiceIOThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateAllVolumes();
|
void UpdateAllVolumes();
|
||||||
|
|
||||||
virtual void Notify(const VolumeManager::StateChangedEvent &aEvent);
|
virtual void Notify(const VolumeManager::StateChangedEvent& aEvent);
|
||||||
virtual void Notify(Volume * const &aVolume);
|
virtual void Notify(Volume* const & aVolume);
|
||||||
|
|
||||||
RefPtr<nsVolumeService> mVolumeService;
|
RefPtr<nsVolumeService> mVolumeService;
|
||||||
};
|
};
|
||||||
|
|
||||||
void InitVolumeServiceIOThread(nsVolumeService * const &aVolumeService);
|
void InitVolumeServiceIOThread(nsVolumeService* const & aVolumeService);
|
||||||
void ShutdownVolumeServiceIOThread();
|
void ShutdownVolumeServiceIOThread();
|
||||||
|
|
||||||
} // system
|
} // system
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
obs->RemoveObserver(this, NS_VOLUME_STATE_CHANGED);
|
obs->RemoveObserver(this, NS_VOLUME_STATE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogVolume(nsIVolume *vol)
|
void LogVolume(nsIVolume* vol)
|
||||||
{
|
{
|
||||||
nsString volName;
|
nsString volName;
|
||||||
nsString mountPoint;
|
nsString mountPoint;
|
||||||
|
@ -92,9 +92,9 @@ static nsCOMPtr<VolumeTestObserver> sTestObserver;
|
||||||
NS_IMPL_ISUPPORTS1(VolumeTestObserver, nsIObserver)
|
NS_IMPL_ISUPPORTS1(VolumeTestObserver, nsIObserver)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
VolumeTestObserver::Observe(nsISupports *aSubject,
|
VolumeTestObserver::Observe(nsISupports* aSubject,
|
||||||
const char *aTopic,
|
const char* aTopic,
|
||||||
const PRUnichar *aData)
|
const PRUnichar* aData)
|
||||||
{
|
{
|
||||||
LOG("TestObserver: topic: %s", aTopic);
|
LOG("TestObserver: topic: %s", aTopic);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace mozilla {
|
||||||
namespace system {
|
namespace system {
|
||||||
|
|
||||||
// Convert a state into a loggable/printable string.
|
// Convert a state into a loggable/printable string.
|
||||||
const char *NS_VolumeStateStr(int32_t aState);
|
const char* NS_VolumeStateStr(int32_t aState);
|
||||||
|
|
||||||
} // system
|
} // system
|
||||||
} // mozilla
|
} // mozilla
|
||||||
|
|
|
@ -40,7 +40,7 @@ NS_VolumeStateStr(int32_t aState)
|
||||||
|
|
||||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsVolume, nsIVolume)
|
NS_IMPL_THREADSAFE_ISUPPORTS1(nsVolume, nsIVolume)
|
||||||
|
|
||||||
nsVolume::nsVolume(const Volume *aVolume)
|
nsVolume::nsVolume(const Volume* aVolume)
|
||||||
: mName(NS_ConvertUTF8toUTF16(aVolume->Name())),
|
: mName(NS_ConvertUTF8toUTF16(aVolume->Name())),
|
||||||
mMountPoint(NS_ConvertUTF8toUTF16(aVolume->MountPoint())),
|
mMountPoint(NS_ConvertUTF8toUTF16(aVolume->MountPoint())),
|
||||||
mState(aVolume->State()),
|
mState(aVolume->State()),
|
||||||
|
@ -49,19 +49,19 @@ nsVolume::nsVolume(const Volume *aVolume)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolume::GetName(nsAString &aName)
|
NS_IMETHODIMP nsVolume::GetName(nsAString& aName)
|
||||||
{
|
{
|
||||||
aName = mName;
|
aName = mName;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolume::GetMountGeneration(int32_t *aMountGeneration)
|
NS_IMETHODIMP nsVolume::GetMountGeneration(int32_t* aMountGeneration)
|
||||||
{
|
{
|
||||||
*aMountGeneration = mMountGeneration;
|
*aMountGeneration = mMountGeneration;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolume::GetMountLockName(nsAString &aMountLockName)
|
NS_IMETHODIMP nsVolume::GetMountLockName(nsAString& aMountLockName)
|
||||||
{
|
{
|
||||||
aMountLockName = NS_LITERAL_STRING("volume-") + Name();
|
aMountLockName = NS_LITERAL_STRING("volume-") + Name();
|
||||||
aMountLockName.AppendPrintf("-%d", mMountGeneration);
|
aMountLockName.AppendPrintf("-%d", mMountGeneration);
|
||||||
|
@ -69,13 +69,13 @@ NS_IMETHODIMP nsVolume::GetMountLockName(nsAString &aMountLockName)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolume::GetMountPoint(nsAString &aMountPoint)
|
NS_IMETHODIMP nsVolume::GetMountPoint(nsAString& aMountPoint)
|
||||||
{
|
{
|
||||||
aMountPoint = mMountPoint;
|
aMountPoint = mMountPoint;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolume::GetState(int32_t *aState)
|
NS_IMETHODIMP nsVolume::GetState(int32_t* aState)
|
||||||
{
|
{
|
||||||
*aState = mState;
|
*aState = mState;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -104,7 +104,7 @@ nsVolume::LogState() const
|
||||||
LOG("nsVolume: %s state %s", NameStr(), StateStr());
|
LOG("nsVolume: %s state %s", NameStr(), StateStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsVolume::Set(const nsVolume *aVolume)
|
void nsVolume::Set(const nsVolume* aVolume)
|
||||||
{
|
{
|
||||||
mName = aVolume->mName;
|
mName = aVolume->mName;
|
||||||
mMountPoint = aVolume->mMountPoint;
|
mMountPoint = aVolume->mMountPoint;
|
||||||
|
@ -137,7 +137,7 @@ void nsVolume::Set(const nsVolume *aVolume)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsVolume::UpdateMountLock(const nsAString &aMountLockState)
|
nsVolume::UpdateMountLock(const nsAString& aMountLockState)
|
||||||
{
|
{
|
||||||
// There are 3 states, unlocked, locked-background, and locked-foreground
|
// There are 3 states, unlocked, locked-background, and locked-foreground
|
||||||
// I figured it was easier to use negtive logic and compare for unlocked.
|
// I figured it was easier to use negtive logic and compare for unlocked.
|
||||||
|
|
|
@ -23,11 +23,11 @@ public:
|
||||||
NS_DECL_NSIVOLUME
|
NS_DECL_NSIVOLUME
|
||||||
|
|
||||||
// This constructor is used by the UpdateVolumeRunnable constructor
|
// This constructor is used by the UpdateVolumeRunnable constructor
|
||||||
nsVolume(const Volume *aVolume);
|
nsVolume(const Volume* aVolume);
|
||||||
|
|
||||||
// This constructor is used by ContentChild::RecvFileSystemUpdate
|
// This constructor is used by ContentChild::RecvFileSystemUpdate
|
||||||
nsVolume(const nsAString &aName, const nsAString &aMountPoint,
|
nsVolume(const nsAString& aName, const nsAString& aMountPoint,
|
||||||
const int32_t &aState, const int32_t &aMountGeneration)
|
const int32_t& aState, const int32_t& aMountGeneration)
|
||||||
: mName(aName),
|
: mName(aName),
|
||||||
mMountPoint(aMountPoint),
|
mMountPoint(aMountPoint),
|
||||||
mState(aState),
|
mState(aState),
|
||||||
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
// This constructor is used by nsVolumeService::FindAddVolumeByName, and
|
// This constructor is used by nsVolumeService::FindAddVolumeByName, and
|
||||||
// will be followed shortly by a Set call.
|
// will be followed shortly by a Set call.
|
||||||
nsVolume(const nsAString &aName)
|
nsVolume(const nsAString& aName)
|
||||||
: mName(aName),
|
: mName(aName),
|
||||||
mState(STATE_INIT),
|
mState(STATE_INIT),
|
||||||
mMountGeneration(-1),
|
mMountGeneration(-1),
|
||||||
|
@ -46,7 +46,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Equals(const nsVolume *aVolume)
|
bool Equals(const nsVolume* aVolume)
|
||||||
{
|
{
|
||||||
return mName.Equals(aVolume->mName)
|
return mName.Equals(aVolume->mName)
|
||||||
&& mMountPoint.Equals(aVolume->mMountPoint)
|
&& mMountPoint.Equals(aVolume->mMountPoint)
|
||||||
|
@ -55,21 +55,21 @@ public:
|
||||||
&& (mMountLocked == aVolume->mMountLocked);
|
&& (mMountLocked == aVolume->mMountLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const nsVolume *aVolume);
|
void Set(const nsVolume* aVolume);
|
||||||
|
|
||||||
void LogState() const;
|
void LogState() const;
|
||||||
|
|
||||||
const nsString &Name() const { return mName; }
|
const nsString& Name() const { return mName; }
|
||||||
const char *NameStr() const { return NS_LossyConvertUTF16toASCII(mName).get(); }
|
const char* NameStr() const { return NS_LossyConvertUTF16toASCII(mName).get(); }
|
||||||
|
|
||||||
int32_t MountGeneration() const { return mMountGeneration; }
|
int32_t MountGeneration() const { return mMountGeneration; }
|
||||||
bool IsMountLocked() const { return mMountLocked; }
|
bool IsMountLocked() const { return mMountLocked; }
|
||||||
|
|
||||||
const nsString &MountPoint() const { return mMountPoint; }
|
const nsString& MountPoint() const { return mMountPoint; }
|
||||||
const char *MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint).get(); }
|
const char* MountPointStr() const { return NS_LossyConvertUTF16toASCII(mMountPoint).get(); }
|
||||||
|
|
||||||
int32_t State() const { return mState; }
|
int32_t State() const { return mState; }
|
||||||
const char *StateStr() const { return NS_VolumeStateStr(mState); }
|
const char* StateStr() const { return NS_VolumeStateStr(mState); }
|
||||||
|
|
||||||
typedef nsTArray<nsRefPtr<nsVolume> > Array;
|
typedef nsTArray<nsRefPtr<nsVolume> > Array;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ private:
|
||||||
~nsVolume() {}
|
~nsVolume() {}
|
||||||
|
|
||||||
friend class nsVolumeService; // Calls the following XxxMountLock functions
|
friend class nsVolumeService; // Calls the following XxxMountLock functions
|
||||||
void UpdateMountLock(const nsAString &aMountLockState);
|
void UpdateMountLock(const nsAString& aMountLockState);
|
||||||
void UpdateMountLock(bool aMountLocked);
|
void UpdateMountLock(bool aMountLocked);
|
||||||
|
|
||||||
nsString mName;
|
nsString mName;
|
||||||
|
|
|
@ -27,7 +27,7 @@ NS_IMPL_ISUPPORTS3(nsVolumeMountLock, nsIVolumeMountLock,
|
||||||
|
|
||||||
// static
|
// static
|
||||||
already_AddRefed<nsVolumeMountLock>
|
already_AddRefed<nsVolumeMountLock>
|
||||||
nsVolumeMountLock::Create(const nsAString &aVolumeName)
|
nsVolumeMountLock::Create(const nsAString& aVolumeName)
|
||||||
{
|
{
|
||||||
DBG("nsVolumeMountLock::Create called");
|
DBG("nsVolumeMountLock::Create called");
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ nsVolumeMountLock::Create(const nsAString &aVolumeName)
|
||||||
return mountLock.forget();
|
return mountLock.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsVolumeMountLock::nsVolumeMountLock(const nsAString &aVolumeName)
|
nsVolumeMountLock::nsVolumeMountLock(const nsAString& aVolumeName)
|
||||||
: mVolumeName(aVolumeName),
|
: mVolumeName(aVolumeName),
|
||||||
mVolumeGeneration(-1),
|
mVolumeGeneration(-1),
|
||||||
mUnlocked(false)
|
mUnlocked(false)
|
||||||
|
@ -92,7 +92,7 @@ NS_IMETHODIMP nsVolumeMountLock::Unlock()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolumeMountLock::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
NS_IMETHODIMP nsVolumeMountLock::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
|
||||||
{
|
{
|
||||||
if (strcmp(aTopic, NS_VOLUME_STATE_CHANGED) != 0) {
|
if (strcmp(aTopic, NS_VOLUME_STATE_CHANGED) != 0) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -31,12 +31,12 @@ public:
|
||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
NS_DECL_NSIVOLUMEMOUNTLOCK
|
NS_DECL_NSIVOLUMEMOUNTLOCK
|
||||||
|
|
||||||
static already_AddRefed<nsVolumeMountLock> Create(const nsAString &volumeName);
|
static already_AddRefed<nsVolumeMountLock> Create(const nsAString& volumeName);
|
||||||
|
|
||||||
const nsString &VolumeName() const { return mVolumeName; }
|
const nsString& VolumeName() const { return mVolumeName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsVolumeMountLock(const nsAString &aVolumeName);
|
nsVolumeMountLock(const nsAString& aVolumeName);
|
||||||
~nsVolumeMountLock();
|
~nsVolumeMountLock();
|
||||||
|
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
|
|
|
@ -108,13 +108,13 @@ nsVolumeService::~nsVolumeService()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback for nsIDOMMozWakeLockListener
|
// Callback for nsIDOMMozWakeLockListener
|
||||||
NS_IMETHODIMP nsVolumeService::Callback(const nsAString &aTopic, const nsAString &aState)
|
NS_IMETHODIMP nsVolumeService::Callback(const nsAString& aTopic, const nsAString& aState)
|
||||||
{
|
{
|
||||||
CheckMountLock(aTopic, aState);
|
CheckMountLock(aTopic, aState);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolumeService::BroadcastVolume(const nsAString &aVolName)
|
NS_IMETHODIMP nsVolumeService::BroadcastVolume(const nsAString& aVolName)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
nsRefPtr<nsVolume> vol = FindVolumeByName(aVolName);
|
nsRefPtr<nsVolume> vol = FindVolumeByName(aVolName);
|
||||||
|
@ -133,7 +133,7 @@ NS_IMETHODIMP nsVolumeService::BroadcastVolume(const nsAString &aVolName)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolumeService::GetVolumeByName(const nsAString &aVolName, nsIVolume **aResult)
|
NS_IMETHODIMP nsVolumeService::GetVolumeByName(const nsAString& aVolName, nsIVolume **aResult)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
nsRefPtr<nsVolume> vol = FindVolumeByName(aVolName);
|
nsRefPtr<nsVolume> vol = FindVolumeByName(aVolName);
|
||||||
|
@ -147,7 +147,7 @@ NS_IMETHODIMP nsVolumeService::GetVolumeByName(const nsAString &aVolName, nsIVol
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolumeService::GetVolumeByPath(const nsAString &aPath, nsIVolume **aResult)
|
NS_IMETHODIMP nsVolumeService::GetVolumeByPath(const nsAString& aPath, nsIVolume **aResult)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
nsCString utf8Path = NS_ConvertUTF16toUTF8(aPath);
|
nsCString utf8Path = NS_ConvertUTF16toUTF8(aPath);
|
||||||
|
@ -190,7 +190,7 @@ NS_IMETHODIMP nsVolumeService::GetVolumeByPath(const nsAString &aPath, nsIVolume
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsVolumeService::CreateMountLock(const nsAString &aVolumeName, nsIVolumeMountLock **aResult)
|
NS_IMETHODIMP nsVolumeService::CreateMountLock(const nsAString& aVolumeName, nsIVolumeMountLock **aResult)
|
||||||
{
|
{
|
||||||
nsRefPtr<nsVolumeMountLock> mountLock = nsVolumeMountLock::Create(aVolumeName);
|
nsRefPtr<nsVolumeMountLock> mountLock = nsVolumeMountLock::Create(aVolumeName);
|
||||||
if (!mountLock) {
|
if (!mountLock) {
|
||||||
|
@ -200,8 +200,8 @@ NS_IMETHODIMP nsVolumeService::CreateMountLock(const nsAString &aVolumeName, nsI
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsVolumeService::CheckMountLock(const nsAString &aMountLockName,
|
void nsVolumeService::CheckMountLock(const nsAString& aMountLockName,
|
||||||
const nsAString &aMountLockState)
|
const nsAString& aMountLockState)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
@ -219,7 +219,7 @@ void nsVolumeService::CheckMountLock(const nsAString &aMountLockName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsVolume> nsVolumeService::FindVolumeByName(const nsAString &aName)
|
already_AddRefed<nsVolume> nsVolumeService::FindVolumeByName(const nsAString& aName)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
@ -236,7 +236,7 @@ already_AddRefed<nsVolume> nsVolumeService::FindVolumeByName(const nsAString &aN
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
already_AddRefed<nsVolume> nsVolumeService::FindAddVolumeByName(const nsAString &aName)
|
already_AddRefed<nsVolume> nsVolumeService::FindAddVolumeByName(const nsAString& aName)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
@ -252,7 +252,7 @@ already_AddRefed<nsVolume> nsVolumeService::FindAddVolumeByName(const nsAString
|
||||||
return vol.forget();
|
return vol.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsVolumeService::UpdateVolume(const nsVolume *aVolume)
|
void nsVolumeService::UpdateVolume(const nsVolume* aVolume)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
@ -278,7 +278,7 @@ void nsVolumeService::UpdateVolume(const nsVolume *aVolume)
|
||||||
class UpdateVolumeRunnable : public nsRunnable
|
class UpdateVolumeRunnable : public nsRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UpdateVolumeRunnable(nsVolumeService *aVolumeService, const Volume *aVolume)
|
UpdateVolumeRunnable(nsVolumeService* aVolumeService, const Volume* aVolume)
|
||||||
: mVolumeService(aVolumeService),
|
: mVolumeService(aVolumeService),
|
||||||
mVolume(new nsVolume(aVolume))
|
mVolume(new nsVolume(aVolume))
|
||||||
{
|
{
|
||||||
|
@ -303,7 +303,7 @@ private:
|
||||||
nsRefPtr<nsVolume> mVolume;
|
nsRefPtr<nsVolume> mVolume;
|
||||||
};
|
};
|
||||||
|
|
||||||
void nsVolumeService::UpdateVolumeIOThread(const Volume *aVolume)
|
void nsVolumeService::UpdateVolumeIOThread(const Volume* aVolume)
|
||||||
{
|
{
|
||||||
DBG("UpdateVolumeIOThread: Volume '%s' state %s mount '%s' gen %d locked %d",
|
DBG("UpdateVolumeIOThread: Volume '%s' state %s mount '%s' gen %d locked %d",
|
||||||
aVolume->NameStr(), aVolume->StateStr(), aVolume->MountPoint().get(),
|
aVolume->NameStr(), aVolume->StateStr(), aVolume->MountPoint().get(),
|
||||||
|
|
|
@ -36,15 +36,15 @@ public:
|
||||||
nsVolumeService();
|
nsVolumeService();
|
||||||
|
|
||||||
static already_AddRefed<nsVolumeService> GetSingleton();
|
static already_AddRefed<nsVolumeService> GetSingleton();
|
||||||
//static nsVolumeService *GetSingleton();
|
//static nsVolumeService* GetSingleton();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
void CheckMountLock(const nsAString &aMountLockName,
|
void CheckMountLock(const nsAString& aMountLockName,
|
||||||
const nsAString &aMountLockState);
|
const nsAString& aMountLockState);
|
||||||
already_AddRefed<nsVolume> FindVolumeByName(const nsAString &aName);
|
already_AddRefed<nsVolume> FindVolumeByName(const nsAString& aName);
|
||||||
already_AddRefed<nsVolume> FindAddVolumeByName(const nsAString &aName);
|
already_AddRefed<nsVolume> FindAddVolumeByName(const nsAString& aName);
|
||||||
void UpdateVolume(const nsVolume *aVolume);
|
void UpdateVolume(const nsVolume* aVolume);
|
||||||
void UpdateVolumeIOThread(const Volume *aVolume);
|
void UpdateVolumeIOThread(const Volume* aVolume);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~nsVolumeService();
|
~nsVolumeService();
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace system {
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsVolumeStat, nsIVolumeStat)
|
NS_IMPL_ISUPPORTS1(nsVolumeStat, nsIVolumeStat)
|
||||||
|
|
||||||
nsVolumeStat::nsVolumeStat(const nsAString &aPath)
|
nsVolumeStat::nsVolumeStat(const nsAString& aPath)
|
||||||
{
|
{
|
||||||
nsCString utf8Path = NS_ConvertUTF16toUTF8(aPath);
|
nsCString utf8Path = NS_ConvertUTF16toUTF8(aPath);
|
||||||
|
|
||||||
|
@ -24,14 +24,14 @@ nsVolumeStat::~nsVolumeStat()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* readonly attribute long long totalBytes; */
|
/* readonly attribute long long totalBytes; */
|
||||||
NS_IMETHODIMP nsVolumeStat::GetTotalBytes(int64_t *aTotalBytes)
|
NS_IMETHODIMP nsVolumeStat::GetTotalBytes(int64_t* aTotalBytes)
|
||||||
{
|
{
|
||||||
*aTotalBytes = mStat.f_blocks * mStat.f_bsize;
|
*aTotalBytes = mStat.f_blocks * mStat.f_bsize;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* readonly attribute long long freeBytes; */
|
/* readonly attribute long long freeBytes; */
|
||||||
NS_IMETHODIMP nsVolumeStat::GetFreeBytes(int64_t *aFreeBytes)
|
NS_IMETHODIMP nsVolumeStat::GetFreeBytes(int64_t* aFreeBytes)
|
||||||
{
|
{
|
||||||
*aFreeBytes = mStat.f_bfree * mStat.f_bsize;
|
*aFreeBytes = mStat.f_bfree * mStat.f_bsize;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIVOLUMESTAT
|
NS_DECL_NSIVOLUMESTAT
|
||||||
|
|
||||||
nsVolumeStat(const nsAString &aPath);
|
nsVolumeStat(const nsAString& aPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~nsVolumeStat();
|
~nsVolumeStat();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче