Commit 68641708 authored by Anny Gakhokidze's avatar Anny Gakhokidze
Browse files

Bug 1541515 - Consolidate IPC calls to nsISHEntry inside of...

Bug 1541515 - Consolidate IPC calls to nsISHEntry inside of nsDocShell::GetChildSHEntry, r=peterv, r=nika for adding sync IPC messages

Currently, nsDocShell::GetChildSHEntry calls 3 sync IPC calls on nsISHEntry,
and the method GetChildSHEntry only has one caller. By moving GetChildSHEntry
method to parent process for nsISHEntry, resulting in a new method
nsISHEntry::GetChildSHEntry, 3 sync IPC calls can be reduced to 1.

Differential Revision: https://phabricator.services.mozilla.com/D27633

--HG--
extra : rebase_source : 1e76a1b07d827b35bae7ed6acca25aa8732c9ed0
extra : source : 34d91f82faa36dd8d8ed721de365122d831f7b25
extra : histedit_source : 86592bc747d506c546ec660e57087e78b9719cf7
parent 4472abff
......@@ -835,15 +835,14 @@ void nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState) {
bool dynamicallyAddedChild = mDynamicallyCreated;
if (!dynamicallyAddedChild && !oshe && currentSH) {
currentSH->HasDynamicallyAddedChild(&dynamicallyAddedChild);
}
if (!dynamicallyAddedChild) {
// Only use the old SHEntry, if we're sure enough that
// it wasn't originally for some other frame.
nsCOMPtr<nsISHEntry> shEntry;
parentDS->GetChildSHEntry(mChildOffset, getter_AddRefs(shEntry));
aLoadState->SetSHEntry(shEntry);
currentSH->GetChildSHEntryIfHasNoDynamicallyAddedChild(
mChildOffset, getter_AddRefs(shEntry));
if (shEntry) {
aLoadState->SetSHEntry(shEntry);
}
}
// Make some decisions on the child frame's loadType based on the
......@@ -3276,52 +3275,6 @@ nsDocShell::FindChildWithName(const nsAString& aName, bool aRecurse,
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetChildSHEntry(int32_t aChildOffset, nsISHEntry** aResult) {
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nullptr;
// A nsISHEntry for a child is *only* available when the parent is in
// the progress of loading a document too...
if (mLSHE) {
/* Before looking for the subframe's url, check
* the expiration status of the parent. If the parent
* has expired from cache, then subframes will not be
* loaded from history in certain situations.
*/
bool parentExpired = mLSHE->GetExpirationStatus();
/* Get the parent's Load Type so that it can be set on the child too.
* By default give a loadHistory value
*/
uint32_t loadType = mLSHE->GetLoadType();
// If the user did a shift-reload on this frameset page,
// we don't want to load the subframes from history.
if (IsForceReloadType(loadType) || loadType == LOAD_REFRESH) {
return rv;
}
/* If the user pressed reload and the parent frame has expired
* from cache, we do not want to load the child frame from history.
*/
if (parentExpired && (loadType == LOAD_RELOAD_NORMAL)) {
// The parent has expired. Return null.
*aResult = nullptr;
return rv;
}
// Get the child subframe from session history.
rv = mLSHE->GetChildAt(aChildOffset, aResult);
if (*aResult) {
(*aResult)->SetLoadType(loadType);
}
}
return rv;
}
NS_IMETHODIMP
nsDocShell::AddChildSHEntry(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
int32_t aChildOffset, uint32_t aLoadType,
......
......@@ -859,10 +859,6 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
void makeEditable(in boolean inWaitForUriLoad);
/**
* Get the SHEntry associated with a child docshell
*/
nsISHEntry getChildSHEntry(in long aChildOffset);
/**
* Add a Child SHEntry for a frameset page, given the child's loadtype.
......
......@@ -101,6 +101,7 @@ parent:
sync AddChild(nullable PSHEntry childEntry, int32_t offset, bool useRemoteSubframes) returns (nsresult result);
sync RemoveChild(PSHEntry childEntry) returns (nsresult result);
sync GetChildAt(int32_t index) returns (MaybeNewPSHEntry childEntry);
sync GetChildSHEntryIfHasNoDynamicallyAddedChild(int32_t childOffset) returns (MaybeNewPSHEntry childEntry);
sync ReplaceChild(PSHEntry newChildEntry) returns (nsresult result);
sync ClearEntry(uint64_t aNewSharedID);
sync CreateLoadInfo() returns (nsDocShellLoadState loadState);
......
......@@ -794,6 +794,14 @@ SHEntryChild::GetChildAt(int32_t aIndex, nsISHEntry** aResult) {
return NS_OK;
}
NS_IMETHODIMP_(void)
SHEntryChild::GetChildSHEntryIfHasNoDynamicallyAddedChild(int32_t aChildOffset,
nsISHEntry** aChild) {
MaybeNewPSHEntry child;
SendGetChildSHEntryIfHasNoDynamicallyAddedChild(aChildOffset, &child);
*aChild = SHEntryChild::GetOrCreate(child).take();
}
NS_IMETHODIMP
SHEntryChild::ReplaceChild(nsISHEntry* aNewEntry) {
nsresult rv;
......
......@@ -516,6 +516,15 @@ bool SHEntryParent::RecvGetChildAt(const int32_t& aIndex,
return true;
}
bool SHEntryParent::RecvGetChildSHEntryIfHasNoDynamicallyAddedChild(
const int32_t& aChildOffset, MaybeNewPSHEntry* aChild) {
nsCOMPtr<nsISHEntry> child;
mEntry->GetChildSHEntryIfHasNoDynamicallyAddedChild(aChildOffset,
getter_AddRefs(child));
GetOrCreate(child, aChild);
return true;
}
bool SHEntryParent::RecvReplaceChild(PSHEntryParent* aNewChild,
nsresult* aResult) {
*aResult =
......
......@@ -177,6 +177,8 @@ class SHEntryParent final : public PSHEntryParent {
const bool& aUseRemoteSubframes, nsresult* aResult);
bool RecvRemoveChild(PSHEntryParent* aChild, nsresult* aResult);
bool RecvGetChildAt(const int32_t& aIndex, MaybeNewPSHEntry* aChild);
bool RecvGetChildSHEntryIfHasNoDynamicallyAddedChild(
const int32_t& aChildOffset, MaybeNewPSHEntry* aChild);
bool RecvReplaceChild(PSHEntryParent* aNewChild, nsresult* aResult);
bool RecvClearEntry(const uint64_t& aNewSharedID);
......
......@@ -399,6 +399,14 @@ interface nsISHEntry : nsISupports
*/
nsISHEntry GetChildAt(in long aIndex);
/**
* If this entry has no dynamically added child, get the child SHEntry
* at the given offset. The loadtype of the returned entry is set
* to its parent's loadtype.
*/
[notxpcom] void GetChildSHEntryIfHasNoDynamicallyAddedChild(in long aChildOffset,
out nsISHEntry aChild);
/**
* Replaces a child which is for the same docshell as aNewChild
* with aNewChild.
......
......@@ -739,6 +739,43 @@ nsSHEntry::GetChildAt(int32_t aIndex, nsISHEntry** aResult) {
return NS_OK;
}
NS_IMETHODIMP_(void)
nsSHEntry::GetChildSHEntryIfHasNoDynamicallyAddedChild(int32_t aChildOffset,
nsISHEntry** aChild) {
*aChild = nullptr;
bool dynamicallyAddedChild = false;
HasDynamicallyAddedChild(&dynamicallyAddedChild);
if (dynamicallyAddedChild) {
return;
}
// If the user did a shift-reload on this frameset page,
// we don't want to load the subframes from history.
if (IsForceReloadType(mLoadType) || mLoadType == LOAD_REFRESH) {
return;
}
/* Before looking for the subframe's url, check
* the expiration status of the parent. If the parent
* has expired from cache, then subframes will not be
* loaded from history in certain situations.
* If the user pressed reload and the parent frame has expired
* from cache, we do not want to load the child frame from history.
*/
if (mShared->mExpired && (mLoadType == LOAD_RELOAD_NORMAL)) {
// The parent has expired. Return null.
*aChild = nullptr;
return;
}
// Get the child subframe from session history.
GetChildAt(aChildOffset, aChild);
if (*aChild) {
// Set the parent's Load Type on the child
(*aChild)->SetLoadType(mLoadType);
}
}
NS_IMETHODIMP
nsSHEntry::ReplaceChild(nsISHEntry* aNewEntry) {
NS_ENSURE_STATE(aNewEntry);
......
......@@ -1000,6 +1000,8 @@ description = Standing up Fission
description = Standing up Fission
[PSHEntry::GetChildAt]
description = Standing up Fission
[PSHEntry::GetChildSHEntryIfHasNoDynamicallyAddedChild]
description = Standing up Fission
[PSHEntry::ReplaceChild]
description = Standing up Fission
[PSHEntry::ClearEntry]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment