Bug 1546761 - Consolidate IPC calls to nsISHistory inside of nsDocShell::OnNewURI, r=peterv, r=nika for adding sync IPC messages

Inside of nsDocShell::OnNewURI there are 4 sync IPC calls
to nsSHistory that can be replaced with 1 sync IPC call
by adding a new method EnsureCorrectEntryAtCurrIndex to nsSHistory.

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

--HG--
extra : rebase_source : 09d7738b2f2dc2334c8f6186e5918b9d0ea3e618
extra : source : 82a41bffcbbca24ad3e84b045d75e4cb01ae1445
extra : histedit_source : 96eb7d2dbed2ad8fe4cc2d37358ec2358f696442
This commit is contained in:
Anny Gakhokidze 2019-05-07 15:23:08 -04:00
Родитель 68571a4dc6
Коммит 4472abffc2
8 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@ -10855,16 +10855,8 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
} else if (mSessionHistory && mLSHE && mURIResultedInDocument) {
// Even if we don't add anything to SHistory, ensure the current index
// points to the same SHEntry as our mLSHE.
int32_t index = mSessionHistory->LegacySHistory()->GetRequestedIndex();
if (index == -1) {
index = mSessionHistory->Index();
}
nsCOMPtr<nsISHEntry> currentSH;
mSessionHistory->LegacySHistory()->GetEntryAtIndex(
index, getter_AddRefs(currentSH));
if (currentSH != mLSHE) {
mSessionHistory->LegacySHistory()->ReplaceEntry(index, mLSHE);
}
mSessionHistory->LegacySHistory()->EnsureCorrectEntryAtCurrIndex(mLSHE);
}
// If this is a POST request, we do not want to include this in global

Просмотреть файл

@ -56,6 +56,7 @@ parent:
sync GetAllEntries() returns (MaybeNewPSHEntry[] entries);
sync FindEntryForBFCache(uint64_t sharedID, bool includeCurrentEntry) returns (MaybeNewPSHEntry entries, int32_t startIndex);
sync Evict(PSHEntry[] entry);
sync EnsureCorrectEntryAtCurrIndex(PSHEntry entry);
async __delete__();
};

Просмотреть файл

@ -304,6 +304,11 @@ SHistoryChild::RemoveDynEntries(int32_t aIndex, nsISHEntry* aEntry) {
SendRemoveDynEntries(aIndex, static_cast<SHEntryChild*>(aEntry));
}
NS_IMETHODIMP_(void)
SHistoryChild::EnsureCorrectEntryAtCurrIndex(nsISHEntry* aEntry) {
SendEnsureCorrectEntryAtCurrIndex(static_cast<SHEntryChild*>(aEntry));
}
NS_IMETHODIMP_(void)
SHistoryChild::RemoveDynEntriesForBFCacheEntry(nsIBFCacheEntry* aBFEntry) {
MaybeNewPSHEntry entry;

Просмотреть файл

@ -140,6 +140,12 @@ bool SHistoryParent::RecvRemoveDynEntries(int32_t aIndex,
return true;
}
bool SHistoryParent::RecvEnsureCorrectEntryAtCurrIndex(PSHEntryParent* aEntry) {
mHistory->EnsureCorrectEntryAtCurrIndex(
static_cast<SHEntryParent*>(aEntry)->mEntry);
return true;
}
bool SHistoryParent::RecvRemoveEntries(nsTArray<nsID>&& aIds, int32_t aIndex,
bool* aDidRemove) {
mHistory->RemoveEntries(aIds, aIndex, aDidRemove);

Просмотреть файл

@ -79,6 +79,7 @@ class SHistoryParent final : public PSHistoryParent {
const bool& aIncludeCurrentEntry,
MaybeNewPSHEntry* aEntry, int32_t* aIndex);
bool RecvEvict(nsTArray<PSHEntryParent*>&& aEntries);
bool RecvEnsureCorrectEntryAtCurrIndex(PSHEntryParent* aEntry);
RefPtr<CanonicalBrowsingContext> mContext;
RefPtr<LegacySHistory> mHistory;

Просмотреть файл

@ -260,4 +260,6 @@ interface nsISHistory: nsISupports
[noscript]
void Reload(in unsigned long aReloadFlags);
[notxpcom] void EnsureCorrectEntryAtCurrIndex(in nsISHEntry aEntry);
};

Просмотреть файл

@ -1358,6 +1358,15 @@ nsSHistory::GotoIndex(int32_t aIndex) {
return LoadURI(loadResult);
}
NS_IMETHODIMP_(void)
nsSHistory::EnsureCorrectEntryAtCurrIndex(nsISHEntry* aEntry) {
int index = mRequestedIndex == -1 ? mIndex : mRequestedIndex;
MOZ_ASSERT(mIndex > -1);
if (mEntries[index] != aEntry) {
ReplaceEntry(index, aEntry);
}
}
nsresult nsSHistory::GotoIndex(int32_t aIndex, LoadEntryResult& aLoadResult) {
return LoadEntry(aIndex, LOAD_HISTORY, HIST_CMD_GOTOINDEX, aLoadResult);
}

Просмотреть файл

@ -852,6 +852,8 @@ description = Standing up Fission
description = Standing up Fission
[PSHistory::Evict]
description = Standing up Fission
[PSHistory::EnsureCorrectEntryAtCurrIndex]
description = Standing up Fission
[PContent::PSHEntry]
description = Standing up Fission
[PSHEntry::GetURI]