Bug 1658454 - nsISHEntry.cacheKey setter for session-history-in-parent, r=peterv

SessionHistoryEntry::MaybeSynchronizeSharedStateToInfo call is a tad controversial, but
something like that is needed for the cases when the actual value lives in the SHEntrySharedParentState.

Differential Revision: https://phabricator.services.mozilla.com/D86640
This commit is contained in:
Olli Pettay
2020-08-13 22:51:17 +00:00
parent 2de3e78e5b
commit 33f2ab8a98
8 changed files with 76 additions and 3 deletions

View File

@@ -8551,7 +8551,10 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
// Make sure we won't just repost without hitting the
// cache first
if (cacheKey != 0) {
mOSHE->SetCacheKey(cacheKey);
// XXX Update this call to deal with mLoadingEntry or mActiveEntry once
// the whole HandleSameDocumentNavigation is updated to work with
// SessionHistoryInfo objects!
SetCacheKeyOnHistoryEntry(mOSHE, nullptr, cacheKey);
}
}
@@ -10323,10 +10326,17 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
// If we already have a loading history entry, store the new cache key
// in it. Otherwise, since we're doing a reload and won't be updating
// our history entry, store the cache key in our current history entry.
if (mLoadingEntry) {
SetCacheKeyOnHistoryEntry(nullptr, &mLoadingEntry->mInfo, cacheKey);
} else if (mActiveEntry) {
SetCacheKeyOnHistoryEntry(nullptr, mActiveEntry.get(), cacheKey);
}
if (mLSHE) {
mLSHE->SetCacheKey(cacheKey);
SetCacheKeyOnHistoryEntry(mLSHE, nullptr, cacheKey);
} else if (mOSHE) {
mOSHE->SetCacheKey(cacheKey);
SetCacheKeyOnHistoryEntry(mOSHE, nullptr, cacheKey);
}
// Since we're force-reloading, clear all the sub frame history.
@@ -10823,6 +10833,29 @@ void nsDocShell::SetScrollRestorationIsManualOnHistoryEntry(
}
}
void nsDocShell::SetCacheKeyOnHistoryEntry(
nsISHEntry* aSHEntry, mozilla::dom::SessionHistoryInfo* aInfo,
uint32_t aCacheKey) {
if (aSHEntry) {
aSHEntry->SetCacheKey(aCacheKey);
}
if (aInfo) {
aInfo->SetCacheKey(aCacheKey);
if (XRE_IsParentProcess()) {
SessionHistoryEntry* entry =
SessionHistoryEntry::GetByInfoId(aInfo->Id());
if (entry) {
entry->SetCacheKey(aCacheKey);
}
} else {
mozilla::Unused
<< ContentChild::GetSingleton()->SendSessionHistoryEntryCacheKey(
aInfo->Id(), aCacheKey);
}
}
}
bool nsDocShell::ShouldAddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel) {
// I believe none of the about: urls should go in the history. But then
// that could just be me... If the intent is only deny about:blank then we