Bug 1570255 - Remove sync session history implementation. r=smaug,nika

Differential Revision: https://phabricator.services.mozilla.com/D65326
This commit is contained in:
Peter Van der Beken 2020-05-20 09:09:06 +00:00
Родитель 055d9db743
Коммит 1990918ebe
35 изменённых файлов: 107 добавлений и 4469 удалений

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

@ -130,25 +130,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
bool AttemptLoadURIInParent(nsDocShellLoadState* aLoadState,
uint32_t* aLoadIdentifier);
bool HasHistoryEntry(nsISHEntry* aEntry) const {
return aEntry && (aEntry == mOSHE || aEntry == mLSHE);
}
void UpdateSHEntries(nsISHEntry* aNewLSHE, nsISHEntry* aNewOSHE) {
mLSHE = aNewLSHE;
mOSHE = aNewOSHE;
}
void SwapHistoryEntries(nsISHEntry* aOldEntry, nsISHEntry* aNewEntry) {
if (aOldEntry == mOSHE) {
mOSHE = aNewEntry;
}
if (aOldEntry == mLSHE) {
mLSHE = aNewEntry;
}
}
protected:
// Called when the browsing context is being discarded.
void CanonicalDiscard();
@ -221,10 +202,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
RefPtr<MediaController> mTabMediaController;
RefPtr<net::DocumentLoadListener> mCurrentLoad;
// These are being mirrored from docshell
nsCOMPtr<nsISHEntry> mOSHE;
nsCOMPtr<nsISHEntry> mLSHE;
};
} // namespace dom

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

@ -198,7 +198,7 @@
#include "nsSandboxFlags.h"
#include "nsSHEntry.h"
#include "nsSHistory.h"
#include "SHEntryChild.h"
#include "nsSHEntry.h"
#include "nsStructuredCloneContainer.h"
#include "nsSubDocumentFrame.h"
#include "nsView.h"
@ -10707,9 +10707,7 @@ nsresult nsDocShell::AddToSessionHistory(
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
RefPtr<ChildSHistory> shistory = webnav->GetSessionHistory();
entry = CreateSHEntryForDocShell(shistory ? shistory->LegacySHistory()
: nullptr);
NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE);
entry = new nsSHEntry(shistory ? shistory->LegacySHistory() : nullptr);
}
// Get the post data & referrer
@ -10998,24 +10996,6 @@ void nsDocShell::SetHistoryEntryAndUpdateBC(const Maybe<nsISHEntry*>& aLSHE,
deathGripOldOSHE = SetHistoryEntry(&mOSHE, aOSHE.value());
MOZ_ASSERT(mOSHE.get() == aOSHE.value());
}
// Do not update the BC if the SH pref is off and we are not a parent process
// or if it is discarded
if ((!StaticPrefs::fission_sessionHistoryInParent() &&
XRE_IsContentProcess()) ||
mBrowsingContext->IsDiscarded()) {
return;
}
if (XRE_IsParentProcess()) {
// We are in the parent process, thus we can update the entries directly
mBrowsingContext->Canonical()->UpdateSHEntries(mLSHE, mOSHE);
} else {
ContentChild* cc = ContentChild::GetSingleton();
// We can't update canonical BC directly, so do it over IPC call
cc->SendUpdateSHEntriesInBC(static_cast<SHEntryChild*>(mLSHE.get()),
static_cast<SHEntryChild*>(mOSHE.get()),
mBrowsingContext);
}
}
already_AddRefed<nsISHEntry> nsDocShell::SetHistoryEntry(

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

@ -6,8 +6,6 @@
#include "nsDocShellLoadState.h"
#include "nsIDocShell.h"
#include "SHEntryParent.h"
#include "SHEntryChild.h"
#include "nsDocShell.h"
#include "nsISHEntry.h"
#include "nsIURIFixup.h"
@ -135,14 +133,6 @@ nsDocShellLoadState::nsDocShellLoadState(
mHeadersStream = aLoadState.HeadersStream();
mSrcdocData = aLoadState.SrcdocData();
mLoadIdentifier = aLoadState.LoadIdentifier();
if (!aLoadState.SHEntry() || !StaticPrefs::fission_sessionHistoryInParent()) {
return;
}
if (XRE_IsParentProcess()) {
mSHEntry = static_cast<LegacySHEntry*>(aLoadState.SHEntry());
} else {
mSHEntry = static_cast<SHEntryChild*>(aLoadState.SHEntry());
}
}
nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther)
@ -877,18 +867,5 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize() {
loadState.SrcdocData() = mSrcdocData;
loadState.ResultPrincipalURI() = mResultPrincipalURI;
loadState.LoadIdentifier() = mLoadIdentifier;
if (!mSHEntry || !StaticPrefs::fission_sessionHistoryInParent()) {
// Without the pref, we don't have an actor for shentry and thus
// we can't serialize it. We could write custom (de)serializers,
// but a session history rewrite is on the way anyway.
return loadState;
}
if (XRE_IsParentProcess()) {
loadState.SHEntry() = static_cast<CrossProcessSHEntry*>(
static_cast<LegacySHEntry*>(mSHEntry.get()));
} else {
loadState.SHEntry() = static_cast<CrossProcessSHEntry*>(
static_cast<SHEntryChild*>(mSHEntry.get()));
}
return loadState;
}

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

@ -6,7 +6,6 @@
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/BrowsingContextGroup.h"
#include "mozilla/dom/SHEntryChild.h"
// session history
#include "nsSHEntryShared.h"
@ -19,14 +18,10 @@ nsresult InitDocShellModule() {
mozilla::dom::BrowsingContext::Init();
nsresult rv = nsSHistory::Startup();
NS_ENSURE_SUCCESS(rv, rv);
mozilla::dom::SHEntryChildShared::Init();
return NS_OK;
}
void UnloadDocShellModule() {
nsSHistory::Shutdown();
nsSHEntryShared::Shutdown();
}
void UnloadDocShellModule() { nsSHistory::Shutdown(); }
} // namespace mozilla

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

@ -8,8 +8,6 @@
#include "mozilla/dom/ChildSHistoryBinding.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/SHEntryChild.h"
#include "mozilla/dom/SHistoryChild.h"
#include "mozilla/StaticPrefs_fission.h"
#include "nsComponentManagerUtils.h"
#include "nsSHEntry.h"
@ -34,13 +32,6 @@ void ChildSHistory::SetIsInProcess(bool aIsInProcess) {
return;
}
if (XRE_IsContentProcess() && StaticPrefs::fission_sessionHistoryInParent()) {
mHistory = do_AddRef(static_cast<SHistoryChild*>(
ContentChild::GetSingleton()->SendPSHistoryConstructor(
mBrowsingContext)));
return;
}
mHistory = new nsSHistory(mBrowsingContext);
}
@ -118,17 +109,5 @@ nsISupports* ChildSHistory::GetParentObject() const {
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
}
already_AddRefed<nsISHEntry> CreateSHEntryForDocShell(nsISHistory* aSHistory) {
uint64_t sharedID = SHEntryChildShared::CreateSharedID();
if (XRE_IsContentProcess() && StaticPrefs::fission_sessionHistoryInParent()) {
return do_AddRef(static_cast<SHEntryChild*>(
ContentChild::GetSingleton()->SendPSHEntryConstructor(
static_cast<SHistoryChild*>(aSHistory), sharedID)));
}
nsCOMPtr<nsISHEntry> entry = new nsLegacySHEntry(aSHistory, sharedID);
return entry.forget();
}
} // namespace dom
} // namespace mozilla

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

@ -105,8 +105,6 @@ class ChildSHistory : public nsISupports, public nsWrapperCache {
mozilla::LinkedList<PendingAsyncHistoryNavigation> mPendingNavigations;
};
already_AddRefed<nsISHEntry> CreateSHEntryForDocShell(nsISHistory* aSHistory);
} // namespace dom
} // namespace mozilla

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

@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/MaybeNewPSHEntry.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/PContentParent.h"
#include "mozilla/dom/PSHistoryParent.h"
#include "mozilla/dom/SHEntryChild.h"
#include "mozilla/dom/SHEntryParent.h"
#include "mozilla/dom/SHistoryChild.h"
namespace mozilla {
namespace ipc {
template <>
struct IPDLParamTraits<dom::NewPSHEntry> {
static void Write(IPC::Message* aMsg, IProtocol* aActor,
dom::NewPSHEntry&& aEntry) {
MOZ_RELEASE_ASSERT(aActor->GetSide() == ParentSide, "wrong side!");
WriteIPDLParam(aMsg, aActor, std::move(aEntry.mEndpoint));
WriteIPDLParam(aMsg, aActor, aEntry.mSHistoryParent);
WriteIPDLParam(aMsg, aActor, aEntry.mSharedID);
}
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
IProtocol* aActor, dom::NewPSHEntry* aEntry) {
MOZ_RELEASE_ASSERT(aActor->GetSide() == ChildSide, "wrong side!");
return ReadIPDLParam(aMsg, aIter, aActor, &aEntry->mEndpoint) &&
ReadIPDLParam(aMsg, aIter, aActor, &aEntry->mSHistoryChild) &&
ReadIPDLParam(aMsg, aIter, aActor, &aEntry->mSharedID);
}
};
/* static */
void IPDLParamTraits<dom::CrossProcessSHEntry*>::Write(
IPC::Message* aMsg, IProtocol* aActor, dom::CrossProcessSHEntry* aEntry) {
MOZ_DIAGNOSTIC_ASSERT(aActor->ToplevelProtocol()->GetProtocolId() ==
PContentMsgStart);
if (aActor->GetSide() == ChildSide) {
WriteIPDLParam(aMsg, aActor,
static_cast<dom::PSHEntryChild*>(
static_cast<dom::SHEntryChild*>(aEntry)));
return;
}
dom::MaybeNewPSHEntryParent entry(static_cast<dom::PSHEntryParent*>(nullptr));
if (aEntry) {
entry = static_cast<dom::LegacySHEntry*>(aEntry)->GetOrCreateActor(
static_cast<dom::PContentParent*>(aActor->ToplevelProtocol()));
}
WriteIPDLParam(aMsg, aActor, std::move(entry));
}
/* static */
bool IPDLParamTraits<dom::CrossProcessSHEntry*>::Read(
const IPC::Message* aMsg, PickleIterator* aIter,
mozilla::ipc::IProtocol* aActor, RefPtr<dom::CrossProcessSHEntry>* aEntry) {
if (aActor->GetSide() == ParentSide) {
dom::PSHEntryParent* actor;
if (!ReadIPDLParam(aMsg, aIter, aActor, &actor)) {
aActor->FatalError("Error deserializing MaybeNewPSHEntry");
return false;
}
*aEntry =
actor ? static_cast<dom::SHEntryParent*>(actor)->GetSHEntry() : nullptr;
return true;
}
dom::MaybeNewPSHEntryChild actor(static_cast<dom::PSHEntryChild*>(nullptr));
if (!ReadIPDLParam(aMsg, aIter, aActor, &actor)) {
aActor->FatalError("Error deserializing MaybeNewPSHEntry");
return false;
}
return actor.match(
[&](dom::PSHEntryChild*& entry) {
*aEntry = static_cast<dom::SHEntryChild*>(entry);
return true;
},
[&](dom::NewPSHEntry& newEntry) {
RefPtr<dom::SHEntryChild> entry = new dom::SHEntryChild(
static_cast<dom::SHistoryChild*>(newEntry.mSHistoryChild),
newEntry.mSharedID);
dom::ContentChild::GetSingleton()->BindPSHEntryEndpoint(
std::move(newEntry.mEndpoint), do_AddRef(entry).take());
*aEntry = std::move(entry);
return true;
});
}
} // namespace ipc
} // namespace mozilla

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

@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_MaybeNewPSHEntry_h
#define mozilla_dom_MaybeNewPSHEntry_h
#include "ipc/IPCMessageUtils.h"
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Variant.h"
#include "mozilla/ipc/IPDLParamTraits.h"
#include "mozilla/ipc/ProtocolUtils.h"
namespace mozilla {
namespace dom {
class LegacySHEntry;
class PSHistoryChild;
class PSHistoryParent;
class PSHEntryChild;
class PSHEntryParent;
class PSHistoryChild;
class PSHistoryParent;
class SHEntryChild;
struct NewPSHEntry final {
mozilla::ipc::ManagedEndpoint<PSHEntryChild> mEndpoint;
PSHistoryParent* mSHistoryParent;
PSHistoryChild* mSHistoryChild;
uint64_t mSharedID;
};
typedef Variant<PSHEntryParent*, NewPSHEntry> MaybeNewPSHEntryParent;
typedef Variant<PSHEntryChild*, NewPSHEntry> MaybeNewPSHEntryChild;
// Any IPDL protocol trying to pass this (as argument or return value) needs to
// be managed by PContent.
class CrossProcessSHEntry {
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
SHEntryChild* ToSHEntryChild();
};
} // namespace dom
namespace ipc {
template <>
struct IPDLParamTraits<dom::CrossProcessSHEntry*> {
static void Write(IPC::Message* aMsg, IProtocol* aActor,
dom::CrossProcessSHEntry* aEntry);
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
IProtocol* aActor, RefPtr<dom::CrossProcessSHEntry>* aEntry);
};
} // namespace ipc
} // namespace mozilla
#endif /* mozilla_dom_MaybeNewPSHEntry_h */

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

@ -1,123 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PContent;
include protocol PSHistory;
include DOMTypes;
include PresState;
using refcounted class mozilla::dom::CrossProcessSHEntry from "mozilla/dom/MaybeNewPSHEntry.h";
using refcounted class nsDocShellLoadState from "mozilla/dom/DocShellMessageUtils.h";
using struct nsID from "nsID.h";
using nsIntRect from "nsRect.h";
namespace mozilla {
namespace dom {
sync protocol PSHEntry {
// IPDLParamTraits<dom::CrossProcessSHEntry*>::Write relies on PContent being
// the manager.
manager PContent;
parent:
sync GetURI() returns (nsIURI uri);
async SetURI(nsIURI uri);
sync GetOriginalURI() returns (nsIURI originalUri);
async SetOriginalURI(nsIURI originalUri);
sync GetResultPrincipalURI() returns (nsIURI resultPrincipalUri);
async SetResultPrincipalURI(nsIURI resultPrincipalUri);
sync GetLoadReplace() returns (bool loadReplace);
async SetLoadReplace(bool loadReplace);
sync GetTitle() returns (nsString title);
async SetTitle(nsString title);
sync GetIsSubFrame() returns (bool isSubFrame);
async SetIsSubFrame(bool isSubFrame);
sync GetReferrerInfo() returns (nsIReferrerInfo referrerInfo);
async SetReferrerInfo(nsIReferrerInfo referrerInfo);
sync GetSticky() returns (bool sticky);
async SetSticky(bool sticky);
sync GetPostData() returns (nsIInputStream postData);
async SetPostData(nsIInputStream postData);
sync GetParent() returns (CrossProcessSHEntry parentEntry);
async SetParent(nullable PSHEntry parentEntry);
sync GetLoadType() returns (uint32_t loadType);
async SetLoadType(uint32_t loadType);
sync GetID() returns (uint32_t id);
async SetID(uint32_t id);
sync GetCacheKey() returns (uint32_t cacheKey);
async SetCacheKey(uint32_t cacheKey);
sync GetExpirationStatus() returns (bool expirationStatus);
async SetExpirationStatus(bool expirationStatus);
sync GetContentType() returns (nsCString contentType);
async SetContentType(nsCString contentType);
sync GetURIWasModified() returns (bool uriWasModified);
async SetURIWasModified(bool uriWasModified);
sync GetTriggeringPrincipal() returns (nsIPrincipal triggeringPrincipal);
async SetTriggeringPrincipal(nsIPrincipal triggeringPrincipal);
sync GetPrincipalToInherit() returns (nsIPrincipal principalToInherit);
async SetPrincipalToInherit(nsIPrincipal principalToInherit);
sync GetStoragePrincipalToInherit()
returns (nsIPrincipal storagePrincipalToInherit);
async SetStoragePrincipalToInherit(nsIPrincipal storagePrincipalToInherit);
sync GetCsp() returns (nsIContentSecurityPolicy csp);
async SetCsp(nsIContentSecurityPolicy csp);
sync GetStateData() returns (ClonedMessageData stateData);
async SetStateData(ClonedMessageData stateData);
sync GetDocshellID() returns (nsID docshellId);
async SetDocshellID(nsID docshellId);
sync GetIsSrcdocEntry() returns (bool isSrcdocEntry);
sync GetSrcdocData() returns (nsString srcdocData);
async SetSrcdocData(nsString srcdocData);
sync GetBaseURI() returns (nsIURI baseUri);
async SetBaseURI(nsIURI baseUri);
sync GetScrollRestorationIsManual() returns (bool scrollRestorationIsManual);
async SetScrollRestorationIsManual(bool scrollRestorationIsManual);
sync GetLoadedInThisProcess() returns (bool loadedInThisProcess);
sync GetLastTouched() returns (uint32_t lastTouched);
async SetLastTouched(uint32_t lastTouched);
sync GetChildCount() returns (int32_t childCount);
sync GetPersist() returns (bool persist);
async SetPersist(bool persist);
async SetScrollPosition(int32_t x, int32_t y);
sync GetScrollPosition() returns (int32_t x, int32_t y);
sync GetViewerBounds() returns (nsIntRect bounds);
async SetViewerBounds(nsIntRect bounds);
async Create(nsIURI URI, nsString title, nsIInputStream inputStream,
uint32_t cacheKey, nsCString contentType,
nsIPrincipal triggeringPrincipal, nsIPrincipal principalToInherit,
nsIPrincipal storagePrincipalToInherit,
nsIContentSecurityPolicy csp, nsID docshellID,
bool dynamicCreation, nsIURI originalUri, nsIURI resultPrincipalURI,
bool loadReplace, nsIReferrerInfo referrerInfo,
nsString srcdoc, bool srcdocEntry, nsIURI baseURI,
bool saveLayoutState, bool expired);
sync HasDetachedEditor() returns (bool hasDetachedEditor);
sync IsDynamicallyAdded() returns (bool isDynamicallyAdded);
sync HasDynamicallyAddedChild() returns (bool hasDynamicallyAddedChild);
sync AdoptBFCacheEntry(PSHEntry entry) returns (nsresult result);
async AbandonBFCacheEntry(uint64_t aNewSharedID);
sync SharesDocumentWith(PSHEntry entry) returns (bool sharesDocumentWith,
nsresult result);
async SetLoadTypeAsHistory();
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 (CrossProcessSHEntry childEntry);
sync GetChildSHEntryIfHasNoDynamicallyAddedChild(int32_t childOffset) returns (CrossProcessSHEntry childEntry);
sync ReplaceChild(PSHEntry newChildEntry) returns (nsresult result);
async ClearEntry(uint64_t aNewSharedID);
sync CreateLoadInfo() returns (nsDocShellLoadState loadState);
sync Clone() returns (CrossProcessSHEntry result);
sync SyncTreesForSubframeNavigation(nullable PSHEntry entry, MaybeDiscardedBrowsingContext BC,
MaybeDiscardedBrowsingContext ignoreBC)
returns (SwapEntriesDocshellData[] entriesToUpdate);
async UpdateLayoutHistoryState(bool scrollPositionOnly,
nsCString[] keys, PresState[] states);
sync __delete__();
};
} // namespace dom
} // namespace mozilla

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

@ -1,88 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PContent;
include protocol PSHEntry;
include DOMTypes;
using mozilla::dom::MaybeDiscardedBrowsingContext from "mozilla/dom/BrowsingContext.h";
using refcounted class mozilla::dom::CrossProcessSHEntry from "mozilla/dom/MaybeNewPSHEntry.h";
using refcounted class nsDocShellLoadState from "mozilla/dom/DocShellMessageUtils.h";
using struct nsID from "nsID.h";
using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
namespace mozilla {
namespace dom {
struct LoadSHEntryData
{
CrossProcessSHEntry shEntry;
MaybeDiscardedBrowsingContext browsingContext;
nsDocShellLoadState loadState;
};
union LoadSHEntryResult {
nsresult;
LoadSHEntryData[];
};
sync protocol PSHistory {
// IPDLParamTraits<dom::CrossProcessSHEntry*>::Write relies on PContent being
// the manager.
manager PContent;
parent:
sync GetCount() returns (int32_t count);
sync GetIndex() returns (int32_t index);
sync SetIndex(int32_t index) returns (nsresult result);
sync GetRequestedIndex() returns (int32_t index);
async InternalSetRequestedIndex(int32_t index);
sync GetEntryAtIndex(int32_t index) returns (nsresult result, CrossProcessSHEntry entry);
sync PurgeHistory(int32_t numEntries) returns (nsresult result);
sync ReloadCurrentEntry() returns (LoadSHEntryResult load);
sync GotoIndex(int32_t index) returns (LoadSHEntryResult load);
sync GetIndexOfEntry(PSHEntry entry) returns (int32_t index);
sync AddEntry(PSHEntry entry, bool persist) returns (nsresult result, int32_t entriesPurged);
async UpdateIndex();
sync ReplaceEntry(int32_t index, PSHEntry entry) returns (nsresult result);
sync NotifyOnHistoryReload() returns (bool ok);
async EvictOutOfRangeContentViewers(int32_t index);
async EvictAllContentViewers();
async RemoveDynEntries(int32_t index, PSHEntry entry);
sync RemoveEntries(nsID[] ids, int32_t index) returns (bool didRemove);
async RemoveFrameEntries(PSHEntry entry);
sync Reload(uint32_t reloadFlags) returns (LoadSHEntryResult load);
sync GetAllEntries() returns (CrossProcessSHEntry[] entries);
sync FindEntryForBFCache(uint64_t sharedID, bool includeCurrentEntry)
returns (CrossProcessSHEntry entries, int32_t startIndex);
async Evict(PSHEntry[] entry);
async EnsureCorrectEntryAtCurrIndex(PSHEntry entry);
async EvictContentViewersOrReplaceEntry(nullable PSHEntry newSHEntry, bool replace);
async NotifyListenersContentViewerEvicted(uint32_t numEvicted);
// See below for some explanation
sync AddToRootSessionHistory(bool cloneChildren, nullable PSHEntry OSHE, MaybeDiscardedBrowsingContext BC, PSHEntry entry,
uint32_t loadType, bool shouldPersist) returns (int32_t? previousEntryIndex, int32_t? loadedEntryIndex,
SwapEntriesDocshellData[] entriesToUpdate, int32_t entriesPurged, nsresult result);
// In CloneAndReplaceChild and SetChildHistoryEntry methods (which get called within this
// and above function) there are calls to SwapHistoryEntries to update entries in the docshell.
// We don't have access to the docshell in the parent
// process so we have to either wait to update the docshell or update it via an IPC call.
// We pass in the ChildID of the process who invoked the IPC to make decisions
// about whether we should update entries in the docshell via an IPC call -
// if the caller is a process different from where the docshell lives.
// Else, we return entries that we need to update in entriesToUpdate array
// and update the docshell with such entries in the child process.
sync AddChildSHEntryHelper(PSHEntry cloneRef, PSHEntry newEntry, MaybeDiscardedBrowsingContext BC,
bool cloneChildren) returns (SwapEntriesDocshellData[] entriesToUpdate,
int32_t entriesPurged, CrossProcessSHEntry entry, nsresult result);
async __delete__();
child:
async ReloadCurrentEntryFromChild();
};
} // namespace dom
} // namespace mozilla

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,127 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_SHEntryChild_h
#define mozilla_dom_SHEntryChild_h
#include "mozilla/dom/PSHEntryChild.h"
#include "mozilla/dom/MaybeNewPSHEntry.h"
#include "nsContentUtils.h"
#include "nsExpirationTracker.h"
#include "nsIBFCacheEntry.h"
#include "nsISHEntry.h"
#include "nsRect.h"
#include "nsSHEntryShared.h"
#include "nsStubMutationObserver.h"
class nsDocShellEditorData;
class nsIContentViewer;
class nsILayoutHistoryState;
class nsIMutableArray;
namespace mozilla {
namespace dom {
class SHistoryChild;
/**
* Implementation of the shared state for session history entries in the child
* process.
*/
class SHEntryChildShared final : public nsIBFCacheEntry,
public nsStubMutationObserver,
public SHEntrySharedChildState {
public:
static void Init();
static SHEntryChildShared* GetOrCreate(SHistoryChild* aSHistory,
uint64_t aSharedID);
static void Remove(uint64_t aSharedID);
static uint64_t CreateSharedID() {
return nsContentUtils::GenerateProcessSpecificId(++sNextSharedID);
}
static void EvictContentViewers(
const nsTArray<uint64_t>& aToEvictSharedStateIDs);
void NotifyListenersContentViewerEvicted(uint32_t aNumEvicted = 1);
NS_DECL_ISUPPORTS
NS_DECL_NSIBFCACHEENTRY
// The nsIMutationObserver bits we actually care about.
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
nsExpirationState* GetExpirationState() { return &mExpirationState; }
uint64_t GetID() { return mID; }
private:
static uint64_t sNextSharedID;
SHEntryChildShared(SHistoryChild* aSHistory, uint64_t aID);
~SHEntryChildShared();
friend class SHEntryChild;
already_AddRefed<SHEntryChildShared> Duplicate();
void RemoveFromExpirationTracker();
void SyncPresentationState();
void DropPresentationState();
nsresult SetContentViewer(nsIContentViewer* aViewer);
uint64_t mID;
RefPtr<SHistoryChild> mSHistory;
};
/**
* Session history entry actor for the child process.
*/
class SHEntryChild final : public PSHEntryChild,
public nsISHEntry,
public CrossProcessSHEntry {
friend class PSHEntryChild;
using PSHEntryChild::CrossProcessSHEntry;
public:
explicit SHEntryChild(const SHEntryChild* aClone)
: mShared(aClone->mShared.get()), mIPCActorDeleted(false) {}
SHEntryChild(SHistoryChild* aSHistory, uint64_t aSharedID)
: mShared(SHEntryChildShared::GetOrCreate(aSHistory, aSharedID)),
mIPCActorDeleted(false) {}
NS_DECL_ISUPPORTS
NS_DECL_NSISHENTRY
void EvictContentViewer();
protected:
void ActorDestroy(ActorDestroyReason aWhy) override {
mIPCActorDeleted = true;
}
private:
~SHEntryChild() = default;
RefPtr<SHEntryChildShared> mShared;
bool mIPCActorDeleted;
};
inline SHEntryChild* CrossProcessSHEntry::ToSHEntryChild() {
MOZ_ASSERT(XRE_IsContentProcess(), "Wrong side!");
return static_cast<SHEntryChild*>(this);
}
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_SHEntryChild_h */

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

@ -1,620 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SHEntryParent.h"
#include "SHistoryParent.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/MaybeNewPSHEntry.h"
#include "nsILayoutHistoryState.h"
#include "nsStructuredCloneContainer.h"
namespace mozilla {
namespace dom {
SHEntrySharedParent::SHEntrySharedParent(PContentParent* aContentParent,
LegacySHistory* aSHistory,
uint64_t aSharedID)
: SHEntrySharedParentState(aSHistory, aSharedID),
mContentParent(aContentParent) {}
void SHEntrySharedParent::Destroy() {
if (mContentParent &&
!static_cast<ContentParent*>(mContentParent.get())->IsDestroyed()) {
Unused << mContentParent->SendDestroySHEntrySharedState(mID);
}
SHEntrySharedParentState::Destroy();
}
LegacySHEntry::LegacySHEntry(PContentParent* aContentParent,
LegacySHistory* aSHistory, uint64_t aSharedID)
: nsSHEntry(new SHEntrySharedParent(aContentParent, aSHistory, aSharedID)),
mActor(nullptr) {}
NS_IMPL_ISUPPORTS_INHERITED0(LegacySHEntry, nsSHEntry)
SHEntryParent* LegacySHEntry::CreateActor() {
MOZ_ASSERT(!mActor);
mActor = new SHEntryParent(this);
return mActor;
}
MaybeNewPSHEntryParent LegacySHEntry::GetOrCreateActor(
PContentParent* aContentParent) {
if (mActor) {
return AsVariant(static_cast<PSHEntryParent*>(mActor));
}
nsCOMPtr<nsISHistory> shistory = do_QueryReferent(mShared->mSHistory);
return AsVariant(
NewPSHEntry{aContentParent->OpenPSHEntryEndpoint(CreateActor()),
static_cast<LegacySHistory*>(shistory.get())->GetActor(),
nullptr, mShared->mID});
}
void LegacySHEntry::AbandonBFCacheEntry(uint64_t aNewSharedID) {
mShared =
static_cast<SHEntrySharedParent*>(mShared.get())->Duplicate(aNewSharedID);
}
NS_IMETHODIMP
LegacySHEntry::GetBfcacheID(uint64_t* aBFCacheID) {
*aBFCacheID = mShared->GetID();
return NS_OK;
}
NS_IMETHODIMP
LegacySHEntry::Clone(nsISHEntry** aResult) {
nsCOMPtr<nsISHEntry> entry = new LegacySHEntry(*this);
entry.forget(aResult);
return NS_OK;
}
void SHEntryParent::ActorDestroy(ActorDestroyReason aWhy) {
mEntry->mActor = nullptr;
}
bool SHEntryParent::RecvGetURI(RefPtr<nsIURI>* aURI) {
*aURI = mEntry->GetURI();
return true;
}
bool SHEntryParent::RecvSetURI(nsIURI* aURI) {
DebugOnly<nsresult> rv = mEntry->SetURI(aURI);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetOriginalURI(RefPtr<nsIURI>* aOriginalURI) {
*aOriginalURI = mEntry->GetOriginalURI();
return true;
}
bool SHEntryParent::RecvSetOriginalURI(nsIURI* aOriginalURI) {
DebugOnly<nsresult> rv = mEntry->SetOriginalURI(aOriginalURI);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetResultPrincipalURI(
RefPtr<nsIURI>* aResultPrincipalURI) {
*aResultPrincipalURI = mEntry->GetResultPrincipalURI();
return true;
}
bool SHEntryParent::RecvSetResultPrincipalURI(nsIURI* aResultPrincipalURI) {
DebugOnly<nsresult> rv = mEntry->SetResultPrincipalURI(aResultPrincipalURI);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetLoadReplace(bool* aLoadReplace) {
*aLoadReplace = mEntry->GetLoadReplace();
return true;
}
bool SHEntryParent::RecvSetLoadReplace(const bool& aLoadReplace) {
DebugOnly<nsresult> rv = mEntry->SetLoadReplace(aLoadReplace);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetTitle(nsString* aTitle) {
DebugOnly<nsresult> rv = mEntry->GetTitle(*aTitle);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvSetTitle(const nsString& aTitle) {
DebugOnly<nsresult> rv = mEntry->SetTitle(aTitle);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetIsSubFrame(bool* aIsSubFrame) {
*aIsSubFrame = mEntry->GetIsSubFrame();
return true;
}
bool SHEntryParent::RecvSetIsSubFrame(const bool& aIsSubFrame) {
DebugOnly<nsresult> rv = mEntry->SetIsSubFrame(aIsSubFrame);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetReferrerInfo(
RefPtr<nsIReferrerInfo>* aReferrerInfo) {
*aReferrerInfo = mEntry->GetReferrerInfo();
return true;
}
bool SHEntryParent::RecvSetReferrerInfo(nsIReferrerInfo* aReferrerInfo) {
DebugOnly<nsresult> rv = mEntry->SetReferrerInfo(aReferrerInfo);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetSticky(bool* aSticky) {
*aSticky = mEntry->GetSticky();
return true;
}
bool SHEntryParent::RecvSetSticky(const bool& aSticky) {
DebugOnly<nsresult> rv = mEntry->SetSticky(aSticky);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetPostData(RefPtr<nsIInputStream>* aPostData) {
*aPostData = mEntry->GetPostData();
return true;
}
bool SHEntryParent::RecvSetPostData(nsIInputStream* aPostData) {
DebugOnly<nsresult> rv = mEntry->SetPostData(aPostData);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetParent(RefPtr<CrossProcessSHEntry>* aParentEntry) {
nsCOMPtr<nsISHEntry> parent = mEntry->GetParent();
*aParentEntry = parent.forget().downcast<LegacySHEntry>();
return true;
}
bool SHEntryParent::RecvSetParent(PSHEntryParent* aParentEntry) {
DebugOnly<nsresult> rv = mEntry->SetParent(
aParentEntry ? static_cast<SHEntryParent*>(aParentEntry)->mEntry.get()
: nullptr);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetLoadType(uint32_t* aLoadType) {
*aLoadType = mEntry->GetLoadType();
return true;
}
bool SHEntryParent::RecvSetLoadType(const uint32_t& aLoadType) {
DebugOnly<nsresult> rv = mEntry->SetLoadType(aLoadType);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetID(uint32_t* aID) {
*aID = mEntry->GetID();
return true;
}
bool SHEntryParent::RecvSetID(const uint32_t& aID) {
DebugOnly<nsresult> rv = mEntry->SetID(aID);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetCacheKey(uint32_t* aCacheKey) {
*aCacheKey = mEntry->GetCacheKey();
return true;
}
bool SHEntryParent::RecvSetCacheKey(const uint32_t& aCacheKey) {
DebugOnly<nsresult> rv = mEntry->SetCacheKey(aCacheKey);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetExpirationStatus(bool* aExpirationStatus) {
*aExpirationStatus = mEntry->GetExpirationStatus();
return true;
}
bool SHEntryParent::RecvSetExpirationStatus(const bool& aExpirationStatus) {
DebugOnly<nsresult> rv = mEntry->SetExpirationStatus(aExpirationStatus);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetContentType(nsCString* aContentType) {
DebugOnly<nsresult> rv = mEntry->GetContentType(*aContentType);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvSetContentType(const nsCString& aContentType) {
DebugOnly<nsresult> rv = mEntry->SetContentType(aContentType);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetURIWasModified(bool* aURIWasModified) {
*aURIWasModified = mEntry->GetURIWasModified();
return true;
}
bool SHEntryParent::RecvSetURIWasModified(const bool& aURIWasModified) {
DebugOnly<nsresult> rv = mEntry->SetURIWasModified(aURIWasModified);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetTriggeringPrincipal(
RefPtr<nsIPrincipal>* aTriggeringPrincipal) {
*aTriggeringPrincipal = mEntry->GetTriggeringPrincipal();
return true;
}
bool SHEntryParent::RecvSetTriggeringPrincipal(
nsIPrincipal* aTriggeringPrincipal) {
DebugOnly<nsresult> rv = mEntry->SetTriggeringPrincipal(aTriggeringPrincipal);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetPrincipalToInherit(
RefPtr<nsIPrincipal>* aPrincipalToInherit) {
*aPrincipalToInherit = mEntry->GetPrincipalToInherit();
return true;
}
bool SHEntryParent::RecvSetPrincipalToInherit(
nsIPrincipal* aPrincipalToInherit) {
DebugOnly<nsresult> rv = mEntry->SetPrincipalToInherit(aPrincipalToInherit);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetStoragePrincipalToInherit(
RefPtr<nsIPrincipal>* aStoragePrincipalToInherit) {
*aStoragePrincipalToInherit = mEntry->GetStoragePrincipalToInherit();
return true;
}
bool SHEntryParent::RecvSetStoragePrincipalToInherit(
nsIPrincipal* aStoragePrincipalToInherit) {
DebugOnly<nsresult> rv =
mEntry->SetStoragePrincipalToInherit(aStoragePrincipalToInherit);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetCsp(RefPtr<nsIContentSecurityPolicy>* aCsp) {
*aCsp = mEntry->GetCsp();
return true;
}
bool SHEntryParent::RecvSetCsp(nsIContentSecurityPolicy* aCsp) {
DebugOnly<nsresult> rv = mEntry->SetCsp(aCsp);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetStateData(ClonedMessageData* aData) {
nsCOMPtr<nsIStructuredCloneContainer> container = mEntry->GetStateData();
if (container) {
static_cast<nsStructuredCloneContainer*>(container.get())
->BuildClonedMessageDataForParent(
static_cast<ContentParent*>(ToplevelProtocol()), *aData);
}
return true;
}
bool SHEntryParent::RecvSetStateData(ClonedMessageData&& aData) {
// FIXME Need more data! Should we signal null separately from the
// ClonedMessageData?
if (aData.data().data.Size() == 0) {
mEntry->SetStateData(nullptr);
} else {
RefPtr<nsStructuredCloneContainer> container =
new nsStructuredCloneContainer();
container->StealFromClonedMessageDataForParent(aData);
mEntry->SetStateData(container);
}
return true;
}
bool SHEntryParent::RecvGetDocshellID(nsID* aDocshellID) {
DebugOnly<nsresult> rv = mEntry->GetDocshellID(*aDocshellID);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvSetDocshellID(const nsID& aDocshellID) {
DebugOnly<nsresult> rv = mEntry->SetDocshellID(aDocshellID);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetIsSrcdocEntry(bool* aIsSrcdocEntry) {
*aIsSrcdocEntry = mEntry->GetIsSrcdocEntry();
return true;
}
bool SHEntryParent::RecvGetSrcdocData(nsString* aSrcdocData) {
DebugOnly<nsresult> rv = mEntry->GetSrcdocData(*aSrcdocData);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvSetSrcdocData(const nsString& aSrcdocData) {
DebugOnly<nsresult> rv = mEntry->SetSrcdocData(aSrcdocData);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetBaseURI(RefPtr<nsIURI>* aBaseURI) {
*aBaseURI = mEntry->GetBaseURI();
return true;
}
bool SHEntryParent::RecvSetBaseURI(nsIURI* aBaseURI) {
DebugOnly<nsresult> rv = mEntry->SetBaseURI(aBaseURI);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetScrollRestorationIsManual(
bool* aScrollRestorationIsManual) {
DebugOnly<nsresult> rv =
mEntry->GetScrollRestorationIsManual(aScrollRestorationIsManual);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvSetScrollRestorationIsManual(
const bool& aScrollRestorationIsManual) {
DebugOnly<nsresult> rv =
mEntry->SetScrollRestorationIsManual(aScrollRestorationIsManual);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetLoadedInThisProcess(bool* aLoadedInThisProcess) {
*aLoadedInThisProcess = mEntry->GetLoadedInThisProcess();
return true;
}
bool SHEntryParent::RecvGetLastTouched(uint32_t* aLastTouched) {
*aLastTouched = mEntry->GetLastTouched();
return true;
}
bool SHEntryParent::RecvSetLastTouched(const uint32_t& aLastTouched) {
DebugOnly<nsresult> rv = mEntry->SetLastTouched(aLastTouched);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetChildCount(int32_t* aChildCount) {
*aChildCount = mEntry->GetChildCount();
return true;
}
bool SHEntryParent::RecvGetPersist(bool* aPersist) {
*aPersist = mEntry->GetPersist();
return true;
}
bool SHEntryParent::RecvSetPersist(const bool& aPersist) {
DebugOnly<nsresult> rv = mEntry->SetPersist(aPersist);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetScrollPosition(int32_t* aX, int32_t* aY) {
DebugOnly<nsresult> rv = mEntry->GetScrollPosition(aX, aY);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvSetScrollPosition(const int32_t& aX,
const int32_t& aY) {
DebugOnly<nsresult> rv = mEntry->SetScrollPosition(aX, aY);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvGetViewerBounds(nsIntRect* aBounds) {
mEntry->GetViewerBounds(*aBounds);
return true;
}
bool SHEntryParent::RecvSetViewerBounds(const nsIntRect& aBounds) {
mEntry->SetViewerBounds(aBounds);
return true;
}
bool SHEntryParent::RecvCreate(
nsIURI* aURI, const nsString& aTitle, nsIInputStream* aInputStream,
const uint32_t& aCacheKey, const nsCString& aContentType,
nsIPrincipal* aTriggeringPrincipal, nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aStoragePrincipalToInherit, nsIContentSecurityPolicy* aCsp,
const nsID& aDocshellID, const bool& aDynamicCreation, nsIURI* aOriginalURI,
nsIURI* aResultPrincipalURI, const bool& aLoadReplace,
nsIReferrerInfo* aReferrerInfo, const nsAString& srcdoc,
const bool& srcdocEntry, nsIURI* aBaseURI, const bool& aSaveLayoutState,
const bool& aExpired) {
DebugOnly<nsresult> rv = mEntry->Create(
aURI, aTitle, aInputStream, aCacheKey, aContentType, aTriggeringPrincipal,
aPrincipalToInherit, aStoragePrincipalToInherit, aCsp, aDocshellID,
aDynamicCreation, aOriginalURI, aResultPrincipalURI, aLoadReplace,
aReferrerInfo, srcdoc, srcdocEntry, aBaseURI, aSaveLayoutState, aExpired);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvHasDetachedEditor(bool* aHasDetachedEditor) {
*aHasDetachedEditor = mEntry->HasDetachedEditor();
return true;
}
bool SHEntryParent::RecvIsDynamicallyAdded(bool* aIsDynamicallyAdded) {
*aIsDynamicallyAdded = mEntry->IsDynamicallyAdded();
return true;
}
bool SHEntryParent::RecvHasDynamicallyAddedChild(
bool* aHasDynamicallyAddedChild) {
DebugOnly<nsresult> rv =
mEntry->HasDynamicallyAddedChild(aHasDynamicallyAddedChild);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvDocshellID(nsID* aDocshellID) {
mEntry->GetDocshellID(*aDocshellID);
return true;
}
bool SHEntryParent::RecvAdoptBFCacheEntry(PSHEntryParent* aEntry,
nsresult* aResult) {
*aResult =
mEntry->AdoptBFCacheEntry(static_cast<SHEntryParent*>(aEntry)->mEntry);
return true;
}
bool SHEntryParent::RecvAbandonBFCacheEntry(const uint64_t& aNewSharedID) {
mEntry->AbandonBFCacheEntry(aNewSharedID);
return true;
}
bool SHEntryParent::RecvSharesDocumentWith(PSHEntryParent* aEntry,
bool* aSharesDocumentWith,
nsresult* aResult) {
*aResult = mEntry->SharesDocumentWith(
static_cast<SHEntryParent*>(aEntry)->mEntry, aSharesDocumentWith);
return true;
}
bool SHEntryParent::RecvSetLoadTypeAsHistory() {
DebugOnly<nsresult> rv = mEntry->SetLoadTypeAsHistory();
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
return true;
}
bool SHEntryParent::RecvAddChild(PSHEntryParent* aChild, const int32_t& aOffset,
const bool& aUseRemoteSubframes,
nsresult* aResult) {
*aResult = mEntry->AddChild(
aChild ? static_cast<SHEntryParent*>(aChild)->mEntry.get() : nullptr,
aOffset, aUseRemoteSubframes);
return true;
}
bool SHEntryParent::RecvRemoveChild(PSHEntryParent* aChild, nsresult* aResult) {
*aResult = mEntry->RemoveChild(static_cast<SHEntryParent*>(aChild)->mEntry);
return true;
}
bool SHEntryParent::RecvGetChildAt(const int32_t& aIndex,
RefPtr<CrossProcessSHEntry>* aChild) {
nsCOMPtr<nsISHEntry> child;
DebugOnly<nsresult> rv = mEntry->GetChildAt(aIndex, getter_AddRefs(child));
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
*aChild = child.forget().downcast<LegacySHEntry>();
return true;
}
bool SHEntryParent::RecvGetChildSHEntryIfHasNoDynamicallyAddedChild(
const int32_t& aChildOffset, RefPtr<CrossProcessSHEntry>* aChild) {
nsCOMPtr<nsISHEntry> child;
mEntry->GetChildSHEntryIfHasNoDynamicallyAddedChild(aChildOffset,
getter_AddRefs(child));
*aChild = child.forget().downcast<LegacySHEntry>();
return true;
}
bool SHEntryParent::RecvReplaceChild(PSHEntryParent* aNewChild,
nsresult* aResult) {
*aResult =
mEntry->ReplaceChild(static_cast<SHEntryParent*>(aNewChild)->mEntry);
return true;
}
bool SHEntryParent::RecvClearEntry(const uint64_t& aNewSharedID) {
mEntry->ClearEntry();
mEntry->AbandonBFCacheEntry(aNewSharedID);
return true;
}
bool SHEntryParent::RecvCreateLoadInfo(
RefPtr<nsDocShellLoadState>* aLoadState) {
mEntry->CreateLoadInfo(getter_AddRefs(*aLoadState));
return true;
}
bool SHEntryParent::RecvUpdateLayoutHistoryState(
const bool& aScrollPositionOnly, nsTArray<nsCString>&& aKeys,
nsTArray<PresState>&& aStates) {
nsCOMPtr<nsILayoutHistoryState> layoutHistoryState;
// InitLayoutHistoryState creates a new object only if there isn't one
// already.
mEntry->InitLayoutHistoryState(getter_AddRefs(layoutHistoryState));
layoutHistoryState->Reset();
if (aKeys.Length() != aStates.Length()) {
NS_WARNING("Bogus data sent from the child process?");
return true;
}
layoutHistoryState->SetScrollPositionOnly(aScrollPositionOnly);
for (uint32_t i = 0; i < aKeys.Length(); ++i) {
PresState& state = aStates[i];
UniquePtr<PresState> newState = MakeUnique<PresState>(state);
layoutHistoryState->AddState(aKeys[i], std::move(newState));
}
return true;
}
bool SHEntryParent::RecvClone(RefPtr<CrossProcessSHEntry>* aResult) {
nsCOMPtr<nsISHEntry> result;
DebugOnly<nsresult> rv =
static_cast<LegacySHEntry*>(mEntry)->Clone(getter_AddRefs(result));
MOZ_ASSERT(NS_SUCCEEDED(rv), "Didn't expect this to fail.");
*aResult = result.forget().downcast<LegacySHEntry>();
return true;
}
bool SHEntryParent::RecvSyncTreesForSubframeNavigation(
PSHEntryParent* aSHEntry, const MaybeDiscarded<BrowsingContext>& aBC,
const MaybeDiscarded<BrowsingContext>& aIgnoreBC,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate) {
nsTArray<EntriesAndBrowsingContextData> entriesToSendOverIPC;
// aBC or aIgnoreBC can be discarded but we can update them anyway if they are
// not null
mEntry->SyncTreesForSubframeNavigation(
static_cast<ContentParent*>(Manager())->ChildID(),
aSHEntry ? static_cast<SHEntryParent*>(aSHEntry)->mEntry.get() : nullptr,
aBC.GetMaybeDiscarded(), aIgnoreBC.GetMaybeDiscarded(),
&entriesToSendOverIPC);
SHistoryParent::CreateActorsForSwapEntries(entriesToSendOverIPC,
aEntriesToUpdate, Manager());
return true;
}
} // namespace dom
} // namespace mozilla

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

@ -1,225 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_SHistoryEntry_h
#define mozilla_dom_SHistoryEntry_h
#include "mozilla/dom/PSHEntryParent.h"
#include "mozilla/dom/MaybeNewPSHEntry.h"
#include "mozilla/WeakPtr.h"
#include "nsSHEntry.h"
#include "nsSHEntryShared.h"
namespace mozilla {
namespace dom {
class LegacySHistory;
class PContentParent;
class SHEntryParent;
/**
* Implementation of the shared state for session history entries in the parent
* process.
*/
class SHEntrySharedParent : public SHEntrySharedParentState {
public:
SHEntrySharedParent(PContentParent* aContentParent, LegacySHistory* aSHistory,
uint64_t aSharedID);
already_AddRefed<SHEntrySharedParent> Duplicate(uint64_t aNewSharedID) {
RefPtr<SHEntrySharedParent> shared =
new SHEntrySharedParent(this, aNewSharedID);
shared->CopyFrom(this);
return shared.forget();
}
PContentParent* GetContentParent() { return mContentParent.get(); }
protected:
SHEntrySharedParent(SHEntrySharedParent* aDuplicate, uint64_t aSharedID)
: SHEntrySharedParentState(aDuplicate, aSharedID),
mContentParent(aDuplicate->mContentParent) {}
void Destroy() override;
private:
mozilla::WeakPtr<PContentParent> mContentParent;
};
/**
* Session history entry implementation based on the legacy implementation that
* used to live in the child process. Ideally this wouldn't implement nsISHEntry
* (it should only ever be accessed by SHEntryParent and LegacySHistory).
* The actor is (re)created as needed, whenever we need to return an entry to
* the child process. The lifetime is determined by the child side.
*/
class LegacySHEntry final : public nsSHEntry, public CrossProcessSHEntry {
public:
LegacySHEntry(PContentParent* aContentParent, LegacySHistory* aSHistory,
uint64_t aSharedID);
explicit LegacySHEntry(const LegacySHEntry& aEntry)
: nsSHEntry(aEntry), mActor(nullptr) {}
NS_DECL_ISUPPORTS_INHERITED
MaybeNewPSHEntryParent GetOrCreateActor(PContentParent* aContentParent);
using nsSHEntry::AbandonBFCacheEntry;
void AbandonBFCacheEntry(uint64_t aNewSharedID);
NS_IMETHODIMP GetBfcacheID(uint64_t* aBFCacheID) override;
uint64_t GetSharedStateID() const { return mShared->GetID(); }
dom::SHEntrySharedParentState* GetSharedState() const {
return mShared.get();
}
NS_IMETHOD Clone(nsISHEntry** aResult) override;
private:
friend class SHEntryParent;
friend class SHistoryParent;
~LegacySHEntry() = default;
SHEntryParent* CreateActor();
SHEntryParent* mActor;
};
/**
* Session history entry actor for the parent process. Forwards to the legacy
* implementation that used to live in the child process (see LegacySHEntry).
*/
class SHEntryParent final : public PSHEntryParent {
friend class PSHEntryParent;
friend class SHistoryParent;
friend class ContentParent;
public:
explicit SHEntryParent(LegacySHEntry* aEntry)
: PSHEntryParent(), mEntry(aEntry) {}
LegacySHEntry* GetSHEntry() { return mEntry; }
protected:
void ActorDestroy(ActorDestroyReason aWhy) override;
private:
bool RecvGetURI(RefPtr<nsIURI>* aURI);
bool RecvSetURI(nsIURI* aURI);
bool RecvGetOriginalURI(RefPtr<nsIURI>* aOriginalURI);
bool RecvSetOriginalURI(nsIURI* aOriginalURI);
bool RecvGetResultPrincipalURI(RefPtr<nsIURI>* aResultPrincipalURI);
bool RecvSetResultPrincipalURI(nsIURI* aResultPrincipalURI);
bool RecvGetLoadReplace(bool* aLoadReplace);
bool RecvSetLoadReplace(const bool& aLoadReplace);
bool RecvGetTitle(nsString* aTitle);
bool RecvSetTitle(const nsString& aTitle);
bool RecvGetIsSubFrame(bool* aIsSubFrame);
bool RecvSetIsSubFrame(const bool& aIsSubFrame);
bool RecvGetReferrerInfo(RefPtr<nsIReferrerInfo>* aReferrerInfo);
bool RecvSetReferrerInfo(nsIReferrerInfo* aReferrerInfo);
bool RecvGetSticky(bool* aSticky);
bool RecvSetSticky(const bool& aSticky);
bool RecvGetPostData(RefPtr<nsIInputStream>* aPostData);
bool RecvSetPostData(nsIInputStream* aPostData);
bool RecvGetParent(RefPtr<CrossProcessSHEntry>* aParentEntry);
bool RecvSetParent(PSHEntryParent* aParentEntry);
bool RecvGetLoadType(uint32_t* aLoadType);
bool RecvSetLoadType(const uint32_t& aLoadType);
bool RecvGetID(uint32_t* aID);
bool RecvSetID(const uint32_t& aID);
bool RecvGetCacheKey(uint32_t* aCacheKey);
bool RecvSetCacheKey(const uint32_t& aCacheKey);
bool RecvGetExpirationStatus(bool* aExpirationStatus);
bool RecvSetExpirationStatus(const bool& aExpirationStatus);
bool RecvGetContentType(nsCString* aContentType);
bool RecvSetContentType(const nsCString& aContentType);
bool RecvGetURIWasModified(bool* aURIWasModified);
bool RecvSetURIWasModified(const bool& aURIWasModified);
bool RecvGetTriggeringPrincipal(RefPtr<nsIPrincipal>* aTriggeringPrincipal);
bool RecvSetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal);
bool RecvGetPrincipalToInherit(RefPtr<nsIPrincipal>* aPrincipalToInherit);
bool RecvSetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit);
bool RecvGetStoragePrincipalToInherit(
RefPtr<nsIPrincipal>* aStoragePrincipalToInherit);
bool RecvSetStoragePrincipalToInherit(
nsIPrincipal* aStoragePrincipalToInherit);
bool RecvGetCsp(RefPtr<nsIContentSecurityPolicy>* aCsp);
bool RecvSetCsp(nsIContentSecurityPolicy* aCsp);
bool RecvGetStateData(ClonedMessageData* aData);
bool RecvSetStateData(ClonedMessageData&& aData);
bool RecvGetDocshellID(nsID* aDocshellID);
bool RecvSetDocshellID(const nsID& aDocshellID);
bool RecvGetIsSrcdocEntry(bool* aIsSrcdocEntry);
bool RecvGetSrcdocData(nsString* aSrcdocData);
bool RecvSetSrcdocData(const nsString& aSrcdocData);
bool RecvGetBaseURI(RefPtr<nsIURI>* aBaseURI);
bool RecvSetBaseURI(nsIURI* aBaseURI);
bool RecvGetScrollRestorationIsManual(bool* aScrollRestorationIsManual);
bool RecvSetScrollRestorationIsManual(const bool& aScrollRestorationIsManual);
bool RecvGetLoadedInThisProcess(bool* aLoadedInThisProcess);
bool RecvGetLastTouched(uint32_t* aLastTouched);
bool RecvSetLastTouched(const uint32_t& aLastTouched);
bool RecvGetChildCount(int32_t* aChildCount);
bool RecvGetPersist(bool* aPersist);
bool RecvSetPersist(const bool& aPersist);
bool RecvGetScrollPosition(int32_t* aX, int32_t* aY);
bool RecvSetScrollPosition(const int32_t& aX, const int32_t& aY);
bool RecvGetViewerBounds(nsIntRect* aBounds);
bool RecvSetViewerBounds(const nsIntRect& aBounds);
bool RecvCreate(nsIURI* aURI, const nsString& aTitle,
nsIInputStream* aInputStream, const uint32_t& aCacheKey,
const nsCString& aContentType,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aStoragePrincipalToInherit,
nsIContentSecurityPolicy* aCsp, const nsID& aDocshellID,
const bool& aDynamicCreation, nsIURI* aOriginalURI,
nsIURI* aResultPrincipalURI, const bool& aLoadReplace,
nsIReferrerInfo* aReferrerInfo, const nsAString& srcdoc,
const bool& srcdocEntry, nsIURI* aBaseURI,
const bool& aSaveLayoutState, const bool& aExpired);
bool RecvClone(PSHEntryParent** aCloneEntry);
bool RecvHasDetachedEditor(bool* aHasDetachedEditor);
bool RecvIsDynamicallyAdded(bool* aIsDynamicallyAdded);
bool RecvHasDynamicallyAddedChild(bool* aHasDynamicallyAddedChild);
bool RecvDocshellID(nsID* aDocshellID);
bool RecvAdoptBFCacheEntry(PSHEntryParent* aEntry, nsresult* aResult);
bool RecvAbandonBFCacheEntry(const uint64_t& aNewSharedID);
bool RecvSharesDocumentWith(PSHEntryParent* aEntry, bool* aSharesDocumentWith,
nsresult* aResult);
bool RecvSetLoadTypeAsHistory();
bool RecvAddChild(PSHEntryParent* aChild, const int32_t& aOffset,
const bool& aUseRemoteSubframes, nsresult* aResult);
bool RecvRemoveChild(PSHEntryParent* aChild, nsresult* aResult);
bool RecvGetChildAt(const int32_t& aIndex,
RefPtr<CrossProcessSHEntry>* aChild);
bool RecvGetChildSHEntryIfHasNoDynamicallyAddedChild(
const int32_t& aChildOffset, RefPtr<CrossProcessSHEntry>* aChild);
bool RecvReplaceChild(PSHEntryParent* aNewChild, nsresult* aResult);
bool RecvClearEntry(const uint64_t& aNewSharedID);
bool RecvCreateLoadInfo(RefPtr<nsDocShellLoadState>* aLoadState);
bool RecvClone(RefPtr<CrossProcessSHEntry>* aResult);
bool RecvSyncTreesForSubframeNavigation(
PSHEntryParent* aSHEntry, const MaybeDiscarded<BrowsingContext>& aBC,
const MaybeDiscarded<BrowsingContext>& aIgnoreBC,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate);
bool RecvUpdateLayoutHistoryState(const bool& aScrollPositionOnly,
nsTArray<nsCString>&& aKeys,
nsTArray<PresState>&& aStates);
RefPtr<LegacySHEntry> mEntry;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_SHEntryParent_h */

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

@ -1,467 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SHistoryChild.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/PSHistoryChild.h"
#include "nsDocShell.h"
#include "nsISHistoryListener.h"
#include "SHEntryChild.h"
namespace mozilla {
namespace dom {
class SwapEntriesDocshellData;
}
} // namespace mozilla
#define CONTENT_VIEWER_TIMEOUT_SECONDS \
"browser.sessionhistory.contentViewerTimeout"
// Default this to time out unused content viewers after 30 minutes
#define CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT (30 * 60)
namespace mozilla {
namespace dom {
void SHistoryChild::HistoryTracker::NotifyExpired(SHEntryChildShared* aObj) {
RemoveObject(aObj);
mSHistory->EvictExpiredContentViewerForEntry(aObj);
}
SHistoryChild::SHistoryChild(BrowsingContext* aRootBC)
: mRootDocShell(static_cast<nsDocShell*>(aRootBC->GetDocShell())),
mIPCActorDeleted(false) {
// Bind mHistoryTracker's event target to the tabGroup for aRootBC.
// Maybe move this to ChildSHistory?
nsCOMPtr<nsPIDOMWindowOuter> win = aRootBC->GetDOMWindow();
if (win) {
// Seamonkey moves shistory between <xul:browser>s when restoring a tab.
// Let's try not to break our friend too badly...
if (mHistoryTracker) {
NS_WARNING(
"Change the root docshell of a shistory is unsafe and "
"potentially problematic.");
mHistoryTracker->AgeAllGenerations();
}
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(win);
mHistoryTracker = mozilla::MakeUnique<SHistoryChild::HistoryTracker>(
this,
mozilla::Preferences::GetUint(CONTENT_VIEWER_TIMEOUT_SECONDS,
CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT),
global->EventTargetFor(mozilla::TaskCategory::Other));
}
}
NS_IMPL_ADDREF(SHistoryChild)
NS_IMETHODIMP_(MozExternalRefCountType) SHistoryChild::Release() {
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release");
NS_ASSERT_OWNINGTHREAD(SHEntryChild);
nsrefcnt count = --mRefCnt;
NS_LOG_RELEASE(this, count, "SHistoryChild");
if (count == 0) {
mRefCnt = 1; /* stabilize */
delete this;
return 0;
}
if (count == 1 && !mIPCActorDeleted) {
Unused << Send__delete__(this);
}
return count;
}
NS_IMPL_QUERY_INTERFACE(SHistoryChild, nsISHistory, nsISupportsWeakReference)
NS_IMETHODIMP
SHistoryChild::GetCount(int32_t* aCount) {
return SendGetCount(aCount) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SHistoryChild::GetIndex(int32_t* aIndex) {
return SendGetIndex(aIndex) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SHistoryChild::SetIndex(int32_t aIndex) {
nsresult rv;
return SendSetIndex(aIndex, &rv) ? rv : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SHistoryChild::GetRequestedIndex(int32_t* aRequestedIndex) {
return SendGetRequestedIndex(aRequestedIndex) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP_(void)
SHistoryChild::InternalSetRequestedIndex(int32_t aRequestedIndex) {
SendInternalSetRequestedIndex(aRequestedIndex);
}
NS_IMETHODIMP
SHistoryChild::GetEntryAtIndex(int32_t aIndex, nsISHEntry** aResult) {
nsresult rv;
RefPtr<CrossProcessSHEntry> entry;
if (!SendGetEntryAtIndex(aIndex, &rv, &entry)) {
return NS_ERROR_FAILURE;
}
NS_ENSURE_SUCCESS(rv, rv);
*aResult = entry ? do_AddRef(entry->ToSHEntryChild()).take() : nullptr;
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::PurgeHistory(int32_t aNumEntries) {
nsresult rv;
if (!SendPurgeHistory(aNumEntries, &rv)) {
return NS_ERROR_FAILURE;
}
NS_ENSURE_SUCCESS(rv, rv);
if (mRootDocShell) {
mRootDocShell->HistoryPurged(aNumEntries);
}
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::AddSHistoryListener(nsISHistoryListener* aListener) {
NS_ENSURE_ARG_POINTER(aListener);
// Check if the listener supports Weak Reference. This is a must.
// This listener functionality is used by embedders and we want to
// have the right ownership with who ever listens to SHistory
nsWeakPtr listener = do_GetWeakReference(aListener);
if (!listener) {
return NS_ERROR_FAILURE;
}
mListeners.AppendElementUnlessExists(listener);
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::RemoveSHistoryListener(nsISHistoryListener* aListener) {
// Make sure the listener that wants to be removed is the
// one we have in store.
nsWeakPtr listener = do_GetWeakReference(aListener);
mListeners.RemoveElement(listener);
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::ReloadCurrentEntry() {
LoadSHEntryResult loadResult;
if (!SendReloadCurrentEntry(&loadResult)) {
return NS_ERROR_FAILURE;
}
if (loadResult.type() == LoadSHEntryResult::Tnsresult) {
return loadResult;
}
return LoadURI(loadResult);
}
NS_IMETHODIMP
SHistoryChild::GotoIndex(int32_t aIndex) {
LoadSHEntryResult loadResult;
if (!SendGotoIndex(aIndex, &loadResult)) {
return NS_ERROR_FAILURE;
}
if (loadResult.type() == LoadSHEntryResult::Tnsresult) {
return loadResult;
}
return LoadURI(loadResult);
}
NS_IMETHODIMP_(int32_t)
SHistoryChild::GetIndexOfEntry(nsISHEntry* aEntry) {
int32_t index;
if (!SendGetIndexOfEntry(static_cast<SHEntryChild*>(aEntry), &index)) {
return 0;
}
return index;
}
NS_IMETHODIMP
SHistoryChild::AddEntry(nsISHEntry* aEntry, bool aPersist) {
NS_ENSURE_ARG(aEntry);
nsresult rv;
int32_t entriesPurged;
if (!SendAddEntry(static_cast<SHEntryChild*>(aEntry), aPersist, &rv,
&entriesPurged)) {
return NS_ERROR_FAILURE;
}
NS_ENSURE_SUCCESS(rv, rv);
if (mRootDocShell) {
aEntry->SetDocshellID(mRootDocShell->HistoryID());
if (entriesPurged > 0) {
mRootDocShell->HistoryPurged(entriesPurged);
}
}
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::UpdateIndex(void) {
return SendUpdateIndex() ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SHistoryChild::ReplaceEntry(int32_t aIndex, nsISHEntry* aReplaceEntry) {
nsresult rv;
if (!SendReplaceEntry(aIndex, static_cast<SHEntryChild*>(aReplaceEntry),
&rv)) {
return NS_ERROR_FAILURE;
}
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::NotifyOnHistoryReload(bool* _retval) {
return SendNotifyOnHistoryReload(_retval) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SHistoryChild::EvictOutOfRangeContentViewers(int32_t aIndex) {
// FIXME Need to get out of range entries and entries that are safe (to
// compare content viewers so we don't evict live content viewers).
return SendEvictOutOfRangeContentViewers(aIndex) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SHistoryChild::EvictExpiredContentViewerForEntry(nsIBFCacheEntry* aBFEntry) {
SHEntryChildShared* shared = static_cast<SHEntryChildShared*>(aBFEntry);
RefPtr<CrossProcessSHEntry> entry;
int32_t index;
if (!SendFindEntryForBFCache(shared->GetID(), false, &entry, &index)) {
return NS_ERROR_FAILURE;
}
RefPtr<SHEntryChild> shEntry;
if (entry && (shEntry = entry->ToSHEntryChild())) {
shEntry->EvictContentViewer();
SendEvict(nsTArray<PSHEntryChild*>({shEntry.get()}));
}
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::EvictAllContentViewers(void) {
nsTArray<RefPtr<CrossProcessSHEntry>> entries;
if (!SendGetAllEntries(&entries)) {
return NS_ERROR_FAILURE;
}
// Keep a strong reference to all the entries, we're going to send the array
// back to the parent!
nsTArray<RefPtr<SHEntryChild>> shEntries(entries.Length());
for (RefPtr<CrossProcessSHEntry>& entry : entries) {
RefPtr<SHEntryChild> shEntry = entry->ToSHEntryChild();
shEntry->EvictContentViewer();
shEntries.AppendElement(shEntry.forget());
}
nsTArray<PSHEntryChild*> pshEntries;
pshEntries.AppendElements(shEntries);
SendEvict(pshEntries);
return NS_OK;
}
NS_IMETHODIMP_(void)
SHistoryChild::EvictContentViewersOrReplaceEntry(nsISHEntry* aNewSHEntry,
bool aReplace) {
SendEvictContentViewersOrReplaceEntry(static_cast<SHEntryChild*>(aNewSHEntry),
aReplace);
}
NS_IMETHODIMP_(void)
SHistoryChild::AddToExpirationTracker(nsIBFCacheEntry* aBFEntry) {
RefPtr<SHEntryChildShared> entry = static_cast<SHEntryChildShared*>(aBFEntry);
if (mHistoryTracker && entry) {
mHistoryTracker->AddObject(entry);
}
}
NS_IMETHODIMP_(void)
SHistoryChild::RemoveFromExpirationTracker(nsIBFCacheEntry* aBFEntry) {
RefPtr<SHEntryChildShared> entry = static_cast<SHEntryChildShared*>(aBFEntry);
MOZ_ASSERT(mHistoryTracker && !mHistoryTracker->IsEmpty());
if (mHistoryTracker && entry) {
mHistoryTracker->RemoveObject(entry);
}
}
NS_IMETHODIMP_(void)
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) {
RefPtr<CrossProcessSHEntry> entry;
int32_t index;
if (!SendFindEntryForBFCache(
static_cast<SHEntryChildShared*>(aBFEntry)->GetID(), true, &entry,
&index)) {
return;
}
RefPtr<SHEntryChild> shEntry;
if (entry && (shEntry = entry->ToSHEntryChild())) {
RemoveDynEntries(index, shEntry);
}
}
NS_IMETHODIMP_(void)
SHistoryChild::RemoveEntries(nsTArray<nsID>& aIDs, int32_t aStartIndex) {
bool didRemove = false;
if (SendRemoveEntries(aIDs, aStartIndex, &didRemove) && didRemove &&
mRootDocShell) {
mRootDocShell->DispatchLocationChangeEvent();
}
}
NS_IMETHODIMP_(void)
SHistoryChild::RemoveFrameEntries(nsISHEntry* aEntry) {
SendRemoveFrameEntries(static_cast<SHEntryChild*>(aEntry));
}
NS_IMETHODIMP
SHistoryChild::Reload(uint32_t aReloadFlags) {
LoadSHEntryResult loadResult;
if (!SendReload(aReloadFlags, &loadResult)) {
return NS_ERROR_FAILURE;
}
if (loadResult.type() == LoadSHEntryResult::Tnsresult) {
return loadResult;
}
return LoadURI(loadResult);
}
NS_IMETHODIMP
SHistoryChild::CreateEntry(nsISHEntry** aEntry) {
uint64_t sharedID = SHEntryChildShared::CreateSharedID();
RefPtr<SHEntryChild> entry = static_cast<SHEntryChild*>(
Manager()->SendPSHEntryConstructor(this, sharedID));
if (!entry) {
return NS_ERROR_FAILURE;
}
entry.forget(aEntry);
return NS_OK;
}
nsresult SHistoryChild::LoadURI(nsTArray<LoadSHEntryData>& aLoadData) {
for (LoadSHEntryData& l : aLoadData) {
if (l.browsingContext().IsNullOrDiscarded()) {
continue;
}
nsCOMPtr<nsIDocShell> docShell = l.browsingContext().get()->GetDocShell();
if (!docShell) {
continue;
}
RefPtr<SHEntryChild> entry;
if (l.shEntry()) {
entry = l.shEntry()->ToSHEntryChild();
}
// FIXME Should this be sent through IPC?
l.loadState()->SetSHEntry(entry);
docShell->LoadURI(l.loadState(), false);
}
return NS_OK;
}
NS_IMETHODIMP
SHistoryChild::AddToRootSessionHistory(bool aCloneChildren, nsISHEntry* aOSHE,
BrowsingContext* aBC, nsISHEntry* aEntry,
uint32_t aLoadType, bool aShouldPersist,
Maybe<int32_t>* aPreviousEntryIndex,
Maybe<int32_t>* aLoadedEntryIndex) {
nsresult rv;
int32_t entriesPurged;
nsTArray<SwapEntriesDocshellData> entriesToUpdate;
if (!SendAddToRootSessionHistory(
aCloneChildren, static_cast<SHEntryChild*>(aOSHE), aBC,
static_cast<SHEntryChild*>(aEntry), aLoadType, aShouldPersist,
aPreviousEntryIndex, aLoadedEntryIndex, &entriesToUpdate,
&entriesPurged, &rv)) {
return NS_ERROR_FAILURE;
}
for (auto& data : entriesToUpdate) {
MOZ_ASSERT(!data.context().IsNull(), "Browsing context cannot be null");
nsDocShell* docshell = static_cast<nsDocShell*>(
data.context().GetMaybeDiscarded()->GetDocShell());
if (docshell) {
docshell->SwapHistoryEntries(data.oldEntry()->ToSHEntryChild(),
data.newEntry()->ToSHEntryChild());
}
}
if (NS_SUCCEEDED(rv) && mRootDocShell && entriesPurged > 0) {
mRootDocShell->HistoryPurged(entriesPurged);
}
return rv;
}
NS_IMETHODIMP
SHistoryChild::AddChildSHEntryHelper(nsISHEntry* aCloneRef,
nsISHEntry* aNewEntry,
BrowsingContext* aBC,
bool aCloneChildren) {
nsresult rv;
RefPtr<CrossProcessSHEntry> child;
int32_t entriesPurged;
nsTArray<SwapEntriesDocshellData> entriesToUpdate;
if (!SendAddChildSHEntryHelper(static_cast<SHEntryChild*>(aCloneRef),
static_cast<SHEntryChild*>(aNewEntry), aBC,
aCloneChildren, &entriesToUpdate,
&entriesPurged, &child, &rv)) {
return NS_ERROR_FAILURE;
}
for (auto& data : entriesToUpdate) {
MOZ_ASSERT(!data.context().IsNull(), "Browsing context cannot be null");
nsDocShell* docshell = static_cast<nsDocShell*>(
data.context().GetMaybeDiscarded()->GetDocShell());
if (docshell) {
docshell->SwapHistoryEntries(data.oldEntry()->ToSHEntryChild(),
data.newEntry()->ToSHEntryChild());
}
}
if (!child) {
return rv;
}
if (NS_SUCCEEDED(rv) && mRootDocShell && entriesPurged > 0) {
mRootDocShell->HistoryPurged(entriesPurged);
}
return rv;
}
} // namespace dom
} // namespace mozilla

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

@ -1,88 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_SHistoryChild_h
#define mozilla_dom_SHistoryChild_h
#include "mozilla/dom/PSHistoryChild.h"
#include "nsExpirationTracker.h"
#include "nsISHistory.h"
#include "nsWeakReference.h"
class nsIDocShell;
namespace mozilla {
namespace dom {
class LoadSHEntryData;
class SHEntryChildShared;
/**
* Session history actor for the child process.
*/
class SHistoryChild final : public PSHistoryChild,
public nsISHistory,
public nsSupportsWeakReference {
friend class PSHistoryChild;
public:
explicit SHistoryChild(BrowsingContext* aBrowsingContext);
NS_DECL_ISUPPORTS
NS_DECL_NSISHISTORY
protected:
void ActorDestroy(ActorDestroyReason aWhy) override {
mIPCActorDeleted = true;
}
private:
bool RecvReloadCurrentEntryFromChild() {
ReloadCurrentEntry();
return true;
}
// The timer based history tracker is used to evict bfcache on expiration.
class HistoryTracker final
: public nsExpirationTracker<SHEntryChildShared, 3> {
public:
explicit HistoryTracker(SHistoryChild* aSHistory, uint32_t aTimeout,
nsIEventTarget* aEventTarget)
: nsExpirationTracker(1000 * aTimeout / 2, "HistoryTracker",
aEventTarget),
mSHistory(aSHistory) {
MOZ_ASSERT(aSHistory);
mSHistory = aSHistory;
}
protected:
void NotifyExpired(SHEntryChildShared* aObj) override;
private:
// HistoryTracker is owned by SHistoryChild; it always outlives
// HistoryTracker so it's safe to use raw pointer here.
SHistoryChild* mSHistory;
};
~SHistoryChild() = default;
nsresult LoadURI(nsTArray<LoadSHEntryData>& aLoadData);
// Track all bfcache entries and evict on expiration.
mozilla::UniquePtr<HistoryTracker> mHistoryTracker;
// Session History listeners
nsAutoTObserverArray<nsWeakPtr, 2> mListeners;
WeakPtr<nsDocShell> mRootDocShell;
bool mIPCActorDeleted;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_SHistoryChild_h */

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

@ -1,435 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SHistoryParent.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/SHEntryParent.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ContentProcessManager.h"
#include "mozilla/dom/PContentParent.h"
#include "mozilla/Logging.h"
#include "nsTHashtable.h"
#include "SHEntryChild.h"
extern mozilla::LazyLogModule gSHistoryLog;
namespace mozilla {
namespace dom {
LegacySHistory::LegacySHistory(SHistoryParent* aSHistoryParent,
CanonicalBrowsingContext* aRootBC)
: nsSHistory(aRootBC), mSHistoryParent(aSHistoryParent) {
mIsRemote = true;
aRootBC->SetSessionHistory(this);
}
static void FillInLoadResult(
nsresult aRv, const nsTArray<nsSHistory::LoadEntryResult>& aLoadResults,
LoadSHEntryResult* aResult) {
if (NS_SUCCEEDED(aRv)) {
nsTArray<LoadSHEntryData> data;
data.SetCapacity(aLoadResults.Length());
for (const nsSHistory::LoadEntryResult& l : aLoadResults) {
data.AppendElement(
LoadSHEntryData(static_cast<LegacySHEntry*>(l.mLoadState->SHEntry()),
l.mBrowsingContext, l.mLoadState));
}
*aResult = data;
} else {
*aResult = aRv;
}
}
SHistoryParent::SHistoryParent(CanonicalBrowsingContext* aContext)
: mHistory(new LegacySHistory(this, aContext)) {}
SHistoryParent::~SHistoryParent() { mHistory->mSHistoryParent = nullptr; }
SHEntryParent* SHistoryParent::CreateEntry(PContentParent* aContentParent,
PSHistoryParent* aSHistoryParent,
uint64_t aSharedID) {
RefPtr<LegacySHEntry> entry = new LegacySHEntry(
aContentParent, static_cast<SHistoryParent*>(aSHistoryParent)->mHistory,
aSharedID);
return entry->CreateActor();
}
void SHistoryParent::ActorDestroy(ActorDestroyReason aWhy) {}
bool SHistoryParent::RecvGetCount(int32_t* aCount) {
return NS_SUCCEEDED(mHistory->GetCount(aCount));
}
bool SHistoryParent::RecvGetIndex(int32_t* aIndex) {
return NS_SUCCEEDED(mHistory->GetIndex(aIndex));
}
bool SHistoryParent::RecvSetIndex(int32_t aIndex, nsresult* aResult) {
*aResult = mHistory->SetIndex(aIndex);
return true;
}
bool SHistoryParent::RecvGetRequestedIndex(int32_t* aIndex) {
return NS_SUCCEEDED(mHistory->GetRequestedIndex(aIndex));
}
bool SHistoryParent::RecvInternalSetRequestedIndex(int32_t aIndex) {
mHistory->InternalSetRequestedIndex(aIndex);
return true;
}
bool SHistoryParent::RecvGetEntryAtIndex(int32_t aIndex, nsresult* aResult,
RefPtr<CrossProcessSHEntry>* aEntry) {
nsCOMPtr<nsISHEntry> entry;
*aResult = mHistory->GetEntryAtIndex(aIndex, getter_AddRefs(entry));
*aEntry = entry.forget().downcast<LegacySHEntry>();
return true;
}
bool SHistoryParent::RecvPurgeHistory(int32_t aNumEntries, nsresult* aResult) {
*aResult = mHistory->PurgeHistory(aNumEntries);
return true;
}
bool SHistoryParent::RecvReloadCurrentEntry(LoadSHEntryResult* aLoadResult) {
nsTArray<nsSHistory::LoadEntryResult> loadResults;
nsresult rv = mHistory->ReloadCurrentEntry(loadResults);
if (NS_SUCCEEDED(rv)) {
FillInLoadResult(rv, loadResults, aLoadResult);
} else {
*aLoadResult = rv;
}
return true;
}
bool SHistoryParent::RecvGotoIndex(int32_t aIndex,
LoadSHEntryResult* aLoadResult) {
nsTArray<nsSHistory::LoadEntryResult> loadResults;
nsresult rv = mHistory->GotoIndex(aIndex, loadResults);
FillInLoadResult(rv, loadResults, aLoadResult);
return true;
}
bool SHistoryParent::RecvGetIndexOfEntry(PSHEntryParent* aEntry,
int32_t* aIndex) {
MOZ_ASSERT(Manager() == aEntry->Manager());
*aIndex =
mHistory->GetIndexOfEntry(static_cast<SHEntryParent*>(aEntry)->mEntry);
return true;
}
bool SHistoryParent::RecvAddEntry(PSHEntryParent* aEntry, bool aPersist,
nsresult* aResult, int32_t* aEntriesPurged) {
MOZ_ASSERT(Manager() == aEntry->Manager());
*aResult = mHistory->AddEntry(static_cast<SHEntryParent*>(aEntry)->mEntry,
aPersist, aEntriesPurged);
return true;
}
bool SHistoryParent::RecvUpdateIndex() {
return NS_SUCCEEDED(mHistory->UpdateIndex());
}
bool SHistoryParent::RecvReplaceEntry(int32_t aIndex, PSHEntryParent* aEntry,
nsresult* aResult) {
MOZ_ASSERT(Manager() == aEntry->Manager());
*aResult = mHistory->ReplaceEntry(
aIndex, static_cast<SHEntryParent*>(aEntry)->mEntry);
return true;
}
bool SHistoryParent::RecvNotifyOnHistoryReload(bool* aOk) {
return NS_SUCCEEDED(mHistory->NotifyOnHistoryReload(aOk));
}
bool SHistoryParent::RecvEvictOutOfRangeContentViewers(int32_t aIndex) {
return NS_SUCCEEDED(mHistory->EvictOutOfRangeContentViewers(aIndex));
}
bool SHistoryParent::RecvEvictAllContentViewers() {
return NS_SUCCEEDED(mHistory->EvictAllContentViewers());
}
bool SHistoryParent::RecvEvictContentViewersOrReplaceEntry(
PSHEntryParent* aNewSHEntry, bool aReplace) {
MOZ_ASSERT(Manager() == aNewSHEntry->Manager());
mHistory->EvictContentViewersOrReplaceEntry(
aNewSHEntry ? static_cast<SHEntryParent*>(aNewSHEntry)->mEntry.get()
: nullptr,
aReplace);
return true;
}
bool SHistoryParent::RecvRemoveDynEntries(int32_t aIndex,
PSHEntryParent* aEntry) {
MOZ_ASSERT(Manager() == aEntry->Manager());
mHistory->RemoveDynEntries(aIndex,
static_cast<SHEntryParent*>(aEntry)->mEntry);
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);
return true;
}
bool SHistoryParent::RecvRemoveFrameEntries(PSHEntryParent* aEntry) {
mHistory->RemoveFrameEntries(
static_cast<SHEntryParent*>(aEntry)->GetSHEntry());
return true;
}
bool SHistoryParent::RecvReload(const uint32_t& aReloadFlags,
LoadSHEntryResult* aLoadResult) {
nsTArray<nsSHistory::LoadEntryResult> loadResults;
nsresult rv = mHistory->Reload(aReloadFlags, loadResults);
if (NS_SUCCEEDED(rv) && loadResults.IsEmpty()) {
*aLoadResult = NS_OK;
} else {
FillInLoadResult(rv, loadResults, aLoadResult);
}
return true;
}
bool SHistoryParent::RecvGetAllEntries(
nsTArray<RefPtr<CrossProcessSHEntry>>* aEntries) {
nsTArray<nsCOMPtr<nsISHEntry>>& entries = mHistory->Entries();
uint32_t length = entries.Length();
aEntries->AppendElements(length);
for (uint32_t i = 0; i < length; ++i) {
aEntries->ElementAt(i) = static_cast<LegacySHEntry*>(entries[i].get());
}
return true;
}
bool SHistoryParent::RecvFindEntryForBFCache(
const uint64_t& aSharedID, const bool& aIncludeCurrentEntry,
RefPtr<CrossProcessSHEntry>* aEntry, int32_t* aIndex) {
int32_t currentIndex;
mHistory->GetIndex(&currentIndex);
int32_t startSafeIndex, endSafeIndex;
mHistory->WindowIndices(currentIndex, &startSafeIndex, &endSafeIndex);
for (int32_t i = startSafeIndex; i <= endSafeIndex; ++i) {
nsCOMPtr<nsISHEntry> entry;
nsresult rv = mHistory->GetEntryAtIndex(i, getter_AddRefs(entry));
NS_ENSURE_SUCCESS(rv, false);
RefPtr<LegacySHEntry> shEntry = entry.forget().downcast<LegacySHEntry>();
if (shEntry->GetSharedStateID() == aSharedID) {
if (!aIncludeCurrentEntry && i == currentIndex) {
*aEntry = nullptr;
*aIndex = -1;
} else {
*aEntry = std::move(shEntry);
*aIndex = i;
}
return true;
}
}
*aEntry = nullptr;
*aIndex = -1;
return true;
}
bool SHistoryParent::RecvEvict(nsTArray<PSHEntryParent*>&& aEntries) {
for (PSHEntryParent* entry : aEntries) {
int32_t index =
mHistory->GetIndexOfEntry(static_cast<SHEntryParent*>(entry)->mEntry);
if (index != -1) {
mHistory->RemoveDynEntries(index,
static_cast<SHEntryParent*>(entry)->mEntry);
}
}
return true;
}
bool SHistoryParent::RecvNotifyListenersContentViewerEvicted(
uint32_t aNumEvicted) {
mHistory->NotifyListenersContentViewerEvicted(aNumEvicted);
return true;
}
void LegacySHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex) {
if (aIndex < 0) {
return;
}
NS_ENSURE_TRUE_VOID(aIndex < Length());
// Calculate the range that's safe from eviction.
int32_t startSafeIndex, endSafeIndex;
WindowIndices(aIndex, &startSafeIndex, &endSafeIndex);
// See nsSHistory::EvictOutOfRangeWindowContentViewers for more comments.
MOZ_LOG(gSHistoryLog, mozilla::LogLevel::Debug,
("EvictOutOfRangeWindowContentViewers(index=%d), "
"Length()=%d. Safe range [%d, %d]",
aIndex, Length(), startSafeIndex, endSafeIndex));
// Collect content viewers within safe range so we don't accidentally evict
// one of them if it appears outside this range.
nsTHashtable<nsUint64HashKey> safeSharedStateIDs;
for (int32_t i = startSafeIndex; i <= endSafeIndex; i++) {
RefPtr<LegacySHEntry> entry =
static_cast<LegacySHEntry*>(mEntries[i].get());
MOZ_ASSERT(entry);
safeSharedStateIDs.PutEntry(entry->GetSharedStateID());
}
// Iterate over entries that are not within safe range and save the IDs
// of shared state and content parents into a hashtable.
// Format of the hashtable: content parent -> list of shared state IDs
nsDataHashtable<nsPtrHashKey<PContentParent>, nsTHashtable<nsUint64HashKey>>
toEvict;
for (int32_t i = 0; i < Length(); i++) {
if (i >= startSafeIndex && i <= endSafeIndex) {
continue;
}
RefPtr<LegacySHEntry> entry =
static_cast<LegacySHEntry*>(mEntries[i].get());
dom::SHEntrySharedParentState* sharedParentState = entry->GetSharedState();
uint64_t id = entry->GetSharedStateID();
PContentParent* parent =
static_cast<SHEntrySharedParent*>(sharedParentState)
->GetContentParent();
MOZ_ASSERT(parent);
if (!safeSharedStateIDs.Contains(id)) {
nsTHashtable<nsUint64HashKey>& ids = toEvict.GetOrInsert(parent);
ids.PutEntry(id);
}
}
if (toEvict.Count() == 0) {
return;
}
// Remove dynamically created children from entries that will be evicted
// later. We are iterating over the mEntries (instead of toEvict) to gain
// access to each nsSHEntry because toEvict only contains content parents and
// IDs of SHEntrySharedParentState
// (It's important that the condition checks Length(), rather than a cached
// copy of Length(), because the length might change between iterations due to
// RemoveDynEntries call.)
for (int32_t i = 0; i < Length(); i++) {
RefPtr<LegacySHEntry> entry =
static_cast<LegacySHEntry*>(mEntries[i].get());
MOZ_ASSERT(entry);
uint64_t id = entry->GetSharedStateID();
if (!safeSharedStateIDs.Contains(id)) {
// When dropping bfcache, we have to remove associated dynamic entries as
// well.
int32_t index = GetIndexOfEntry(entry);
if (index != -1) {
RemoveDynEntries(index, entry);
}
}
}
// Iterate over the 'toEvict' hashtable to get the IDs of content viewers to
// evict for each parent
for (auto iter = toEvict.ConstIter(); !iter.Done(); iter.Next()) {
auto parent = iter.Key();
const nsTHashtable<nsUint64HashKey>& ids = iter.Data();
// Convert ids into an array because we don't have support for passing
// nsTHashtable over IPC
AutoTArray<uint64_t, 4> evictArray;
for (auto iter = ids.ConstIter(); !iter.Done(); iter.Next()) {
evictArray.AppendElement(iter.Get()->GetKey());
}
Unused << parent->SendEvictContentViewers(evictArray);
}
}
NS_IMETHODIMP
LegacySHistory::CreateEntry(nsISHEntry** aEntry) {
NS_ENSURE_TRUE(mRootBC, NS_ERROR_FAILURE);
NS_ADDREF(*aEntry = new LegacySHEntry(
static_cast<CanonicalBrowsingContext*>(mRootBC)
->GetContentParent(),
this, SHEntryChildShared::CreateSharedID()));
return NS_OK;
}
NS_IMETHODIMP
LegacySHistory::ReloadCurrentEntry() {
return mSHistoryParent->SendReloadCurrentEntryFromChild() ? NS_OK
: NS_ERROR_FAILURE;
}
bool SHistoryParent::RecvAddToRootSessionHistory(
bool aCloneChildren, PSHEntryParent* aOSHE,
const MaybeDiscarded<BrowsingContext>& aBC, PSHEntryParent* aEntry,
uint32_t aLoadType, bool aShouldPersist,
Maybe<int32_t>* aPreviousEntryIndex, Maybe<int32_t>* aLoadedEntryIndex,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate,
int32_t* aEntriesPurged, nsresult* aResult) {
MOZ_ASSERT(!aBC.IsNull(), "Browsing context cannot be null");
nsTArray<EntriesAndBrowsingContextData> entriesToSendOverIDL;
*aResult = mHistory->AddToRootSessionHistory(
aCloneChildren,
aOSHE ? static_cast<SHEntryParent*>(aOSHE)->mEntry.get() : nullptr,
aBC.GetMaybeDiscarded(),
static_cast<SHEntryParent*>(aEntry)->mEntry.get(), aLoadType,
aShouldPersist, static_cast<ContentParent*>(Manager())->ChildID(),
aPreviousEntryIndex, aLoadedEntryIndex, &entriesToSendOverIDL,
aEntriesPurged);
SHistoryParent::CreateActorsForSwapEntries(entriesToSendOverIDL,
aEntriesToUpdate, Manager());
return true;
}
bool SHistoryParent::RecvAddChildSHEntryHelper(
PSHEntryParent* aCloneRef, PSHEntryParent* aNewEntry,
const MaybeDiscarded<BrowsingContext>& aBC, bool aCloneChildren,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate,
int32_t* aEntriesPurged, RefPtr<CrossProcessSHEntry>* aChild,
nsresult* aResult) {
MOZ_ASSERT(!aBC.IsNull(), "Browsing context cannot be null");
nsCOMPtr<nsISHEntry> child;
nsTArray<EntriesAndBrowsingContextData> entriesToSendOverIPC;
*aResult = mHistory->AddChildSHEntryHelper(
static_cast<SHEntryParent*>(aCloneRef)->mEntry.get(),
aNewEntry ? static_cast<SHEntryParent*>(aNewEntry)->mEntry.get()
: nullptr,
aBC.GetMaybeDiscarded(), aCloneChildren,
static_cast<ContentParent*>(Manager())->ChildID(), &entriesToSendOverIPC,
aEntriesPurged, getter_AddRefs(child));
SHistoryParent::CreateActorsForSwapEntries(entriesToSendOverIPC,
aEntriesToUpdate, Manager());
*aChild = child.forget().downcast<LegacySHEntry>();
return true;
}
void SHistoryParent::CreateActorsForSwapEntries(
const nsTArray<EntriesAndBrowsingContextData>& aEntriesToSendOverIPC,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate,
PContentParent* aContentParent) {
for (auto& data : aEntriesToSendOverIPC) {
SwapEntriesDocshellData* toUpdate = aEntriesToUpdate->AppendElement();
// Old entry
toUpdate->oldEntry() = static_cast<LegacySHEntry*>(data.oldEntry.get());
// New entry
toUpdate->newEntry() = static_cast<LegacySHEntry*>(data.newEntry.get());
toUpdate->context() = data.context;
}
}
} // namespace dom
} // namespace mozilla

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

@ -1,130 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_SHistoryParent_h
#define mozilla_dom_SHistoryParent_h
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/PSHistoryParent.h"
#include "mozilla/RefPtr.h"
#include "nsSHistory.h"
namespace mozilla {
namespace dom {
class PSHEntryOrSharedID;
class SHistoryParent;
class SHEntryParent;
/**
* Session history implementation based on the legacy implementation that used
* to live in the child process. Ideally this wouldn't implement nsISHistory
* (it should only ever be accessed by SHistoryParent).
*/
class LegacySHistory final : public nsSHistory {
private:
friend class SHistoryParent;
virtual ~LegacySHistory() = default;
void EvictOutOfRangeWindowContentViewers(int32_t aIndex) override;
SHistoryParent* mSHistoryParent;
public:
LegacySHistory(SHistoryParent* aSHistoryParent,
CanonicalBrowsingContext* aRootBC);
NS_IMETHOD CreateEntry(nsISHEntry** aEntry) override;
using nsSHistory::ReloadCurrentEntry;
NS_IMETHOD ReloadCurrentEntry() override;
SHistoryParent* GetActor() { return mSHistoryParent; }
};
/**
* Session history actor for the parent process. Forwards to the legacy
* implementation that used to live in the child process (see LegacySHistory).
*/
class SHistoryParent final : public PSHistoryParent {
friend class LegacySHistory;
friend class PSHistoryParent;
friend class SHEntryParent;
public:
explicit SHistoryParent(CanonicalBrowsingContext* aContext);
virtual ~SHistoryParent();
static SHEntryParent* CreateEntry(PContentParent* aContentParent,
PSHistoryParent* aSHistoryParent,
uint64_t aSharedID);
// We have a list of entries we would like to return from
// the IPC call and we need to create actors for all of them
static void CreateActorsForSwapEntries(
const nsTArray<EntriesAndBrowsingContextData>& aEntriesToSendOverIPC,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate,
PContentParent* aContentParent);
protected:
void ActorDestroy(ActorDestroyReason aWhy) override;
private:
bool RecvGetCount(int32_t* aCount);
bool RecvGetIndex(int32_t* aIndex);
bool RecvSetIndex(int32_t aIndex, nsresult* aResult);
bool RecvGetRequestedIndex(int32_t* aIndex);
bool RecvInternalSetRequestedIndex(int32_t aIndex);
bool RecvGetEntryAtIndex(int32_t aIndex, nsresult* aResult,
RefPtr<CrossProcessSHEntry>* aEntry);
bool RecvPurgeHistory(int32_t aNumEntries, nsresult* aResult);
bool RecvReloadCurrentEntry(LoadSHEntryResult* aLoadResult);
bool RecvGotoIndex(int32_t aIndex, LoadSHEntryResult* aLoadResult);
bool RecvGetIndexOfEntry(PSHEntryParent* aEntry, int32_t* aIndex);
bool RecvAddEntry(PSHEntryParent* aEntry, bool aPersist, nsresult* aResult,
int32_t* aEntriesPurged);
bool RecvUpdateIndex();
bool RecvReplaceEntry(int32_t aIndex, PSHEntryParent* aEntry,
nsresult* aResult);
bool RecvNotifyOnHistoryReload(bool* aOk);
bool RecvEvictOutOfRangeContentViewers(int32_t aIndex);
bool RecvEvictAllContentViewers();
bool RecvRemoveDynEntries(int32_t aIndex, PSHEntryParent* aEntry);
bool RecvRemoveEntries(nsTArray<nsID>&& ids, int32_t aIndex,
bool* aDidRemove);
bool RecvRemoveFrameEntries(PSHEntryParent* aEntry);
bool RecvReload(const uint32_t& aReloadFlags, LoadSHEntryResult* aLoadResult);
bool RecvGetAllEntries(nsTArray<RefPtr<CrossProcessSHEntry>>* aEntries);
bool RecvFindEntryForBFCache(const uint64_t& aSharedID,
const bool& aIncludeCurrentEntry,
RefPtr<CrossProcessSHEntry>* aEntry,
int32_t* aIndex);
bool RecvEvict(nsTArray<PSHEntryParent*>&& aEntries);
bool RecvEnsureCorrectEntryAtCurrIndex(PSHEntryParent* aEntry);
bool RecvEvictContentViewersOrReplaceEntry(PSHEntryParent* aNewSHEntry,
bool aReplace);
bool RecvNotifyListenersContentViewerEvicted(uint32_t aNumEvicted);
bool RecvAddToRootSessionHistory(
bool aCloneChildren, PSHEntryParent* aOSHE,
const MaybeDiscarded<BrowsingContext>& aBC, PSHEntryParent* aEntry,
uint32_t aLoadType, bool aShouldPersist,
Maybe<int32_t>* aPreviousEntryIndex, Maybe<int32_t>* aLoadedEntryIndex,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate,
int32_t* aEntriesPurged, nsresult* aResult);
bool RecvAddChildSHEntryHelper(
PSHEntryParent* aCloneRef, PSHEntryParent* aNewEntry,
const MaybeDiscarded<BrowsingContext>& aBC, bool aCloneChildren,
nsTArray<SwapEntriesDocshellData>* aEntriesToUpdate,
int32_t* aEntriesPurged, RefPtr<CrossProcessSHEntry>* aChild,
nsresult* aResult);
RefPtr<CanonicalBrowsingContext> mContext;
RefPtr<LegacySHistory> mHistory;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_SHistoryParent_h */

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

@ -13,11 +13,6 @@ XPIDL_SOURCES += [
XPIDL_MODULE = 'shistory'
IPDL_SOURCES += [
'PSHEntry.ipdl',
'PSHistory.ipdl',
]
EXPORTS += [
'nsSHEntry.h',
'nsSHEntryShared.h',
@ -26,23 +21,13 @@ EXPORTS += [
EXPORTS.mozilla.dom += [
'ChildSHistory.h',
'MaybeNewPSHEntry.h',
'SHEntryChild.h',
'SHEntryParent.h',
'SHistoryChild.h',
'SHistoryParent.h',
]
UNIFIED_SOURCES += [
'ChildSHistory.cpp',
'MaybeNewPSHEntry.cpp',
'nsSHEntry.cpp',
'nsSHEntryShared.cpp',
'nsSHistory.cpp',
'SHEntryChild.cpp',
'SHEntryParent.cpp',
'SHistoryChild.cpp',
'SHistoryParent.cpp',
]
LOCAL_INCLUDES += [

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

@ -10,6 +10,7 @@
#include "nsDocShell.h"
#include "nsDocShellEditorData.h"
#include "nsDocShellLoadState.h"
#include "nsDocShellLoadTypes.h"
#include "nsIContentSecurityPolicy.h"
#include "nsIContentViewer.h"
@ -21,7 +22,6 @@
#include "nsIURI.h"
#include "nsSHEntryShared.h"
#include "nsSHistory.h"
#include "SHEntryChild.h"
#include "mozilla/Logging.h"
#include "nsIReferrerInfo.h"
@ -32,8 +32,8 @@ namespace dom = mozilla::dom;
static uint32_t gEntryID = 0;
nsSHEntry::nsSHEntry(dom::SHEntrySharedParentState* aState)
: mShared(aState),
nsSHEntry::nsSHEntry(nsISHistory* aSHistory)
: mShared(new nsSHEntryShared(aSHistory)),
mLoadType(0),
mID(gEntryID++),
mScrollPositionX(0),
@ -173,22 +173,6 @@ nsSHEntry::SetReferrerInfo(nsIReferrerInfo* aReferrerInfo) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetContentViewer(nsIContentViewer* aViewer) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetContentViewer(nsIContentViewer** aResult) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetSticky(bool aSticky) {
mShared->mSticky = aSticky;
@ -314,22 +298,6 @@ nsSHEntry::SetCacheKey(uint32_t aCacheKey) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetSaveLayoutStateFlag(bool* aFlag) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetSaveLayoutStateFlag(bool aFlag) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetExpirationStatus(bool* aFlag) {
*aFlag = mShared->mExpired;
@ -402,14 +370,11 @@ nsSHEntry::Create(
mResultPrincipalURI = aResultPrincipalURI;
mLoadReplace = aLoadReplace;
mReferrerInfo = aReferrerInfo;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::Clone(nsISHEntry** aResult) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
mShared->mLayoutHistoryState = nullptr;
mShared->mSaveLayoutState = aSaveLayoutState;
return NS_OK;
}
@ -431,22 +396,6 @@ nsSHEntry::SetParent(nsISHEntry* aParent) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetWindowState(nsISupports* aState) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetWindowState(nsISupports** aState) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP_(void)
nsSHEntry::SetViewerBounds(const nsIntRect& aBounds) {
mShared->mViewerBounds = aBounds;
@ -508,17 +457,9 @@ nsSHEntry::SetCsp(nsIContentSecurityPolicy* aCsp) {
return NS_OK;
}
bool nsSHEntry::HasBFCacheEntry(nsIBFCacheEntry* aEntry) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return false;
}
NS_IMETHODIMP
nsSHEntry::AdoptBFCacheEntry(nsISHEntry* aEntry) {
dom::SHEntrySharedParentState* shared =
static_cast<nsSHEntry*>(aEntry)->mShared;
nsSHEntryShared* shared = static_cast<nsSHEntry*>(aEntry)->mShared;
NS_ENSURE_STATE(shared);
mShared = shared;
@ -533,14 +474,6 @@ nsSHEntry::SharesDocumentWith(nsISHEntry* aEntry, bool* aOut) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::AbandonBFCacheEntry() {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetIsSrcdocEntry(bool* aIsSrcdocEntry) {
*aIsSrcdocEntry = mIsSrcdocEntry;
@ -808,71 +741,7 @@ NS_IMETHODIMP_(void) nsSHEntry::ClearEntry() {
GetChildAt(i, getter_AddRefs(child));
RemoveChild(child);
}
}
NS_IMETHODIMP_(void)
nsSHEntry::AddChildShell(nsIDocShellTreeItem* aShell) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
}
NS_IMETHODIMP
nsSHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem** aShell) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP_(void)
nsSHEntry::ClearChildShells() {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
}
NS_IMETHODIMP
nsSHEntry::GetRefreshURIList(nsIMutableArray** aList) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetRefreshURIList(nsIMutableArray* aList) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
NS_IMETHODIMP_(void)
nsSHEntry::SyncPresentationState() {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
}
nsDocShellEditorData* nsSHEntry::ForgetEditorData() {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return nullptr;
}
void nsSHEntry::SetEditorData(nsDocShellEditorData* aData) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
}
bool nsSHEntry::HasDetachedEditor() {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return false;
AbandonBFCacheEntry();
}
NS_IMETHODIMP
@ -1015,22 +884,10 @@ nsSHEntry::CreateLoadInfo(nsDocShellLoadState** aLoadState) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetBfcacheID(uint64_t* aBFCacheID) {
MOZ_CRASH(
"Classes inheriting from nsSHEntry should implement this. "
"Bug 1546344 will clean this up.");
return NS_OK;
}
void nsSHEntry::SyncTreesForSubframeNavigation(
uint64_t aOtherPid, nsISHEntry* aEntry,
mozilla::dom::BrowsingContext* aTopBC,
mozilla::dom::BrowsingContext* aIgnoreBC,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate) {
MOZ_ASSERT(aEntriesToUpdate || aOtherPid == 0,
"our entries to update is null");
NS_IMETHODIMP_(void)
nsSHEntry::SyncTreesForSubframeNavigation(
nsISHEntry* aEntry, mozilla::dom::BrowsingContext* aTopBC,
mozilla::dom::BrowsingContext* aIgnoreBC) {
// We need to sync up the browsing context and session history trees for
// subframe navigation. If the load was in a subframe, we forward up to
// the top browsing context, which will then recursively sync up all browsing
@ -1047,24 +904,12 @@ void nsSHEntry::SyncTreesForSubframeNavigation(
nsCOMPtr<nsISHEntry> oldRootEntry = nsSHistory::GetRootSHEntry(this);
if (oldRootEntry) {
nsSHistory::SwapEntriesData data = {aIgnoreBC, newRootEntry, nullptr,
aOtherPid, aEntriesToUpdate};
nsSHistory::SwapEntriesData data = {aIgnoreBC, newRootEntry, nullptr};
nsSHistory::SetChildHistoryEntry(oldRootEntry, aTopBC, 0, &data);
}
}
}
NS_IMETHODIMP_(void)
nsSHEntry::SyncTreesForSubframeNavigation(
nsISHEntry* aEntry, mozilla::dom::BrowsingContext* aTopBC,
mozilla::dom::BrowsingContext* aIgnoreBC) {
SyncTreesForSubframeNavigation(
0 /* unused, this will be set in SHEntryParent::RecvSyncTrees */,
aEntry, aTopBC, aIgnoreBC,
nullptr /* this will be given in SHEntryCHild::SyncTrees if we
are going over IPC, else, it is not needed */);
}
void nsSHEntry::EvictContentViewer() {
nsCOMPtr<nsIContentViewer> viewer = GetContentViewer();
if (viewer) {
@ -1083,58 +928,33 @@ nsSHEntry::SynchronizeLayoutHistoryState() {
return NS_OK;
}
nsLegacySHEntry::nsLegacySHEntry(nsISHistory* aHistory, uint64_t aID)
: nsSHEntry(new nsSHEntryShared(aHistory, aID)) {}
NS_IMETHODIMP
nsLegacySHEntry::SetContentViewer(nsIContentViewer* aViewer) {
nsSHEntry::SetContentViewer(nsIContentViewer* aViewer) {
return GetState()->SetContentViewer(aViewer);
}
NS_IMETHODIMP
nsLegacySHEntry::GetContentViewer(nsIContentViewer** aResult) {
nsSHEntry::GetContentViewer(nsIContentViewer** aResult) {
*aResult = GetState()->mContentViewer;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsLegacySHEntry::Create(
nsIURI* aURI, const nsAString& aTitle, nsIInputStream* aInputStream,
uint32_t aCacheKey, const nsACString& aContentType,
nsIPrincipal* aTriggeringPrincipal, nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aStoragePrincipalToInherit, nsIContentSecurityPolicy* aCsp,
const nsID& aDocShellID, bool aDynamicCreation, nsIURI* aOriginalURI,
nsIURI* aResultPrincipalURI, bool aLoadReplace,
nsIReferrerInfo* aReferrerInfo, const nsAString& aSrcdocData,
bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState, bool aExpired) {
mShared->mLayoutHistoryState = nullptr;
mShared->mSaveLayoutState = aSaveLayoutState;
return nsSHEntry::Create(aURI, aTitle, aInputStream, aCacheKey, aContentType,
aTriggeringPrincipal, aPrincipalToInherit,
aStoragePrincipalToInherit, aCsp, aDocShellID,
aDynamicCreation, aOriginalURI, aResultPrincipalURI,
aLoadReplace, aReferrerInfo, aSrcdocData,
aSrcdocEntry, aBaseURI, aSaveLayoutState, aExpired);
}
NS_IMETHODIMP
nsLegacySHEntry::Clone(nsISHEntry** aResult) {
nsCOMPtr<nsISHEntry> entry = new nsLegacySHEntry(*this);
nsSHEntry::Clone(nsISHEntry** aResult) {
nsCOMPtr<nsISHEntry> entry = new nsSHEntry(*this);
entry.forget(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsLegacySHEntry::GetSaveLayoutStateFlag(bool* aFlag) {
nsSHEntry::GetSaveLayoutStateFlag(bool* aFlag) {
*aFlag = mShared->mSaveLayoutState;
return NS_OK;
}
NS_IMETHODIMP
nsLegacySHEntry::SetSaveLayoutStateFlag(bool aFlag) {
nsSHEntry::SetSaveLayoutStateFlag(bool aFlag) {
mShared->mSaveLayoutState = aFlag;
if (mShared->mLayoutHistoryState) {
mShared->mLayoutHistoryState->SetScrollPositionOnly(!aFlag);
@ -1144,55 +964,53 @@ nsLegacySHEntry::SetSaveLayoutStateFlag(bool aFlag) {
}
NS_IMETHODIMP
nsLegacySHEntry::SetWindowState(nsISupports* aState) {
nsSHEntry::SetWindowState(nsISupports* aState) {
GetState()->mWindowState = aState;
return NS_OK;
}
NS_IMETHODIMP
nsLegacySHEntry::GetWindowState(nsISupports** aState) {
nsSHEntry::GetWindowState(nsISupports** aState) {
NS_IF_ADDREF(*aState = GetState()->mWindowState);
return NS_OK;
}
NS_IMETHODIMP
nsLegacySHEntry::GetRefreshURIList(nsIMutableArray** aList) {
nsSHEntry::GetRefreshURIList(nsIMutableArray** aList) {
NS_IF_ADDREF(*aList = GetState()->mRefreshURIList);
return NS_OK;
}
NS_IMETHODIMP
nsLegacySHEntry::SetRefreshURIList(nsIMutableArray* aList) {
nsSHEntry::SetRefreshURIList(nsIMutableArray* aList) {
GetState()->mRefreshURIList = aList;
return NS_OK;
}
NS_IMETHODIMP_(void)
nsLegacySHEntry::AddChildShell(nsIDocShellTreeItem* aShell) {
nsSHEntry::AddChildShell(nsIDocShellTreeItem* aShell) {
MOZ_ASSERT(aShell, "Null child shell added to history entry");
GetState()->mChildShells.AppendObject(aShell);
}
NS_IMETHODIMP
nsLegacySHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem** aShell) {
nsSHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem** aShell) {
NS_IF_ADDREF(*aShell = GetState()->mChildShells.SafeObjectAt(aIndex));
return NS_OK;
}
NS_IMETHODIMP_(void)
nsLegacySHEntry::ClearChildShells() { GetState()->mChildShells.Clear(); }
nsSHEntry::ClearChildShells() { GetState()->mChildShells.Clear(); }
NS_IMETHODIMP_(void)
nsLegacySHEntry::SyncPresentationState() {
GetState()->SyncPresentationState();
}
nsSHEntry::SyncPresentationState() { GetState()->SyncPresentationState(); }
nsDocShellEditorData* nsLegacySHEntry::ForgetEditorData() {
nsDocShellEditorData* nsSHEntry::ForgetEditorData() {
// XXX jlebar Check how this is used.
return GetState()->mEditorData.release();
}
void nsLegacySHEntry::SetEditorData(nsDocShellEditorData* aData) {
void nsSHEntry::SetEditorData(nsDocShellEditorData* aData) {
NS_ASSERTION(!(aData && GetState()->mEditorData),
"We're going to overwrite an owning ref!");
if (GetState()->mEditorData != aData) {
@ -1200,33 +1018,22 @@ void nsLegacySHEntry::SetEditorData(nsDocShellEditorData* aData) {
}
}
bool nsLegacySHEntry::HasDetachedEditor() {
bool nsSHEntry::HasDetachedEditor() {
return GetState()->mEditorData != nullptr;
}
bool nsLegacySHEntry::HasBFCacheEntry(nsIBFCacheEntry* aEntry) {
bool nsSHEntry::HasBFCacheEntry(nsIBFCacheEntry* aEntry) {
return static_cast<nsIBFCacheEntry*>(GetState()) == aEntry;
}
NS_IMETHODIMP
nsLegacySHEntry::AbandonBFCacheEntry() {
mShared =
GetState()->Duplicate(mozilla::dom::SHEntryChildShared::CreateSharedID());
nsSHEntry::AbandonBFCacheEntry() {
mShared = GetState()->Duplicate();
return NS_OK;
}
NS_IMETHODIMP_(void)
nsLegacySHEntry::ClearEntry() {
nsSHEntry::ClearEntry();
AbandonBFCacheEntry();
}
NS_IMETHODIMP
nsLegacySHEntry::GetBfcacheID(uint64_t* aBFCacheID) {
nsSHEntry::GetBfcacheID(uint64_t* aBFCacheID) {
*aBFCacheID = mShared->GetID();
return NS_OK;
}
nsSHEntryShared* nsLegacySHEntry::GetState() {
return static_cast<nsSHEntryShared*>(mShared.get());
}

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

@ -14,33 +14,15 @@
#include "mozilla/Attributes.h"
namespace mozilla {
namespace dom {
class SHEntrySharedChildState;
class SHEntrySharedParentState;
} // namespace dom
} // namespace mozilla
class nsSHEntryShared;
class nsIInputStream;
class nsIURI;
class nsIReferrerInfo;
// Structure for passing around entries via XPCOM from methods such as
// nsSHistory::CloneAndReplaceChild, nsSHistory::SetChildHistoryEntry and
// nsSHEntry::SyncTreesForSubframeNavigation, that need to swap entries in
// docshell, to corresponding Recv methods so that we don't have to create
// actors until we are about to return from the parent process
struct EntriesAndBrowsingContextData {
nsCOMPtr<nsISHEntry> oldEntry;
nsCOMPtr<nsISHEntry> newEntry;
mozilla::dom::BrowsingContext* context;
};
class nsSHEntry : public nsISHEntry {
public:
explicit nsSHEntry(nsISHistory* aSHistory);
NS_DECL_ISUPPORTS
NS_DECL_NSISHENTRY
@ -48,20 +30,16 @@ class nsSHEntry : public nsISHEntry {
static nsresult Startup();
static void Shutdown();
void SyncTreesForSubframeNavigation(
uint64_t aOtherPid, nsISHEntry* aEntry,
mozilla::dom::BrowsingContext* aTopBC,
mozilla::dom::BrowsingContext* aIgnoreBC,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate);
protected:
explicit nsSHEntry(mozilla::dom::SHEntrySharedParentState* aState);
explicit nsSHEntry(const nsSHEntry& aOther);
virtual ~nsSHEntry();
nsSHEntryShared* GetState() { return mShared; }
// We share the state in here with other SHEntries which correspond to the
// same document.
RefPtr<mozilla::dom::SHEntrySharedParentState> mShared;
RefPtr<nsSHEntryShared> mShared;
// See nsSHEntry.idl for comments on these members.
nsCOMPtr<nsIURI> mURI;
@ -87,53 +65,4 @@ class nsSHEntry : public nsISHEntry {
bool mPersist;
};
/**
* Session history entry class used for implementing session history for
* docshells in the parent process (a different solution would be to use the
* IPC actors for that too, with both parent and child actor created in the
* parent process).
*/
class nsLegacySHEntry final : public nsSHEntry {
public:
explicit nsLegacySHEntry(nsISHistory* aHistory, uint64_t aID);
explicit nsLegacySHEntry(const nsLegacySHEntry& aOther) : nsSHEntry(aOther) {}
NS_IMETHOD GetContentViewer(nsIContentViewer** aResult) override;
NS_IMETHOD SetContentViewer(nsIContentViewer* aViewer) override;
NS_IMETHOD GetWindowState(nsISupports** aState) override;
NS_IMETHOD SetWindowState(nsISupports* aState) override;
using nsISHEntry::GetRefreshURIList;
NS_IMETHOD GetRefreshURIList(nsIMutableArray** aRefreshURIList) override;
NS_IMETHOD SetRefreshURIList(nsIMutableArray* aRefreshURIList) override;
using nsISHEntry::GetSaveLayoutStateFlag;
NS_IMETHOD GetSaveLayoutStateFlag(bool* aSaveLayoutStateFlag) override;
NS_IMETHOD SetSaveLayoutStateFlag(bool aSaveLayoutStateFlag) override;
NS_IMETHOD_(void) AddChildShell(nsIDocShellTreeItem* aShell) override;
NS_IMETHOD ChildShellAt(int32_t aIndex,
nsIDocShellTreeItem** aShell) override;
NS_IMETHOD_(void) ClearChildShells() override;
NS_IMETHOD_(void) SyncPresentationState() override;
NS_IMETHOD Create(
nsIURI* aURI, const nsAString& aTitle, nsIInputStream* aInputStream,
uint32_t aCacheKey, const nsACString& aContentType,
nsIPrincipal* aTriggeringPrincipal, nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aStoragePrincipalToInherit, nsIContentSecurityPolicy* aCsp,
const nsID& aDocshellID, bool aDynamicCreation, nsIURI* aOriginalURI,
nsIURI* aResultPrincipalURI, bool aLoadReplace,
nsIReferrerInfo* aReferrerInfo, const nsAString& aSrcdocData,
bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState,
bool aExpired) override;
NS_IMETHOD Clone(nsISHEntry** aResult) override;
NS_IMETHOD_(nsDocShellEditorData*) ForgetEditorData(void) override;
NS_IMETHOD_(void) SetEditorData(nsDocShellEditorData* aData) override;
NS_IMETHOD_(bool) HasDetachedEditor() override;
NS_IMETHOD_(bool) HasBFCacheEntry(nsIBFCacheEntry* aEntry) override;
NS_IMETHOD AbandonBFCacheEntry() override;
NS_IMETHOD_(void) ClearEntry() override;
NS_IMETHOD GetBfcacheID(uint64_t* aBFCacheID) override;
private:
nsSHEntryShared* GetState();
};
#endif /* nsSHEntry_h */

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

@ -21,21 +21,23 @@
namespace dom = mozilla::dom;
namespace {
uint64_t gSHEntrySharedID = 0;
} // namespace
namespace mozilla {
namespace dom {
SHEntrySharedParentState::SHEntrySharedParentState(nsISHistory* aSHistory,
uint64_t aID)
: SHEntrySharedParentState(nsWeakPtr(do_GetWeakReference(aSHistory)).get(),
aID) {}
SHEntrySharedParentState::SHEntrySharedParentState(nsISHistory* aSHistory)
: SHEntrySharedParentState(
nsWeakPtr(do_GetWeakReference(aSHistory)).get()) {}
SHEntrySharedParentState::SHEntrySharedParentState(nsIWeakReference* aSHistory,
uint64_t aID)
SHEntrySharedParentState::SHEntrySharedParentState(nsIWeakReference* aSHistory)
: mDocShellID({0}),
mViewerBounds(0, 0, 0, 0),
mCacheKey(0),
mLastTouched(0),
mID(aID),
mID(++gSHEntrySharedID),
mSHistory(aSHistory),
mIsFrameNavigation(false),
mSticky(true),
@ -67,12 +69,8 @@ void dom::SHEntrySharedParentState::NotifyListenersContentViewerEvicted() {
}
}
dom::SHEntrySharedChildState::SHEntrySharedChildState()
: mSaveLayoutState(true) {}
void SHEntrySharedChildState::CopyFrom(SHEntrySharedChildState* aEntry) {
mChildShells.AppendObjects(aEntry->mChildShells);
mSaveLayoutState = aEntry->mSaveLayoutState;
}
} // namespace dom
@ -102,9 +100,8 @@ NS_IMPL_QUERY_INTERFACE(nsSHEntryShared, nsIBFCacheEntry, nsIMutationObserver)
NS_IMPL_ADDREF_INHERITED(nsSHEntryShared, dom::SHEntrySharedParentState)
NS_IMPL_RELEASE_INHERITED(nsSHEntryShared, dom::SHEntrySharedParentState)
already_AddRefed<nsSHEntryShared> nsSHEntryShared::Duplicate(
uint64_t aNewSharedID) {
RefPtr<nsSHEntryShared> newEntry = new nsSHEntryShared(this, aNewSharedID);
already_AddRefed<nsSHEntryShared> nsSHEntryShared::Duplicate() {
RefPtr<nsSHEntryShared> newEntry = new nsSHEntryShared(this);
newEntry->dom::SHEntrySharedParentState::CopyFrom(this);
newEntry->dom::SHEntrySharedChildState::CopyFrom(this);

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

@ -54,10 +54,10 @@ class SHEntrySharedParentState {
void NotifyListenersContentViewerEvicted();
protected:
SHEntrySharedParentState(nsISHistory* aSHistory, uint64_t aID);
SHEntrySharedParentState(SHEntrySharedParentState* aDuplicate, uint64_t aID)
: SHEntrySharedParentState(aDuplicate->mSHistory, aID) {}
SHEntrySharedParentState(nsIWeakReference* aSHistory, uint64_t aID);
explicit SHEntrySharedParentState(nsISHistory* aSHistory);
explicit SHEntrySharedParentState(SHEntrySharedParentState* aDuplicate)
: SHEntrySharedParentState(aDuplicate->mSHistory) {}
explicit SHEntrySharedParentState(nsIWeakReference* aSHistory);
virtual ~SHEntrySharedParentState();
NS_INLINE_DECL_VIRTUAL_REFCOUNTING_WITH_DESTROY(SHEntrySharedParentState,
Destroy())
@ -104,8 +104,6 @@ class SHEntrySharedParentState {
*/
class SHEntrySharedChildState {
protected:
SHEntrySharedChildState();
void CopyFrom(SHEntrySharedChildState* aSource);
public:
@ -117,16 +115,11 @@ class SHEntrySharedChildState {
// they're specific to a particular content viewer.
nsCOMPtr<nsIContentViewer> mContentViewer;
RefPtr<mozilla::dom::Document> mDocument;
// FIXME Move to parent?
nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
nsCOMPtr<nsISupports> mWindowState;
// FIXME Move to parent?
nsCOMPtr<nsIMutableArray> mRefreshURIList;
nsExpirationState mExpirationState;
UniquePtr<nsDocShellEditorData> mEditorData;
// FIXME Move to parent?
bool mSaveLayoutState;
};
} // namespace dom
@ -149,7 +142,7 @@ class nsSHEntryShared final : public nsIBFCacheEntry,
using SHEntrySharedParentState::SHEntrySharedParentState;
already_AddRefed<nsSHEntryShared> Duplicate(uint64_t aNewSharedID);
already_AddRefed<nsSHEntryShared> Duplicate();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIBFCACHEENTRY
@ -166,7 +159,7 @@ class nsSHEntryShared final : public nsIBFCacheEntry,
private:
~nsSHEntryShared();
friend class nsLegacySHEntry;
friend class nsSHEntry;
void RemoveFromExpirationTracker();
void SyncPresentationState();

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

@ -29,15 +29,13 @@
#include "mozilla/Attributes.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/MaybeNewPSHEntry.h"
#include "mozilla/dom/SHEntryChild.h"
#include "mozilla/dom/SHEntryParent.h"
#include "mozilla/LinkedList.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPrefs_fission.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "nsIWebNavigation.h"
#include "nsDocShellLoadTypes.h"
#include "base/process.h"
@ -396,20 +394,10 @@ nsresult nsSHistory::WalkHistoryEntries(nsISHEntry* aRootEntry,
for (BrowsingContext* child : aBC->Children()) {
// If the SH pref is on, or we are in the parent process, update
// canonical BC directly
if (StaticPrefs::fission_sessionHistoryInParent() ||
XRE_IsParentProcess()) {
// Walk the children of the browsing context and see if one of them
// has childEntry as mOSHE or mLSHE
if (child->Canonical()->HasHistoryEntry(childEntry)) {
childBC = child;
break;
}
} else {
nsDocShell* docshell = static_cast<nsDocShell*>(child->GetDocShell());
if (docshell && docshell->HasHistoryEntry(childEntry)) {
childBC = docshell->GetBrowsingContext();
break;
}
nsDocShell* docshell = static_cast<nsDocShell*>(child->GetDocShell());
if (docshell && docshell->HasHistoryEntry(childEntry)) {
childBC = docshell->GetBrowsingContext();
break;
}
}
}
@ -424,38 +412,27 @@ nsresult nsSHistory::WalkHistoryEntries(nsISHEntry* aRootEntry,
// callback data for WalkHistoryEntries
struct MOZ_STACK_CLASS CloneAndReplaceData {
CloneAndReplaceData(uint32_t aCloneID, nsISHEntry* aReplaceEntry,
bool aCloneChildren, nsISHEntry* aDestTreeParent,
uint64_t aOtherPid,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate)
bool aCloneChildren, nsISHEntry* aDestTreeParent)
: cloneID(aCloneID),
cloneChildren(aCloneChildren),
replaceEntry(aReplaceEntry),
destTreeParent(aDestTreeParent),
otherPid(aOtherPid),
entriesToUpdate(aEntriesToUpdate) {}
destTreeParent(aDestTreeParent) {}
uint32_t cloneID;
bool cloneChildren;
nsISHEntry* replaceEntry;
nsISHEntry* destTreeParent;
nsCOMPtr<nsISHEntry> resultEntry;
uint64_t otherPid;
// see comment for WalkHistoryEntriesFunc
nsTArray<EntriesAndBrowsingContextData>* entriesToUpdate;
};
nsresult nsSHistory::CloneAndReplaceChild(nsISHEntry* aEntry,
BrowsingContext* aOwnerBC,
int32_t aChildIndex, void* aData) {
MOZ_ASSERT(
XRE_IsParentProcess() || !StaticPrefs::fission_sessionHistoryInParent(),
"We should be in the parent process, or SH pref should be off");
nsCOMPtr<nsISHEntry> dest;
CloneAndReplaceData* data = static_cast<CloneAndReplaceData*>(aData);
uint32_t cloneID = data->cloneID;
nsISHEntry* replaceEntry = data->replaceEntry;
base::ProcessId otherPid = data->otherPid;
if (!aEntry) {
if (data->destTreeParent) {
@ -480,15 +457,14 @@ nsresult nsSHistory::CloneAndReplaceChild(nsISHEntry* aEntry,
if (srcID != cloneID || data->cloneChildren) {
// Walk the children
CloneAndReplaceData childData(cloneID, replaceEntry, data->cloneChildren,
dest, otherPid, data->entriesToUpdate);
dest);
rv = nsSHistory::WalkHistoryEntries(aEntry, aOwnerBC, CloneAndReplaceChild,
&childData);
NS_ENSURE_SUCCESS(rv, rv);
}
if (srcID != cloneID && aOwnerBC) {
nsSHistory::HandleEntriesToSwapInDocShell(aOwnerBC, aEntry, dest,
data->entriesToUpdate, otherPid);
nsSHistory::HandleEntriesToSwapInDocShell(aOwnerBC, aEntry, dest);
}
if (data->destTreeParent) {
@ -501,13 +477,10 @@ nsresult nsSHistory::CloneAndReplaceChild(nsISHEntry* aEntry,
// static
nsresult nsSHistory::CloneAndReplace(
nsISHEntry* aSrcEntry, BrowsingContext* aOwnerBC, uint32_t aCloneID,
nsISHEntry* aReplaceEntry, bool aCloneChildren, nsISHEntry** aDestEntry,
uint64_t aOtherPid,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate) {
nsISHEntry* aReplaceEntry, bool aCloneChildren, nsISHEntry** aDestEntry) {
NS_ENSURE_ARG_POINTER(aDestEntry);
NS_ENSURE_TRUE(aReplaceEntry, NS_ERROR_FAILURE);
CloneAndReplaceData data(aCloneID, aReplaceEntry, aCloneChildren, nullptr,
aOtherPid, aEntriesToUpdate);
CloneAndReplaceData data(aCloneID, aReplaceEntry, aCloneChildren, nullptr);
nsresult rv = CloneAndReplaceChild(aSrcEntry, aOwnerBC, 0, &data);
data.resultEntry.swap(*aDestEntry);
return rv;
@ -517,31 +490,19 @@ NS_IMETHODIMP
nsSHistory::AddChildSHEntryHelper(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
BrowsingContext* aBC, bool aCloneChildren) {
nsCOMPtr<nsISHEntry> child;
int32_t entriesPurged;
nsresult rv = AddChildSHEntryHelper(
aCloneRef, aNewEntry, aBC, aCloneChildren,
0 /*unused, passed in by SHEntryParent::RecvAddChildSHEntryHelper
*/
,
nullptr /* array - this will be set in
SHistory::RecvAddChildSHEntryHelper if we are going over IPC,
else, it is not needed */
,
&entriesPurged /*used by SHEntryChild::AddToRootSessionHistory but
not here */
,
getter_AddRefs(child));
nsresult rv = AddChildSHEntryHelper(aCloneRef, aNewEntry, aBC, aCloneChildren,
getter_AddRefs(child));
if (NS_SUCCEEDED(rv)) {
child->SetDocshellID(aBC->GetHistoryID());
}
return rv;
}
nsresult nsSHistory::AddChildSHEntryHelper(
nsISHEntry* aCloneRef, nsISHEntry* aNewEntry, BrowsingContext* aBC,
bool aCloneChildren, uint64_t aOtherPid,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate,
int32_t* aEntriesPurged, nsISHEntry** aNextEntry) {
nsresult nsSHistory::AddChildSHEntryHelper(nsISHEntry* aCloneRef,
nsISHEntry* aNewEntry,
BrowsingContext* aBC,
bool aCloneChildren,
nsISHEntry** aNextEntry) {
/* You are currently in the rootDocShell.
* You will get here when a subframe has a new url
* to load and you have walked up the tree all the
@ -561,10 +522,9 @@ nsresult nsSHistory::AddChildSHEntryHelper(
nsresult rv = NS_OK;
uint32_t cloneID = aCloneRef->GetID();
rv = nsSHistory::CloneAndReplace(currentHE, aBC, cloneID, aNewEntry,
aCloneChildren, aNextEntry, aOtherPid,
aEntriesToUpdate);
aCloneChildren, aNextEntry);
if (NS_SUCCEEDED(rv)) {
rv = AddEntry(*aNextEntry, true, aEntriesPurged);
rv = AddEntry(*aNextEntry, true);
}
return rv;
}
@ -572,15 +532,7 @@ nsresult nsSHistory::AddChildSHEntryHelper(
nsresult nsSHistory::SetChildHistoryEntry(nsISHEntry* aEntry,
BrowsingContext* aBC,
int32_t aEntryIndex, void* aData) {
MOZ_ASSERT(
XRE_IsParentProcess() || !StaticPrefs::fission_sessionHistoryInParent(),
"We should be in the parent process, or 'SH in parent' pref should be "
"off");
SwapEntriesData* data = static_cast<SwapEntriesData*>(aData);
uint64_t otherPid = data->otherPid;
MOZ_ASSERT(data->entriesToUpdate || otherPid == 0,
"entriesToUpdate can't be null if we were called over IPC");
if (!aBC || aBC == data->ignoreBC) {
return NS_OK;
}
@ -621,11 +573,9 @@ nsresult nsSHistory::SetChildHistoryEntry(nsISHEntry* aEntry,
destEntry = destTreeRoot;
}
nsSHistory::HandleEntriesToSwapInDocShell(aBC, aEntry, destEntry,
data->entriesToUpdate, otherPid);
nsSHistory::HandleEntriesToSwapInDocShell(aBC, aEntry, destEntry);
// Now handle the children of aEntry.
SwapEntriesData childData = {data->ignoreBC, destTreeRoot, destEntry,
otherPid, data->entriesToUpdate};
SwapEntriesData childData = {data->ignoreBC, destTreeRoot, destEntry};
return nsSHistory::WalkHistoryEntries(aEntry, aBC, SetChildHistoryEntry,
&childData);
}
@ -633,38 +583,15 @@ nsresult nsSHistory::SetChildHistoryEntry(nsISHEntry* aEntry,
// static
void nsSHistory::HandleEntriesToSwapInDocShell(
mozilla::dom::BrowsingContext* aBC, nsISHEntry* aOldEntry,
nsISHEntry* aNewEntry,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate,
uint64_t aOtherPid) {
nsISHEntry* aNewEntry) {
bool shPref = StaticPrefs::fission_sessionHistoryInParent();
if (XRE_IsParentProcess()) {
aBC->Canonical()->SwapHistoryEntries(aOldEntry, aNewEntry);
}
if (aBC->IsInProcess() || !shPref) {
nsDocShell* docshell = static_cast<nsDocShell*>(aBC->GetDocShell());
if (docshell) {
docshell->SwapHistoryEntries(aOldEntry, aNewEntry);
}
} else if (aBC->Canonical()->IsOwnedByProcess(aOtherPid)) {
EntriesAndBrowsingContextData* toUpdate = aEntriesToUpdate->AppendElement();
toUpdate->oldEntry = aOldEntry;
toUpdate->newEntry = aNewEntry;
toUpdate->context = aBC;
} else {
// XXX anny: this is currently not working! see bug 1581970
// This BC is owned by a process different from the caller,
// so we can send the entries right away to a different process
ContentParent* cp = aBC->Canonical()->GetContentParent();
auto convert = [](auto entry) {
return static_cast<CrossProcessSHEntry*>(
static_cast<LegacySHEntry*>(static_cast<nsSHEntry*>(entry)));
};
// We are performing a nested IPC call to a different process
Unused << cp->SendUpdateSHEntriesInDocShell(convert(aOldEntry),
convert(aNewEntry), aBC);
// FIXME Bug 1633988: Need to update entries?
}
}
@ -674,29 +601,6 @@ nsSHistory::AddToRootSessionHistory(bool aCloneChildren, nsISHEntry* aOSHE,
uint32_t aLoadType, bool aShouldPersist,
Maybe<int32_t>* aPreviousEntryIndex,
Maybe<int32_t>* aLoadedEntryIndex) {
int32_t entriesPurged;
nsresult rv = AddToRootSessionHistory(
aCloneChildren, aOSHE, aBC, aEntry, aLoadType, aShouldPersist,
0 /* unused, passed in by SHEntryParent::RecvAddToRootSessionHistory */,
aPreviousEntryIndex, aLoadedEntryIndex,
nullptr /* array - this will be set in RecvAddToRootSessionHistory if we
are going over IPC, else, it is not needed */
,
&entriesPurged
/* used by SHEntryChild::AddToRootSessionHistory but not here */);
if (NS_SUCCEEDED(rv)) {
aEntry->SetDocshellID(aBC->GetHistoryID());
}
return rv;
}
nsresult nsSHistory::AddToRootSessionHistory(
bool aCloneChildren, nsISHEntry* aOSHE, BrowsingContext* aBC,
nsISHEntry* aEntry, uint32_t aLoadType, bool aShouldPersist,
uint64_t aOtherPid, Maybe<int32_t>* previousEntryIndex,
Maybe<int32_t>* aLoadedEntryIndex,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate,
int32_t* aEntriesPurged) {
nsresult rv = NS_OK;
// If we need to clone our children onto the new session
@ -705,8 +609,7 @@ nsresult nsSHistory::AddToRootSessionHistory(
uint32_t cloneID = aOSHE->GetID();
nsCOMPtr<nsISHEntry> newEntry;
nsSHistory::CloneAndReplace(aOSHE, aBC, cloneID, aEntry, true,
getter_AddRefs(newEntry), aOtherPid,
aEntriesToUpdate);
getter_AddRefs(newEntry));
NS_ASSERTION(aEntry == newEntry,
"The new session history should be in the new entry");
}
@ -732,12 +635,15 @@ nsresult nsSHistory::AddToRootSessionHistory(
}
if (addToSHistory) {
// Add to session history
*previousEntryIndex = Some(mIndex);
rv = AddEntry(aEntry, aShouldPersist, aEntriesPurged);
*aPreviousEntryIndex = Some(mIndex);
rv = AddEntry(aEntry, aShouldPersist);
*aLoadedEntryIndex = Some(mIndex);
MOZ_LOG(gPageCacheLog, LogLevel::Verbose,
("Previous index: %d, Loaded index: %d",
previousEntryIndex->value(), aLoadedEntryIndex->value()));
aPreviousEntryIndex->value(), aLoadedEntryIndex->value()));
}
if (NS_SUCCEEDED(rv)) {
aEntry->SetDocshellID(aBC->GetHistoryID());
}
return rv;
}
@ -747,14 +653,7 @@ nsresult nsSHistory::AddToRootSessionHistory(
*/
NS_IMETHODIMP
nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist) {
int32_t dummy = 0;
return AddEntry(aSHEntry, aPersist, &dummy);
}
nsresult nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist,
int32_t* aEntriesPurged) {
NS_ENSURE_ARG(aSHEntry);
*aEntriesPurged = 0;
nsCOMPtr<nsISHistory> shistoryOfEntry = aSHEntry->GetShistory();
if (shistoryOfEntry != this) {
@ -798,8 +697,7 @@ nsresult nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist,
// Purge History list if it is too long
if (gHistoryMaxSize >= 0 && Length() > gHistoryMaxSize) {
*aEntriesPurged = Length() - gHistoryMaxSize;
PurgeHistory(*aEntriesPurged);
PurgeHistory(Length() - gHistoryMaxSize);
}
return NS_OK;
@ -1793,8 +1691,7 @@ nsresult nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry,
NS_IMETHODIMP
nsSHistory::CreateEntry(nsISHEntry** aEntry) {
nsCOMPtr<nsISHEntry> entry =
new nsLegacySHEntry(this, SHEntryChildShared::CreateSharedID());
nsCOMPtr<nsISHEntry> entry = new nsSHEntry(this);
entry.forget(aEntry);
return NS_OK;
}

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

@ -64,10 +64,6 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
nsISHEntry* destTreeRoot; // constant; the root of the dest tree
nsISHEntry* destTreeParent; // constant; the node under destTreeRoot
// whose children will correspond to aEntry
uint64_t otherPid; // constant; pid of the process which indirectly called
// SetChildHistoryEntry
// see comment for WalkHistoryEntriesFunc
nsTArray<EntriesAndBrowsingContextData>* entriesToUpdate;
};
explicit nsSHistory(mozilla::dom::BrowsingContext* aRootBC);
@ -108,11 +104,10 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
// have that pointer updated to point to the cloned history entry.
// If aCloneChildren is true then the children of the entry with id
// |aCloneID| will be cloned into |aReplaceEntry|.
static nsresult CloneAndReplace(
nsISHEntry* aSrcEntry, mozilla::dom::BrowsingContext* aOwnerBC,
uint32_t aCloneID, nsISHEntry* aReplaceEntry, bool aCloneChildren,
nsISHEntry** aDestEntry, uint64_t aOtherPid,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate);
static nsresult CloneAndReplace(nsISHEntry* aSrcEntry,
mozilla::dom::BrowsingContext* aOwnerBC,
uint32_t aCloneID, nsISHEntry* aReplaceEntry,
bool aCloneChildren, nsISHEntry** aDestEntry);
// Child-walking callback for CloneAndReplace
static nsresult CloneAndReplaceChild(nsISHEntry* aEntry,
@ -132,26 +127,12 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
WalkHistoryEntriesFunc aCallback,
void* aData);
nsresult AddToRootSessionHistory(
bool aCloneChildren, nsISHEntry* aOSHE,
mozilla::dom::BrowsingContext* aBC, nsISHEntry* aEntry,
uint32_t aLoadType, bool aShouldPersist, uint64_t aOtherPid,
mozilla::Maybe<int32_t>* aPreviousEntryIndex,
mozilla::Maybe<int32_t>* aLoadedEntryIndex,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate,
int32_t* aEntriesPurged);
nsresult AddChildSHEntryHelper(
nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
mozilla::dom::BrowsingContext* aBC, bool aCloneChildren,
uint64_t aOtherPid,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate,
int32_t* aEntriesPurged, nsISHEntry** aNextEntry);
nsresult AddChildSHEntryHelper(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
mozilla::dom::BrowsingContext* aBC,
bool aCloneChildren, nsISHEntry** aNextEntry);
nsTArray<nsCOMPtr<nsISHEntry>>& Entries() { return mEntries; }
nsresult AddEntry(nsISHEntry* aSHEntry, bool aPersist,
int32_t* aEntriesPurged);
void RemoveEntries(nsTArray<nsID>& aIDs, int32_t aStartIndex,
bool* aDidRemove);
@ -237,11 +218,9 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
// process. Otherwise, if the browsing context is in a different process, we
// do a nested IPC call to that process to update the docshell in that
// process.
static void HandleEntriesToSwapInDocShell(
mozilla::dom::BrowsingContext* aBC, nsISHEntry* aOldEntry,
nsISHEntry* aNewEntry,
nsTArray<EntriesAndBrowsingContextData>* aEntriesToUpdate,
uint64_t aOtherPid);
static void HandleEntriesToSwapInDocShell(mozilla::dom::BrowsingContext* aBC,
nsISHEntry* aOldEntry,
nsISHEntry* aNewEntry);
protected:
// Length of mEntries.

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

@ -61,8 +61,6 @@
#include "mozilla/dom/RemoteWorkerService.h"
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/SHEntryChild.h"
#include "mozilla/dom/SHistoryChild.h"
#include "mozilla/dom/URLClassifierChild.h"
#include "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/dom/WorkerDebugger.h"
@ -3234,42 +3232,6 @@ bool ContentChild::DeallocPSessionStorageObserverChild(
return true;
}
PSHEntryChild* ContentChild::AllocPSHEntryChild(PSHistoryChild* aSHistory,
uint64_t aSharedID) {
// We take a strong reference for the IPC layer. The Release implementation
// for SHEntryChild will ask the IPC layer to release it (through
// DeallocPSHEntryChild) if that is the only remaining reference.
RefPtr<SHEntryChild> child;
child = new SHEntryChild(static_cast<SHistoryChild*>(aSHistory), aSharedID);
return child.forget().take();
}
void ContentChild::DeallocPSHEntryChild(PSHEntryChild* aActor) {
// Release the strong reference we took in AllocPSHEntryChild for the IPC
// layer.
RefPtr<SHEntryChild> child(dont_AddRef(static_cast<SHEntryChild*>(aActor)));
}
PSHistoryChild* ContentChild::AllocPSHistoryChild(
const MaybeDiscarded<BrowsingContext>& aContext) {
// FIXME: How should SHistoryChild construction deal with a null or discarded
// BrowsingContext? This will likely kill the current child process.
if (NS_WARN_IF(aContext.IsNullOrDiscarded())) {
return nullptr;
}
// We take a strong reference for the IPC layer. The Release implementation
// for SHistoryChild will ask the IPC layer to release it (through
// DeallocPSHistoryChild) if that is the only remaining reference.
return do_AddRef(new SHistoryChild(aContext.get())).take();
}
void ContentChild::DeallocPSHistoryChild(PSHistoryChild* aActor) {
// Release the strong reference we took in AllocPSHistoryChild for the IPC
// layer.
RefPtr<SHistoryChild> child(dont_AddRef(static_cast<SHistoryChild*>(aActor)));
}
mozilla::ipc::IPCResult ContentChild::RecvActivate(PBrowserChild* aTab) {
BrowserChild* tab = static_cast<BrowserChild*>(aTab);
return tab->RecvActivate();
@ -3522,18 +3484,6 @@ mozilla::ipc::IPCResult ContentChild::RecvUpdateMediaControlKeysEvent(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvDestroySHEntrySharedState(
const uint64_t& aID) {
SHEntryChildShared::Remove(aID);
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvEvictContentViewers(
nsTArray<uint64_t>&& aToEvictSharedStateIDs) {
SHEntryChildShared::EvictContentViewers(std::move(aToEvictSharedStateIDs));
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvSessionStorageData(
const uint64_t aTopContextId, const nsACString& aOriginAttrs,
const nsACString& aOriginKey, const nsTArray<KeyValuePair>& aDefaultData,
@ -3548,18 +3498,6 @@ mozilla::ipc::IPCResult ContentChild::RecvSessionStorageData(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvUpdateSHEntriesInDocShell(
CrossProcessSHEntry* aOldEntry, CrossProcessSHEntry* aNewEntry,
const MaybeDiscarded<BrowsingContext>& aContext) {
MOZ_ASSERT(!aContext.IsNull(), "Browsing context cannot be null");
nsDocShell* docshell =
static_cast<nsDocShell*>(aContext.GetMaybeDiscarded()->GetDocShell());
if (docshell) {
docshell->SwapHistoryEntries(aOldEntry->ToSHEntryChild(),
aNewEntry->ToSHEntryChild());
}
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvOnAllowAccessFor(
const MaybeDiscarded<BrowsingContext>& aContext,

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

@ -600,16 +600,6 @@ class ContentChild final : public PContentChild,
bool DeallocPSessionStorageObserverChild(
PSessionStorageObserverChild* aActor);
PSHEntryChild* AllocPSHEntryChild(PSHistoryChild* aSHistory,
uint64_t aSharedID);
void DeallocPSHEntryChild(PSHEntryChild*);
PSHistoryChild* AllocPSHistoryChild(
const MaybeDiscarded<BrowsingContext>& aContext);
void DeallocPSHistoryChild(PSHistoryChild* aActor);
nsTArray<LookAndFeelInt>& LookAndFeelCache() { return mLookAndFeelCache; }
/**
@ -658,20 +648,11 @@ class ContentChild final : public PContentChild,
return mBrowsingContextFieldEpoch;
}
mozilla::ipc::IPCResult RecvDestroySHEntrySharedState(const uint64_t& aID);
mozilla::ipc::IPCResult RecvEvictContentViewers(
nsTArray<uint64_t>&& aToEvictSharedStateIDs);
mozilla::ipc::IPCResult RecvSessionStorageData(
uint64_t aTopContextId, const nsACString& aOriginAttrs,
const nsACString& aOriginKey, const nsTArray<KeyValuePair>& aDefaultData,
const nsTArray<KeyValuePair>& aSessionData);
mozilla::ipc::IPCResult RecvUpdateSHEntriesInDocShell(
CrossProcessSHEntry* aOldEntry, CrossProcessSHEntry* aNewEntry,
const MaybeDiscarded<BrowsingContext>& aContext);
mozilla::ipc::IPCResult RecvOnAllowAccessFor(
const MaybeDiscarded<BrowsingContext>& aContext,
const nsCString& aTrackingOrigin, uint32_t aCookieBehavior,

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

@ -108,8 +108,6 @@
#include "mozilla/dom/PresentationParent.h"
#include "mozilla/dom/ProcessMessageManager.h"
#include "mozilla/dom/PushNotifier.h"
#include "mozilla/dom/SHEntryParent.h"
#include "mozilla/dom/SHistoryParent.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/ServiceWorkerRegistrar.h"
#include "mozilla/dom/ServiceWorkerUtils.h"
@ -5650,25 +5648,6 @@ bool ContentParent::DeallocPSessionStorageObserverParent(
return mozilla::dom::DeallocPSessionStorageObserverParent(aActor);
}
PSHEntryParent* ContentParent::AllocPSHEntryParent(PSHistoryParent* aSHistory,
uint64_t aSharedID) {
return SHistoryParent::CreateEntry(this, aSHistory, aSharedID);
}
void ContentParent::DeallocPSHEntryParent(PSHEntryParent* aEntry) {
delete static_cast<SHEntryParent*>(aEntry);
}
PSHistoryParent* ContentParent::AllocPSHistoryParent(
const MaybeDiscarded<BrowsingContext>& aContext) {
MOZ_ASSERT(!aContext.IsNull());
return new SHistoryParent(aContext.GetMaybeDiscarded()->Canonical());
}
void ContentParent::DeallocPSHistoryParent(PSHistoryParent* aActor) {
delete static_cast<SHistoryParent*>(aActor);
}
mozilla::ipc::IPCResult ContentParent::RecvMaybeReloadPlugins() {
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
pluginHost->ReloadPlugins();
@ -5828,35 +5807,6 @@ mozilla::ipc::IPCResult ContentParent::RecvNotifyPictureInPictureModeChanged(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvUpdateSHEntriesInBC(
PSHEntryParent* aNewLSHE, PSHEntryParent* aNewOSHE,
const MaybeDiscarded<BrowsingContext>& aMaybeContext) {
if (aMaybeContext.IsNullOrDiscarded()) {
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
("ParentIPC: Trying to update a browsing context that does not "
"exist or has been discarded"));
return IPC_OK();
}
auto aContext = aMaybeContext.get()->Canonical();
MOZ_ASSERT(aContext);
if (!aContext->IsOwnedByProcess(ChildID())) {
// We are trying to update a child BrowsingContext in another child
// process. This is illegal since the owner of the BrowsingContext
// is the proccess with the in-process docshell, which is tracked
// by OwnerProcessId.
MOZ_DIAGNOSTIC_ASSERT(
false,
"Trying to update a child BrowsingContext in another child process");
return IPC_OK();
}
SHEntryParent* newLSHEparent = static_cast<SHEntryParent*>(aNewLSHE);
SHEntryParent* newOSHEparent = static_cast<SHEntryParent*>(aNewOSHE);
nsISHEntry* lshe = newLSHEparent ? newLSHEparent->mEntry.get() : nullptr;
nsISHEntry* oshe = newOSHEparent ? newOSHEparent->mEntry.get() : nullptr;
aContext->UpdateSHEntries(lshe, oshe);
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvAbortOtherOrientationPendingPromises(
const MaybeDiscarded<BrowsingContext>& aContext) {
if (aContext.IsNullOrDiscarded()) {

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

@ -584,16 +584,6 @@ class ContentParent final
bool DeallocPSessionStorageObserverParent(
PSessionStorageObserverParent* aActor);
PSHEntryParent* AllocPSHEntryParent(PSHistoryParent* aSHistory,
uint64_t aSharedID);
void DeallocPSHEntryParent(PSHEntryParent*);
PSHistoryParent* AllocPSHistoryParent(
const MaybeDiscarded<BrowsingContext>& aContext);
void DeallocPSHistoryParent(PSHistoryParent* aActor);
bool DeallocPURLClassifierLocalParent(PURLClassifierLocalParent* aActor);
bool DeallocPURLClassifierParent(PURLClassifierParent* aActor);
@ -1284,10 +1274,6 @@ class ContentParent final
uint32_t aShutdownStateId,
ServiceWorkerShutdownState::Progress aProgress);
mozilla::ipc::IPCResult RecvUpdateSHEntriesInBC(
PSHEntryParent* aNewLSHE, PSHEntryParent* aNewOSHE,
const MaybeDiscarded<BrowsingContext>& aMaybeContext);
mozilla::ipc::IPCResult RecvRawMessage(const JSActorMessageMeta& aMeta,
const ClonedMessageData& aData,
const ClonedMessageData& aStack);

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

@ -13,7 +13,6 @@ include IPCBlob;
include IPCStream;
include protocol PIPCBlobInputStream;
include ProtocolTypes;
include protocol PSHEntry;
using struct mozilla::void_t
from "ipc/IPCMessageUtils.h";
@ -41,9 +40,7 @@ using refcounted class nsIInputStream from "mozilla/ipc/IPCStreamUtils.h";
using refcounted class nsIReferrerInfo from "mozilla/dom/ReferrerInfoUtils.h";
using refcounted class nsIVariant from "mozilla/dom/PropertyBagUtils.h";
using class mozilla::TimeStamp from "mozilla/TimeStamp.h";
using refcounted class nsISHEntry from "nsISHEntry.h";
using refcounted class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";
using refcounted class mozilla::dom::CrossProcessSHEntry from "mozilla/dom/MaybeNewPSHEntry.h";
using mozilla::dom::WindowContextInitializer from "mozilla/dom/WindowContext.h";
namespace mozilla {
@ -286,10 +283,6 @@ struct DocShellLoadStateInit
nsIInputStream HeadersStream;
nsString SrcdocData; // useless without sourcedocshell
// This might be missing if serialization of session history entries is
// not supported. This is the case when 'fission.sessionHistoryInParent'
// pref is off.
CrossProcessSHEntry SHEntry;
// Fields missing due to lack of need or serialization
// nsCOMPtr<nsIDocShell> mSourceDocShell;
@ -394,11 +387,5 @@ struct OwnerShowInfo {
nsSizeMode sizeMode;
};
struct SwapEntriesDocshellData {
CrossProcessSHEntry oldEntry;
CrossProcessSHEntry newEntry;
MaybeDiscardedBrowsingContext context;
};
} // namespace dom
} // namespace mozilla

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

@ -46,8 +46,6 @@ include protocol PRemoteDecoderManager;
include protocol PProfiler;
include protocol PScriptCache;
include protocol PSessionStorageObserver;
include protocol PSHEntry;
include protocol PSHistory;
include protocol PBenchmarkStorage;
include DOMTypes;
include JavaScriptTypes;
@ -122,7 +120,6 @@ using mozilla::dom::MaybeMediaMetadataBase from "mozilla/dom/MediaSessionIPCUtil
using mozilla::dom::MediaSessionPlaybackState from "mozilla/dom/MediaSessionBinding.h";
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
using mozilla::dom::ServiceWorkerShutdownState::Progress from "mozilla/dom/ServiceWorkerShutdownState.h";
using refcounted class mozilla::dom::CrossProcessSHEntry from "mozilla/dom/MaybeNewPSHEntry.h";
using mozilla::ContentBlockingNotifier::StorageAccessGrantedReason from "mozilla/ContentBlockingNotifier.h";
using mozilla::ContentBlockingNotifier::BlockingDecision from "mozilla/ContentBlockingNotifier.h";
using mozilla::ContentBlocking::StorageAccessPromptChoices from "mozilla/ContentBlocking.h";
@ -405,8 +402,6 @@ nested(upto inside_cpow) sync protocol PContent
manages PScriptCache;
manages PLoginReputation;
manages PSessionStorageObserver;
manages PSHEntry;
manages PSHistory;
manages PBenchmarkStorage;
// Depending on exactly how the new browser is being created, it might be
@ -868,10 +863,6 @@ child:
async InitSandboxTesting(Endpoint<PSandboxTestingChild> aEndpoint);
#endif
async DestroySHEntrySharedState(uint64_t aID);
async EvictContentViewers(uint64_t[] aToEvictSharedStateIDs);
async LoadURI(MaybeDiscardedBrowsingContext aContext, nsDocShellLoadState aLoadState, bool aSetNavigating)
returns (bool aSuccess);
@ -879,11 +870,6 @@ child:
async DisplayLoadError(MaybeDiscardedBrowsingContext aContext, nsString aURI);
// Tell aContext's docshell to update its mOSHE and mLSHE entries
async UpdateSHEntriesInDocShell(CrossProcessSHEntry aOldEntry,
CrossProcessSHEntry aNewEntry,
MaybeDiscardedBrowsingContext aContext);
async OnAllowAccessFor(MaybeDiscardedBrowsingContext aParentContext,
nsCString aTrackingOrigin,
uint32_t aCookieBehavior,
@ -972,11 +958,6 @@ parent:
async PSessionStorageObserver();
async PSHistory(MaybeDiscardedBrowsingContext aContext);
// Clone using shared id.
sync PSHEntry(nullable PSHistory shistory, uint64_t sharedID);
async PBenchmarkStorage();
// Services remoting
@ -1590,13 +1571,6 @@ parent:
async ReportServiceWorkerShutdownProgress(uint32_t aShutdownStateId,
Progress aProgress);
/**
* Whenever docshell updates its SH entries, we need to update them in
* the corresponding BrowsingContext
*/
async UpdateSHEntriesInBC(nullable PSHEntry aNewLSHE, nullable
PSHEntry aNewOSHE, MaybeDiscardedBrowsingContext aContext);
/**
* Whenever a document is updating the OrientationLock, we need to
* reject the orientationPendingPromises in other processes.

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

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PContent;
include protocol PSHEntry;
include protocol PWebBrowserPersistResources;
include protocol PWebBrowserPersistSerialize;
include protocol PFileDescriptorSet;
@ -18,8 +17,9 @@ using refcounted class nsIReferrerInfo from "mozilla/dom/ReferrerInfoUtils.h";
namespace mozilla {
// FIXME When session history lives in the parent we need to figure out how to
// point the parent process at the right entry to get the cache key.
union SessionHistoryEntryOrCacheKey {
nullable PSHEntry;
uint32_t;
};

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

@ -13,7 +13,6 @@
#include "WebBrowserPersistLocalDocument.h"
#include "WebBrowserPersistResourcesChild.h"
#include "WebBrowserPersistSerializeChild.h"
#include "SHEntryChild.h"
#include "mozilla/StaticPrefs_fission.h"
namespace mozilla {
@ -58,13 +57,7 @@ void WebBrowserPersistDocumentChild::Start(
ENSURE(aDocument->GetTitle(attrs.title()));
ENSURE(aDocument->GetContentDisposition(attrs.contentDisposition()));
// shEntryChild needs to remain in scope until after the SendAttributes call,
// to keep the actor alive.
RefPtr<dom::SHEntryChild> shEntryChild;
if (StaticPrefs::fission_sessionHistoryInParent()) {
shEntryChild = aDocument->GetHistory().downcast<dom::SHEntryChild>();
attrs.sessionHistoryEntryOrCacheKey() = shEntryChild;
} else {
if (!StaticPrefs::fission_sessionHistoryInParent()) {
attrs.sessionHistoryEntryOrCacheKey() = aDocument->GetCacheKey();
}

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

@ -8,7 +8,6 @@
#include "WebBrowserPersistDocumentParent.h"
#include "WebBrowserPersistResourcesParent.h"
#include "WebBrowserPersistSerializeParent.h"
#include "SHEntryParent.h"
#include "mozilla/Unused.h"
#include "mozilla/ipc/BackgroundUtils.h"
@ -29,12 +28,6 @@ WebBrowserPersistRemoteDocument ::WebBrowserPersistRemoteDocument(
} else {
NS_WARNING("Failed to obtain principal!");
}
if (mAttrs.sessionHistoryEntryOrCacheKey().type() ==
SessionHistoryEntryOrCacheKey::TPSHEntryParent) {
mSHEntry = static_cast<dom::SHEntryParent*>(
mAttrs.sessionHistoryEntryOrCacheKey().get_PSHEntryParent())
->GetSHEntry();
}
}
WebBrowserPersistRemoteDocument::~WebBrowserPersistRemoteDocument() {
@ -102,11 +95,7 @@ NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetCacheKey(uint32_t* aCacheKey) {
*aCacheKey = 0;
if (mAttrs.sessionHistoryEntryOrCacheKey().type() ==
SessionHistoryEntryOrCacheKey::TPSHEntryParent) {
if (mSHEntry) {
*aCacheKey = mSHEntry->GetCacheKey();
}
} else {
SessionHistoryEntryOrCacheKey::Tuint32_t) {
*aCacheKey = mAttrs.sessionHistoryEntryOrCacheKey();
}
return NS_OK;

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

@ -807,139 +807,6 @@ description = Legacy NPAPI IPC
description = Legacy NPAPI IPC
[PPluginStream::__delete__]
description = Legacy NPAPI IPC
# Session history
[PSHistory::GetCount]
description = Standing up Fission
[PSHistory::GetIndex]
description = Standing up Fission
[PSHistory::SetIndex]
description = Standing up Fission
[PSHistory::GetRequestedIndex]
description = Standing up Fission
[PSHistory::GetEntryAtIndex]
description = Standing up Fission
[PSHistory::PurgeHistory]
description = Standing up Fission
[PSHistory::ReloadCurrentEntry]
description = Standing up Fission
[PSHistory::GotoIndex]
description = Standing up Fission
[PSHistory::GetIndexOfEntry]
description = Standing up Fission
[PSHistory::AddEntry]
description = Standing up Fission
[PSHistory::ReplaceEntry]
description = Standing up Fission
[PSHistory::NotifyOnHistoryReload]
description = Standing up Fission
[PSHistory::AddToRootSessionHistory]
description = Standing up Fission
[PSHistory::AddChildSHEntryHelper]
description = Standing up Fission
[PSHistory::RemoveEntries]
description = Standing up Fission
[PSHistory::Reload]
description = Standing up Fission
[PSHistory::GetAllEntries]
description = Standing up Fission
[PSHistory::FindEntryForBFCache]
description = Standing up Fission
[PContent::PSHEntry]
description = Standing up Fission
[PSHEntry::Clone]
description = Standing up Fission
[PSHEntry::GetURI]
description = Standing up Fission
[PSHEntry::GetOriginalURI]
description = Standing up Fission
[PSHEntry::GetResultPrincipalURI]
description = Standing up Fission
[PSHEntry::GetLoadReplace]
description = Standing up Fission
[PSHEntry::GetTitle]
description = Standing up Fission
[PSHEntry::GetIsSubFrame]
description = Standing up Fission
[PSHEntry::GetReferrerInfo]
description = Standing up Fission
[PSHEntry::GetSticky]
description = Standing up Fission
[PSHEntry::GetPostData]
description = Standing up Fission
[PSHEntry::GetParent]
description = Standing up Fission
[PSHEntry::GetLoadType]
description = Standing up Fission
[PSHEntry::GetID]
description = Standing up Fission
[PSHEntry::GetCacheKey]
description = Standing up Fission
[PSHEntry::GetExpirationStatus]
description = Standing up Fission
[PSHEntry::GetContentType]
description = Standing up Fission
[PSHEntry::GetURIWasModified]
description = Standing up Fission
[PSHEntry::GetTriggeringPrincipal]
description = Standing up Fission
[PSHEntry::GetPrincipalToInherit]
description = Standing up Fission
[PSHEntry::GetStoragePrincipalToInherit]
description = Standing up Fission
[PSHEntry::GetCsp]
description = Standing up Fission
[PSHEntry::GetStateData]
description = Standing up Fission
[PSHEntry::GetDocshellID]
description = Standing up Fission
[PSHEntry::GetIsSrcdocEntry]
description = Standing up Fission
[PSHEntry::GetSrcdocData]
description = Standing up Fission
[PSHEntry::GetBaseURI]
description = Standing up Fission
[PSHEntry::GetScrollRestorationIsManual]
description = Standing up Fission
[PSHEntry::GetLoadedInThisProcess]
description = Standing up Fission
[PSHEntry::GetLastTouched]
description = Standing up Fission
[PSHEntry::GetChildCount]
description = Standing up Fission
[PSHEntry::GetPersist]
description = Standing up Fission
[PSHEntry::GetScrollPosition]
description = Standing up Fission
[PSHEntry::GetViewerBounds]
description = Standing up Fission
[PSHEntry::HasDetachedEditor]
description = Standing up Fission
[PSHEntry::IsDynamicallyAdded]
description = Standing up Fission
[PSHEntry::HasDynamicallyAddedChild]
description = Standing up Fission
[PSHEntry::AdoptBFCacheEntry]
description = Standing up Fission
[PSHEntry::SharesDocumentWith]
description = Standing up Fission
[PSHEntry::AddChild]
description = Standing up Fission
[PSHEntry::RemoveChild]
description = Standing up Fission
[PSHEntry::GetChildAt]
description = Standing up Fission
[PSHEntry::GetChildSHEntryIfHasNoDynamicallyAddedChild]
description = Standing up Fission
[PSHEntry::ReplaceChild]
description = Standing up Fission
[PSHEntry::__delete__]
description = Standing up Fission
[PSHEntry::CreateLoadInfo]
description = Standing up Fission
[PSHEntry::SyncTreesForSubframeNavigation]
description = Standing up Fission
# The rest
[PHeapSnapshotTempFileHelper::OpenHeapSnapshotTempFile]
description = legacy sync IPC - please add detailed description