author | Dave Hylands <dhylands@mozilla.com> |
Mon, 07 Jan 2013 17:43:02 +0100 | |
changeset 118386 | 9d9ec6237d95c1a8774c1a61f474abc6f3272848 |
parent 118385 | 0e777d664763babc59115499d1526d630c897b77 |
child 118387 | 77d3c4a0afb67fb453eb38c76bf293c50807189a |
push id | 24166 |
push user | Ms2ger@gmail.com |
push date | Fri, 11 Jan 2013 13:57:41 +0000 |
treeherder | mozilla-central@63c4b0f66a0c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dougt |
bugs | 785124 |
milestone | 21.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/system/gonk/Volume.cpp +++ b/dom/system/gonk/Volume.cpp @@ -60,16 +60,19 @@ Volume::Volume(const nsCSubstring& aName mMountLocked(true) // Needs to agree with nsVolume::nsVolume { DBG("Volume %s: created", NameStr()); } 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) // 605 Volume sdcard /mnt/sdcard state changed from 1 (Idle-Unmounted) to 0 (No-Media) // // And on media insertion, we get: // 630 Volume sdcard /mnt/sdcard disk inserted (179:0) // 605 Volume sdcard /mnt/sdcard state changed from 0 (No-Media) to 2 (Pending) @@ -95,16 +98,19 @@ Volume::SetMediaPresent(bool aMediaPrese LOG("Volume: %s media %s", NameStr(), aMediaPresent ? "inserted" : "removed"); mMediaPresent = aMediaPresent; mEventObserverList.Broadcast(this); } void Volume::SetState(Volume::STATE aNewState) { + MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); + if (aNewState == mState) { return; } if (aNewState == nsIVolume::STATE_MOUNTED) { mMountGeneration = ++sMountGeneration; LOG("Volume %s: changing state from %s to %s @ '%s' (%d observers) " "mountGeneration = %d, locked = %d", NameStr(), StateStr(mState), @@ -122,97 +128,123 @@ Volume::SetState(Volume::STATE aNewState } mState = aNewState; mEventObserverList.Broadcast(this); } void Volume::SetMountPoint(const nsCSubstring& aMountPoint) { + MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); + if (mMountPoint.Equals(aMountPoint)) { return; } mMountPoint = aMountPoint; DBG("Volume %s: Setting mountpoint to '%s'", NameStr(), mMountPoint.get()); } 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); } //static void Volume::RegisterObserver(Volume::EventObserver* aObserver) { + MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); mEventObserverList.AddObserver(aObserver); // Send an initial event to the observer (for each volume) size_t numVolumes = VolumeManager::NumVolumes(); for (size_t volIndex = 0; volIndex < numVolumes; volIndex++) { RefPtr<Volume> vol = VolumeManager::GetVolume(volIndex); aObserver->Notify(vol); } } //static void Volume::UnregisterObserver(Volume::EventObserver* aObserver) { + MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); mEventObserverList.RemoveObserver(aObserver); } //static void 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; } if (vol->mMountLocked != aMountLocked) { vol->mMountLocked = aMountLocked; DBG("Volume::UpdateMountLock for '%s' to %d\n", vol->NameStr(), (int)aMountLocked); mEventObserverList.Broadcast(vol); } } 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) { case ResponseCode::VolumeListResult: { // Each line will look something like: // // sdcard /mnt/sdcard 1 //
--- a/dom/system/gonk/nsVolume.cpp +++ b/dom/system/gonk/nsVolume.cpp @@ -33,16 +33,21 @@ NS_VolumeStateStr(int32_t aState) case nsIVolume::STATE_UNMOUNTING: return "Unmounting"; case nsIVolume::STATE_FORMATTING: return "Formatting"; case nsIVolume::STATE_SHARED: return "Shared"; case nsIVolume::STATE_SHAREDMNT: return "Shared-Mounted"; } 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) : mName(NS_ConvertUTF8toUTF16(aVolume->Name())), mMountPoint(NS_ConvertUTF8toUTF16(aVolume->MountPoint())), mState(aVolume->State()), mMountGeneration(aVolume->MountGeneration()), mMountLocked(aVolume->IsMountLocked()) @@ -101,16 +106,18 @@ nsVolume::LogState() const return; } LOG("nsVolume: %s state %s", NameStr(), StateStr()); } void nsVolume::Set(const nsVolume* aVolume) { + MOZ_ASSERT(NS_IsMainThread()); + mName = aVolume->mName; mMountPoint = aVolume->mMountPoint; mState = aVolume->mState; if (mState != nsIVolume::STATE_MOUNTED) { // Since we're not in the mounted state, we need to // forgot whatever mount generation we may have had. mMountGeneration = -1; @@ -134,24 +141,28 @@ void nsVolume::Set(const nsVolume* aVolu nsString mountLockState; pmService->GetWakeLockState(mountLockName, mountLockState); UpdateMountLock(mountLockState); } 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")); } void nsVolume::UpdateMountLock(bool aMountLocked) { + MOZ_ASSERT(NS_IsMainThread()); + if (aMountLocked == mMountLocked) { return; } // The locked/unlocked state changed. Tell IOThread about it. mMountLocked = aMountLocked; LogState(); XRE_GetIOMessageLoop()->PostTask( FROM_HERE,
--- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -2083,18 +2083,17 @@ ReadMARChannelIDs(const NS_tchar *path, return result; } #endif 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]; NS_tsnprintf(linkFileName, sizeof(linkFileName)/sizeof(linkFileName[0]), NS_T("%s/update.link"), gSourcePath); AutoFile linkFile = NS_tfopen(linkFileName, NS_T("rb")); if (linkFile == NULL) { NS_tsnprintf(fileName, maxChars,