Bug 1121905 - Reorder frame loading sequence to send content process the URL earlier. r=kanru

This commit is contained in:
Ting-Yu Chou 2015-04-07 10:56:10 +08:00
parent 699f5b6a9b
commit 4a2b6d05a1
4 changed files with 41 additions and 50 deletions

View File

@ -340,19 +340,18 @@ nsFrameLoader::ReallyStartLoadingInternal()
}
if (mRemoteFrame) {
if (!mRemoteBrowser) {
TryRemoteBrowser();
if (!mRemoteBrowser) {
if (!mRemoteBrowser && !TryRemoteBrowser()) {
NS_WARNING("Couldn't create child process for iframe.");
return NS_ERROR_FAILURE;
}
}
if (mRemoteBrowserShown || ShowRemoteFrame(ScreenIntSize(0, 0))) {
// FIXME get error codes from child
mRemoteBrowser->LoadURL(mURIToLoad);
} else {
// Execute pending frame scripts before loading URL
EnsureMessageManager();
// FIXME get error codes from child
mRemoteBrowser->LoadURL(mURIToLoad);
if (!mRemoteBrowserShown && !ShowRemoteFrame(ScreenIntSize(0, 0))) {
NS_WARNING("[nsFrameLoader] ReallyStartLoadingInternal tried but couldn't show remote browser.\n");
}
@ -832,13 +831,9 @@ nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size,
{
NS_ASSERTION(mRemoteFrame, "ShowRemote only makes sense on remote frames.");
if (!mRemoteBrowser) {
TryRemoteBrowser();
if (!mRemoteBrowser) {
NS_ERROR("Couldn't create child process.");
return false;
}
if (!mRemoteBrowser && !TryRemoteBrowser()) {
NS_ERROR("Couldn't create child process.");
return false;
}
// FIXME/bug 589337: Show()/Hide() is pretty expensive for
@ -2262,28 +2257,31 @@ nsFrameLoader::TryRemoteBrowser()
nsCOMPtr<Element> ownerElement = mOwnerContent;
mRemoteBrowser = ContentParent::CreateBrowserOrApp(context, ownerElement, openerContentParent);
if (mRemoteBrowser) {
mChildID = mRemoteBrowser->Manager()->ChildID();
nsCOMPtr<nsIDocShellTreeItem> rootItem;
parentDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = rootItem->GetWindow();
nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(rootWin);
if (rootChromeWin) {
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin);
}
mContentParent = mRemoteBrowser->Manager();
if (mOwnerContent->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::mozpasspointerevents,
nsGkAtoms::_true,
eCaseMatters)) {
unused << mRemoteBrowser->SendSetUpdateHitRegion(true);
}
if (!mRemoteBrowser) {
return false;
}
mContentParent = mRemoteBrowser->Manager();
mChildID = mRemoteBrowser->Manager()->ChildID();
nsCOMPtr<nsIDocShellTreeItem> rootItem;
parentDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = rootItem->GetWindow();
nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(rootWin);
if (rootChromeWin) {
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin);
}
if (mOwnerContent->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::mozpasspointerevents,
nsGkAtoms::_true,
eCaseMatters)) {
unused << mRemoteBrowser->SendSetUpdateHitRegion(true);
}
return true;
}
@ -2528,7 +2526,7 @@ nsFrameLoader::EnsureMessageManager()
bool useRemoteProcess = ShouldUseRemoteProcess();
if (mMessageManager) {
if (useRemoteProcess && mRemoteBrowserShown) {
if (useRemoteProcess && mRemoteBrowser) {
mMessageManager->InitWithCallback(this);
}
return NS_OK;
@ -2553,7 +2551,7 @@ nsFrameLoader::EnsureMessageManager()
}
if (useRemoteProcess) {
mMessageManager = new nsFrameMessageManager(mRemoteBrowserShown ? this : nullptr,
mMessageManager = new nsFrameMessageManager(mRemoteBrowser ? this : nullptr,
static_cast<nsFrameMessageManager*>(parentManager.get()),
MM_CHROME);
} else {

View File

@ -1693,6 +1693,10 @@ bool
TabChild::RecvLoadURL(const nsCString& aURI,
const BrowserConfiguration& aConfiguration)
{
if (!InitTabChildGlobal()) {
return false;
}
SetProcessNameToAppName();
nsresult rv = WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI).get(),

View File

@ -266,7 +266,6 @@ TabParent::TabParent(nsIContentParent* aManager,
, mOrientation(0)
, mDPI(0)
, mDefaultScale(0)
, mShown(false)
, mUpdatedDimensions(false)
, mChromeOffset(0, 0)
, mManager(aManager)
@ -754,13 +753,6 @@ TabParent::LoadURL(nsIURI* aURI)
return;
}
if (!mShown) {
NS_WARNING(nsPrintfCString("TabParent::LoadURL(%s) called before "
"Show(). Ignoring LoadURL.\n",
spec.get()).get());
return;
}
uint32_t appId = OwnOrContainingAppId();
if (mSendOfflineStatus && NS_IsAppOffline(appId)) {
// If the app is offline in the parent process
@ -824,8 +816,6 @@ TabParent::LoadURL(nsIURI* aURI)
void
TabParent::Show(const ScreenIntSize& size, bool aParentIsActive)
{
// sigh
mShown = true;
mDimensions = size;
if (mIsDestroyed) {
return;

View File

@ -429,7 +429,6 @@ protected:
ScreenOrientation mOrientation;
float mDPI;
CSSToLayoutDeviceScale mDefaultScale;
bool mShown;
bool mUpdatedDimensions;
nsIntPoint mChromeOffset;