From 5f4e3d6b4050d3a5b148e815db0525ca5c2295ab Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 20 Feb 2013 12:39:59 +0200 Subject: [PATCH] Bug 842710 - Identify TabChildGlobals in about:memory/compartment, r=jlebar --- content/base/src/nsFrameMessageManager.cpp | 8 ++++++- content/base/src/nsFrameMessageManager.h | 2 +- .../base/src/nsInProcessTabChildGlobal.cpp | 21 +++++++++---------- dom/ipc/TabChild.cpp | 3 ++- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp index 259fa254d27..6689a1ac03a 100644 --- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -1111,7 +1111,8 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL, } bool -nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope) +nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope, + const nsACString& aID) { nsCOMPtr runtimeSvc = @@ -1151,6 +1152,11 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope) NS_ENSURE_SUCCESS(rv, false); JS_SetGlobalObject(cx, global); + + // Set the location information for the new global, so that tools like + // about:memory may use that information. + xpc::SetLocationForGlobal(global, aID); + DidCreateCx(); return true; } diff --git a/content/base/src/nsFrameMessageManager.h b/content/base/src/nsFrameMessageManager.h index c43c7c5009f..fb989556a38 100644 --- a/content/base/src/nsFrameMessageManager.h +++ b/content/base/src/nsFrameMessageManager.h @@ -294,7 +294,7 @@ protected: enum CacheFailedBehavior { EXECUTE_IF_CANT_CACHE, DONT_EXECUTE }; void TryCacheLoadAndCompileScript(const nsAString& aURL, CacheFailedBehavior aBehavior = DONT_EXECUTE); - bool InitTabChildGlobalInternal(nsISupports* aScope); + bool InitTabChildGlobalInternal(nsISupports* aScope, const nsACString& aID); static void Traverse(nsFrameScriptExecutor *tmp, nsCycleCollectionTraversalCallback &cb); static void Unlink(nsFrameScriptExecutor* aTmp); diff --git a/content/base/src/nsInProcessTabChildGlobal.cpp b/content/base/src/nsInProcessTabChildGlobal.cpp index 634b38dae1d..3ec57356851 100644 --- a/content/base/src/nsInProcessTabChildGlobal.cpp +++ b/content/base/src/nsInProcessTabChildGlobal.cpp @@ -143,15 +143,6 @@ nsInProcessTabChildGlobal::Init() nullptr, mCx, mozilla::dom::ipc::MM_CHILD); - - // Set the location information for the new global, so that tools like - // about:memory may use that information. - JSObject *global; - nsIURI* docURI = mOwner->OwnerDoc()->GetDocumentURI(); - if (mGlobal && NS_SUCCEEDED(mGlobal->GetJSObject(&global)) && docURI) { - xpc::SetLocationForGlobal(global, docURI); - } - return NS_OK; } @@ -307,10 +298,18 @@ nsInProcessTabChildGlobal::PreHandleEvent(nsEventChainPreVisitor& aVisitor) nsresult nsInProcessTabChildGlobal::InitTabChildGlobal() { - + nsAutoCString id; + id.AssignLiteral("inProcessTabChildGlobal"); + nsIURI* uri = mOwner->OwnerDoc()->GetDocumentURI(); + if (uri) { + nsAutoCString u; + uri->GetSpec(u); + id.AppendLiteral("?ownedBy="); + id.Append(u); + } nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIDOMEventTarget*, this); - NS_ENSURE_STATE(InitTabChildGlobalInternal(scopeSupports)); + NS_ENSURE_STATE(InitTabChildGlobalInternal(scopeSupports, id)); return NS_OK; } diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 4444bce367b..f8455144804 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2060,7 +2060,8 @@ TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading) nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIDOMEventTarget*, scope); - NS_ENSURE_TRUE(InitTabChildGlobalInternal(scopeSupports), false); + NS_NAMED_LITERAL_CSTRING(globalId, "outOfProcessTabChildGlobal"); + NS_ENSURE_TRUE(InitTabChildGlobalInternal(scopeSupports, globalId), false); scope->Init();