Bug 1190245 - Separate mMessageManager creation and FrameScript loading. r=smaug

This commit is contained in:
Kan-Ru Chen 2015-07-30 11:07:14 +08:00
parent 9f10086ee8
commit afec2af40b
2 changed files with 24 additions and 21 deletions

View File

@ -313,7 +313,7 @@ nsFrameLoader::ReallyStartLoadingInternal()
}
// Execute pending frame scripts before loading URL
EnsureMessageManager();
ReallyLoadFrameScripts();
// FIXME get error codes from child
mRemoteBrowser->LoadURL(mURIToLoad);
@ -790,7 +790,7 @@ nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size,
mRemoteBrowser->Show(size, parentIsActive);
mRemoteBrowserShown = true;
EnsureMessageManager();
ReallyLoadFrameScripts();
InitializeBrowserAPI();
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
@ -1789,7 +1789,7 @@ nsFrameLoader::MaybeCreateDocShell()
webNav->SetSessionHistory(sessionHistory);
}
EnsureMessageManager();
ReallyLoadFrameScripts();
if (OwnerIsAppFrame()) {
// You can't be both an app and a browser frame.
@ -2474,6 +2474,10 @@ nsFrameLoader::EnsureMessageManager()
return rv;
}
if (mMessageManager) {
return NS_OK;
}
if (!mIsTopLevelContent &&
!OwnerIsBrowserOrAppFrame() &&
!mRemoteFrame &&
@ -2484,14 +2488,6 @@ nsFrameLoader::EnsureMessageManager()
return NS_OK;
}
bool useRemoteProcess = ShouldUseRemoteProcess();
if (mMessageManager) {
if (useRemoteProcess && mRemoteBrowser) {
mMessageManager->InitWithCallback(this);
}
return NS_OK;
}
nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
do_QueryInterface(GetOwnerDoc()->GetWindow());
nsCOMPtr<nsIMessageBroadcaster> parentManager;
@ -2510,18 +2506,24 @@ nsFrameLoader::EnsureMessageManager()
}
}
if (useRemoteProcess) {
mMessageManager = new nsFrameMessageManager(mRemoteBrowser ? this : nullptr,
static_cast<nsFrameMessageManager*>(parentManager.get()),
MM_CHROME);
} else {
mMessageManager = new nsFrameMessageManager(nullptr,
static_cast<nsFrameMessageManager*>(parentManager.get()),
MM_CHROME);
mMessageManager = new nsFrameMessageManager(nullptr,
static_cast<nsFrameMessageManager*>(parentManager.get()),
MM_CHROME);
if (!ShouldUseRemoteProcess()) {
mChildMessageManager =
new nsInProcessTabChildGlobal(mDocShell, mOwnerContent, mMessageManager);
// Force pending frame scripts to be loaded.
}
return NS_OK;
}
nsresult
nsFrameLoader::ReallyLoadFrameScripts()
{
nsresult rv = EnsureMessageManager();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (mMessageManager) {
mMessageManager->InitWithCallback(this);
}
return NS_OK;

View File

@ -270,6 +270,7 @@ private:
*/
nsresult MaybeCreateDocShell();
nsresult EnsureMessageManager();
nsresult ReallyLoadFrameScripts();
// Updates the subdocument position and size. This gets called only
// when we have our own in-process DocShell.