gecko/dom/system/gonk/VolumeServiceIOThread.cpp
Dave Hylands e9207164c6 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

83 lines
2.2 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/. */
#include "VolumeServiceIOThread.h"
#include "base/message_loop.h"
#include "nsVolumeService.h"
#include "nsXULAppAPI.h"
#include "Volume.h"
#include "VolumeManager.h"
namespace mozilla {
namespace system {
VolumeServiceIOThread::VolumeServiceIOThread(nsVolumeService *aVolumeService)
: mVolumeService(aVolumeService)
{
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
VolumeManager::RegisterStateObserver(this);
Volume::RegisterObserver(this);
UpdateAllVolumes();
}
VolumeServiceIOThread::~VolumeServiceIOThread()
{
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
Volume::UnregisterObserver(this);
VolumeManager::UnregisterStateObserver(this);
}
void
VolumeServiceIOThread::Notify(Volume * const &aVolume)
{
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
if (VolumeManager::State() != VolumeManager::VOLUMES_READY) {
return;
}
mVolumeService->UpdateVolumeIOThread(aVolume);
}
void
VolumeServiceIOThread::Notify(const VolumeManager::StateChangedEvent &aEvent)
{
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
UpdateAllVolumes();
}
void
VolumeServiceIOThread::UpdateAllVolumes()
{
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
if (VolumeManager::State() != VolumeManager::VOLUMES_READY) {
return;
}
VolumeManager::VolumeArray::size_type numVolumes = VolumeManager::NumVolumes();
VolumeManager::VolumeArray::index_type volIndex;
for (volIndex = 0; volIndex < numVolumes; volIndex++) {
RefPtr<Volume> vol = VolumeManager::GetVolume(volIndex);
mVolumeService->UpdateVolumeIOThread(vol);
}
}
static StaticRefPtr<VolumeServiceIOThread> sVolumeServiceIOThread;
void
InitVolumeServiceIOThread(nsVolumeService * const &aVolumeService)
{
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
sVolumeServiceIOThread = new VolumeServiceIOThread(aVolumeService);
}
void
ShutdownVolumeServiceIOThread()
{
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
sVolumeServiceIOThread = NULL;
}
} // system
} // mozilla