Bug 814822 - Notify wake lock change when content crashes. r=jlebar

This commit is contained in:
Kan-Ru Chen (陳侃如) 2012-11-27 10:28:11 +08:00
parent a9602fb558
commit 21004569fc

View File

@ -53,17 +53,6 @@ static StaticAutoPtr<LockTable> sLockTable;
static bool sInitialized = false;
static bool sIsShuttingDown = false;
static PLDHashOperator
RemoveChildFromList(const nsAString& aKey, ProcessLockTable* aTable, void* aUserArg)
{
MOZ_ASSERT(aUserArg);
uint64_t childID = *static_cast<uint64_t*>(aUserArg);
aTable->Remove(childID);
return PL_DHASH_NEXT;
}
static PLDHashOperator
CountWakeLocks(const uint64_t& aKey, LockCount aCount, void* aUserArg)
{
@ -76,6 +65,31 @@ CountWakeLocks(const uint64_t& aKey, LockCount aCount, void* aUserArg)
return PL_DHASH_NEXT;
}
static PLDHashOperator
RemoveChildFromList(const nsAString& aKey, ProcessLockTable* aTable, void* aUserArg)
{
MOZ_ASSERT(aUserArg);
uint64_t childID = *static_cast<uint64_t*>(aUserArg);
if (aTable->Get(childID, NULL)) {
aTable->Remove(childID);
if (sActiveListeners) {
LockCount totalCount;
WakeLockInformation info;
aTable->EnumerateRead(CountWakeLocks, &totalCount);
if (!totalCount.numLocks) {
sLockTable->Remove(aKey);
}
info.numLocks() = totalCount.numLocks;
info.numHidden() = totalCount.numHidden;
info.topic() = aKey;
NotifyWakeLockChange(info);
}
}
return PL_DHASH_NEXT;
}
class ClearHashtableOnShutdown MOZ_FINAL : public nsIObserver {
public:
NS_DECL_ISUPPORTS
@ -162,6 +176,8 @@ ModifyWakeLockInternal(const nsAString& aTopic,
hal::WakeLockControl aHiddenAdjust,
uint64_t aProcessID)
{
MOZ_ASSERT(NS_IsMainThread());
if (sIsShuttingDown) {
return;
}