зеркало из https://github.com/mozilla/gecko-dev.git
Bug 992313 - Keep track of registered idle observers so we don't call into a freed pointer. r=roc
This commit is contained in:
Родитель
b5a890c201
Коммит
c5ec0c3e51
|
@ -51,7 +51,6 @@
|
||||||
#include "nsIMemoryInfoDumper.h"
|
#include "nsIMemoryInfoDumper.h"
|
||||||
#include "nsIMutable.h"
|
#include "nsIMutable.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsIObserver.h"
|
|
||||||
#include "nsIScriptSecurityManager.h"
|
#include "nsIScriptSecurityManager.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsStyleSheetService.h"
|
#include "nsStyleSheetService.h"
|
||||||
|
@ -1282,6 +1281,8 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
|
||||||
|
|
||||||
mAlertObservers.Clear();
|
mAlertObservers.Clear();
|
||||||
|
|
||||||
|
mIdleObservers.Clear();
|
||||||
|
|
||||||
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||||
if (svc) {
|
if (svc) {
|
||||||
svc->UnregisterListener(mConsoleListener);
|
svc->UnregisterListener(mConsoleListener);
|
||||||
|
@ -1660,6 +1661,7 @@ ContentChild::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
|
||||||
// Make sure aObserver isn't released while we wait for the parent
|
// Make sure aObserver isn't released while we wait for the parent
|
||||||
aObserver->AddRef();
|
aObserver->AddRef();
|
||||||
SendAddIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
SendAddIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
||||||
|
mIdleObservers.PutEntry(aObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1668,6 +1670,7 @@ ContentChild::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
|
||||||
MOZ_ASSERT(aObserver, "null idle observer");
|
MOZ_ASSERT(aObserver, "null idle observer");
|
||||||
SendRemoveIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
SendRemoveIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
||||||
aObserver->Release();
|
aObserver->Release();
|
||||||
|
mIdleObservers.RemoveEntry(aObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -1676,7 +1679,11 @@ ContentChild::RecvNotifyIdleObserver(const uint64_t& aObserver,
|
||||||
const nsString& aTimeStr)
|
const nsString& aTimeStr)
|
||||||
{
|
{
|
||||||
nsIObserver* observer = reinterpret_cast<nsIObserver*>(aObserver);
|
nsIObserver* observer = reinterpret_cast<nsIObserver*>(aObserver);
|
||||||
observer->Observe(nullptr, aTopic.get(), aTimeStr.get());
|
if (mIdleObservers.Contains(observer)) {
|
||||||
|
observer->Observe(nullptr, aTopic.get(), aTimeStr.get());
|
||||||
|
} else {
|
||||||
|
NS_WARNING("Received notification for an idle observer that was removed.");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,13 @@
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/dom/PContentChild.h"
|
#include "mozilla/dom/PContentChild.h"
|
||||||
#include "mozilla/dom/ipc/Blob.h"
|
#include "mozilla/dom/ipc/Blob.h"
|
||||||
|
#include "nsHashKeys.h"
|
||||||
|
#include "nsIObserver.h"
|
||||||
|
#include "nsTHashtable.h"
|
||||||
|
|
||||||
#include "nsWeakPtr.h"
|
#include "nsWeakPtr.h"
|
||||||
|
|
||||||
|
|
||||||
struct ChromePackage;
|
struct ChromePackage;
|
||||||
class nsIDOMBlob;
|
class nsIDOMBlob;
|
||||||
class nsIObserver;
|
class nsIObserver;
|
||||||
|
@ -298,6 +303,8 @@ private:
|
||||||
InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
|
InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
|
||||||
nsRefPtr<ConsoleListener> mConsoleListener;
|
nsRefPtr<ConsoleListener> mConsoleListener;
|
||||||
|
|
||||||
|
nsTHashtable<nsPtrHashKey<nsIObserver>> mIdleObservers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ID unique to the process containing our corresponding
|
* An ID unique to the process containing our corresponding
|
||||||
* content parent.
|
* content parent.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче