Bug 1453986 - Remove possiblity of recursive GetService call when tracing r=smaug

--HG--
extra : rebase_source : 8319cf6afdde021eed71c25a8c6a1c21b7f65e18
This commit is contained in:
Jon Coppeard 2018-04-26 15:54:00 +01:00
parent 9184648e44
commit 6b7ad264ec
3 changed files with 17 additions and 2 deletions

View File

@ -13,6 +13,8 @@
using namespace mozilla;
using namespace mozilla::dom;
bool ProcessGlobal::sWasCreated = false;
ProcessGlobal::ProcessGlobal(nsFrameMessageManager* aMessageManager)
: MessageManagerGlobal(aMessageManager),
mInitialized(false)
@ -63,7 +65,17 @@ ProcessGlobal::Get()
if (!service) {
return nullptr;
}
return static_cast<ProcessGlobal*>(service.get());
ProcessGlobal* global = static_cast<ProcessGlobal*>(service.get());
if (global) {
sWasCreated = true;
}
return global;
}
bool
ProcessGlobal::WasCreated()
{
return sWasCreated;
}
void

View File

@ -51,6 +51,7 @@ public:
bool Init();
static ProcessGlobal* Get();
static bool WasCreated();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ProcessGlobal, nsIMessageSender)
@ -100,6 +101,8 @@ protected:
private:
bool mInitialized;
static bool sWasCreated;
};
} // namespace dom

View File

@ -469,7 +469,7 @@ mozilla::dom::TraceBlackJS(JSTracer* aTrc, bool aIsShutdownGC)
return;
}
if (nsFrameMessageManager::GetChildProcessManager()) {
if (ProcessGlobal::WasCreated() && nsFrameMessageManager::GetChildProcessManager()) {
ProcessGlobal* pg = ProcessGlobal::Get();
if (pg) {
mozilla::TraceScriptHolder(ToSupports(pg), aTrc);