Bug 785124 - Pt 5 - Add extra asserts. r=dougt

This commit is contained in:
Dave Hylands 2013-01-07 17:43:02 +01:00
parent 504e434db0
commit a7e4a46c0b
3 changed files with 44 additions and 2 deletions

View File

@ -65,6 +65,9 @@ Volume::Volume(const nsCSubstring& aName)
void
Volume::SetMediaPresent(bool aMediaPresent)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
// mMediaPresent is slightly redunant to the state, however
// when media is removed (while Idle), we get the following:
// 631 Volume sdcard /mnt/sdcard disk removed (179:0)
@ -100,6 +103,9 @@ Volume::SetMediaPresent(bool aMediaPresent)
void
Volume::SetState(Volume::STATE aNewState)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
if (aNewState == mState) {
return;
}
@ -127,6 +133,9 @@ Volume::SetState(Volume::STATE aNewState)
void
Volume::SetMountPoint(const nsCSubstring& aMountPoint)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
if (mMountPoint.Equals(aMountPoint)) {
return;
}
@ -137,30 +146,45 @@ Volume::SetMountPoint(const nsCSubstring& aMountPoint)
void
Volume::StartMount(VolumeResponseCallback* aCallback)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
StartCommand(new VolumeActionCommand(this, "mount", "", aCallback));
}
void
Volume::StartUnmount(VolumeResponseCallback* aCallback)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
StartCommand(new VolumeActionCommand(this, "unmount", "force", aCallback));
}
void
Volume::StartShare(VolumeResponseCallback* aCallback)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
StartCommand(new VolumeActionCommand(this, "share", "ums", aCallback));
}
void
Volume::StartUnshare(VolumeResponseCallback* aCallback)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
StartCommand(new VolumeActionCommand(this, "unshare", "ums", aCallback));
}
void
Volume::StartCommand(VolumeCommand* aCommand)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
VolumeManager::PostCommand(aCommand);
}
@ -168,6 +192,7 @@ Volume::StartCommand(VolumeCommand* aCommand)
void
Volume::RegisterObserver(Volume::EventObserver* aObserver)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
mEventObserverList.AddObserver(aObserver);
@ -183,6 +208,7 @@ Volume::RegisterObserver(Volume::EventObserver* aObserver)
void
Volume::UnregisterObserver(Volume::EventObserver* aObserver)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
mEventObserverList.RemoveObserver(aObserver);
@ -194,6 +220,9 @@ Volume::UpdateMountLock(const nsACString& aVolumeName,
const int32_t& aMountGeneration,
const bool& aMountLocked)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
RefPtr<Volume> vol = VolumeManager::FindVolumeByName(aVolumeName);
if (!vol || (vol->mMountGeneration != aMountGeneration)) {
return;
@ -208,6 +237,9 @@ Volume::UpdateMountLock(const nsACString& aVolumeName,
void
Volume::HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer& aTokenizer)
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
// The volume name will have already been parsed, and the tokenizer will point
// to the token after the volume name
switch (aResponseCode) {

View File

@ -38,6 +38,11 @@ NS_VolumeStateStr(int32_t aState)
return "???";
}
// While nsVolumes can only be used on the main thread, in the
// UpdateVolumeRunnable constructor (which is called from IOThread) we
// allocate an nsVolume which is then passed to MainThread. Since we
// have a situation where we allocate on one thread and free on another
// we use a thread safe AddRef implementation.
NS_IMPL_THREADSAFE_ISUPPORTS1(nsVolume, nsIVolume)
nsVolume::nsVolume(const Volume* aVolume)
@ -106,6 +111,8 @@ nsVolume::LogState() const
void nsVolume::Set(const nsVolume* aVolume)
{
MOZ_ASSERT(NS_IsMainThread());
mName = aVolume->mName;
mMountPoint = aVolume->mMountPoint;
mState = aVolume->mState;
@ -139,6 +146,8 @@ void nsVolume::Set(const nsVolume* aVolume)
void
nsVolume::UpdateMountLock(const nsAString& aMountLockState)
{
MOZ_ASSERT(NS_IsMainThread());
// There are 3 states, unlocked, locked-background, and locked-foreground
// I figured it was easier to use negtive logic and compare for unlocked.
UpdateMountLock(!aMountLockState.EqualsLiteral("unlocked"));
@ -147,6 +156,8 @@ nsVolume::UpdateMountLock(const nsAString& aMountLockState)
void
nsVolume::UpdateMountLock(bool aMountLocked)
{
MOZ_ASSERT(NS_IsMainThread());
if (aMountLocked == mMountLocked) {
return;
}

View File

@ -2088,8 +2088,7 @@ ReadMARChannelIDs(const NS_tchar *path, MARChannelStringTable *results)
static int
GetUpdateFileName(NS_tchar *fileName, int maxChars)
{
#if defined(MOZ_WIDGET_GONK)
// If an update.link file exists, then it will contain the name
#if defined(MOZ_WIDGET_GONK) // If an update.link file exists, then it will contain the name
// of the update file (terminated by a newline).
NS_tchar linkFileName[MAXPATHLEN];