Bug 865745 - Remove mContext from nsFrameMessageManager. r=smaug

This commit is contained in:
Bobby Holley 2013-06-29 18:44:05 -06:00
parent c4a4101312
commit adb2251a40
6 changed files with 2 additions and 27 deletions

View File

@ -1264,19 +1264,13 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
mMessageManager->GetParentManager() : nullptr;
nsFrameMessageManager* otherParentManager = aOther->mMessageManager ?
aOther->mMessageManager->GetParentManager() : nullptr;
JSContext* thisCx =
mMessageManager ? mMessageManager->GetJSContext() : nullptr;
JSContext* otherCx =
aOther->mMessageManager ? aOther->mMessageManager->GetJSContext() : nullptr;
if (mMessageManager) {
mMessageManager->RemoveFromParent();
mMessageManager->SetJSContext(otherCx);
mMessageManager->SetParentManager(otherParentManager);
mMessageManager->SetCallback(aOther, false);
}
if (aOther->mMessageManager) {
aOther->mMessageManager->RemoveFromParent();
aOther->mMessageManager->SetJSContext(thisCx);
aOther->mMessageManager->SetParentManager(ourParentManager);
aOther->mMessageManager->SetCallback(this, false);
}
@ -2390,12 +2384,10 @@ nsFrameLoader::EnsureMessageManager()
if (ShouldUseRemoteProcess()) {
mMessageManager = new nsFrameMessageManager(mRemoteBrowserShown ? this : nullptr,
static_cast<nsFrameMessageManager*>(parentManager.get()),
cx,
MM_CHROME);
} else {
mMessageManager = new nsFrameMessageManager(nullptr,
static_cast<nsFrameMessageManager*>(parentManager.get()),
cx,
MM_CHROME);
mChildMessageManager =

View File

@ -755,7 +755,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
return mParentManager ? mParentManager->ReceiveMessage(aTarget, aMessage,
aSync, aCloneData,
objectsArray,
aJSONRetVal, mContext) : NS_OK;
aJSONRetVal) : NS_OK;
}
void
@ -812,7 +812,6 @@ nsFrameMessageManager::RemoveFromParent()
mParentManager = nullptr;
mCallback = nullptr;
mOwnedCallback = nullptr;
mContext = nullptr;
}
void
@ -825,7 +824,6 @@ nsFrameMessageManager::Disconnect(bool aRemoveFromParent)
mParentManager = nullptr;
mCallback = nullptr;
mOwnedCallback = nullptr;
mContext = nullptr;
if (!mHandlingMessage) {
mListeners.Clear();
}
@ -837,7 +835,6 @@ NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult)
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default,
NS_ERROR_NOT_AVAILABLE);
nsFrameMessageManager* mm = new nsFrameMessageManager(nullptr,
nullptr,
nullptr,
MM_CHROME | MM_GLOBAL | MM_BROADCASTER);
return CallQueryInterface(mm, aResult);
@ -1390,7 +1387,6 @@ NS_NewParentProcessMessageManager(nsIMessageBroadcaster** aResult)
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default,
NS_ERROR_NOT_AVAILABLE);
nsRefPtr<nsFrameMessageManager> mm = new nsFrameMessageManager(nullptr,
nullptr,
nullptr,
MM_CHROME | MM_PROCESSMANAGER | MM_BROADCASTER);
nsFrameMessageManager::sParentProcessManager = mm;
@ -1413,12 +1409,10 @@ nsFrameMessageManager::NewProcessMessageManager(mozilla::dom::ContentParent* aPr
if (aProcess) {
mm = new nsFrameMessageManager(aProcess,
nsFrameMessageManager::sParentProcessManager,
nullptr,
MM_CHROME | MM_PROCESSMANAGER);
} else {
mm = new nsFrameMessageManager(new SameParentProcessMessageManagerCallback(),
nsFrameMessageManager::sParentProcessManager,
nullptr,
MM_CHROME | MM_PROCESSMANAGER | MM_OWNSCALLBACK);
sSameProcessParentManager = mm;
}
@ -1438,7 +1432,6 @@ NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)
cb = new ChildProcessMessageManagerCallback();
}
nsFrameMessageManager* mm = new nsFrameMessageManager(cb,
nullptr,
nullptr,
MM_PROCESSMANAGER | MM_OWNSCALLBACK);
nsFrameMessageManager::sChildProcessManager = mm;

View File

@ -120,7 +120,6 @@ class nsFrameMessageManager MOZ_FINAL : public nsIContentFrameMessageManager,
public:
nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback,
nsFrameMessageManager* aParentManager,
JSContext* aContext,
/* mozilla::dom::ipc::MessageManagerFlags */ uint32_t aFlags)
: mChrome(!!(aFlags & mozilla::dom::ipc::MM_CHROME)),
mGlobal(!!(aFlags & mozilla::dom::ipc::MM_GLOBAL)),
@ -130,11 +129,8 @@ public:
mHandlingMessage(false),
mDisconnected(false),
mCallback(aCallback),
mParentManager(aParentManager),
mContext(aContext)
mParentManager(aParentManager)
{
NS_ASSERTION(mContext || (mChrome && !mParentManager) || mIsProcessManager,
"Should have mContext in non-global/non-process manager!");
NS_ASSERTION(mChrome || !aParentManager, "Should not set parent manager!");
NS_ASSERTION(!mIsBroadcaster || !mCallback,
"Broadcasters cannot have callbacks!");
@ -211,8 +207,6 @@ public:
uint8_t aArgc);
nsresult DispatchAsyncMessageInternal(const nsAString& aMessage,
const StructuredCloneData& aData);
JSContext* GetJSContext() { return mContext; }
void SetJSContext(JSContext* aCx) { mContext = aCx; }
void RemoveFromParent();
nsFrameMessageManager* GetParentManager() { return mParentManager; }
void SetParentManager(nsFrameMessageManager* aParent)
@ -246,7 +240,6 @@ protected:
mozilla::dom::ipc::MessageManagerCallback* mCallback;
nsAutoPtr<mozilla::dom::ipc::MessageManagerCallback> mOwnedCallback;
nsFrameMessageManager* mParentManager;
JSContext* mContext;
nsTArray<nsString> mPendingScripts;
public:
static nsFrameMessageManager* sParentProcessManager;

View File

@ -141,7 +141,6 @@ nsInProcessTabChildGlobal::Init()
"Couldn't initialize nsInProcessTabChildGlobal");
mMessageManager = new nsFrameMessageManager(this,
nullptr,
mCx,
mozilla::dom::ipc::MM_CHILD);
return NS_OK;
}

View File

@ -11625,7 +11625,6 @@ nsGlobalChromeWindow::GetMessageManager(nsIMessageBroadcaster** aManager)
mMessageManager =
new nsFrameMessageManager(nullptr,
static_cast<nsFrameMessageManager*>(globalMM.get()),
cx,
MM_CHROME | MM_BROADCASTER);
NS_ENSURE_TRUE(mMessageManager, NS_ERROR_OUT_OF_MEMORY);
}

View File

@ -2346,7 +2346,6 @@ TabChildGlobal::Init()
NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
mMessageManager = new nsFrameMessageManager(mTabChild,
nullptr,
mTabChild->GetJSContext(),
MM_CHILD);
}