mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 992313 - Keep track of registered idle observers so we don't call into a freed pointer. r=roc
This commit is contained in:
parent
9564bd368c
commit
202914c96c
@ -51,7 +51,6 @@
|
||||
#include "nsIMemoryInfoDumper.h"
|
||||
#include "nsIMutable.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsStyleSheetService.h"
|
||||
@ -1282,6 +1281,8 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
|
||||
|
||||
mAlertObservers.Clear();
|
||||
|
||||
mIdleObservers.Clear();
|
||||
|
||||
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (svc) {
|
||||
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
|
||||
aObserver->AddRef();
|
||||
SendAddIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
||||
mIdleObservers.PutEntry(aObserver);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1668,6 +1670,7 @@ ContentChild::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
|
||||
MOZ_ASSERT(aObserver, "null idle observer");
|
||||
SendRemoveIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
||||
aObserver->Release();
|
||||
mIdleObservers.RemoveEntry(aObserver);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1676,7 +1679,11 @@ ContentChild::RecvNotifyIdleObserver(const uint64_t& aObserver,
|
||||
const nsString& aTimeStr)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,13 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/PContentChild.h"
|
||||
#include "mozilla/dom/ipc/Blob.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsTHashtable.h"
|
||||
|
||||
#include "nsWeakPtr.h"
|
||||
|
||||
|
||||
struct ChromePackage;
|
||||
class nsIDOMBlob;
|
||||
class nsIObserver;
|
||||
@ -298,6 +303,8 @@ private:
|
||||
InfallibleTArray<nsAutoPtr<AlertObserver> > mAlertObservers;
|
||||
nsRefPtr<ConsoleListener> mConsoleListener;
|
||||
|
||||
nsTHashtable<nsPtrHashKey<nsIObserver>> mIdleObservers;
|
||||
|
||||
/**
|
||||
* An ID unique to the process containing our corresponding
|
||||
* content parent.
|
||||
|
Loading…
Reference in New Issue
Block a user