Bug 1663486 - Synchronize ChildSHistory state when sending a browsing context to a new process. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D89419
This commit is contained in:
Peter Van der Beken 2020-09-08 15:24:13 +00:00
Родитель 7720088b5c
Коммит fe3f64a907
5 изменённых файлов: 39 добавлений и 5 удалений

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

@ -409,8 +409,12 @@ void BrowsingContext::CreateFromIPC(BrowsingContext::IPCInitializer&& aInit,
} }
context->mWindowless = aInit.mWindowless; context->mWindowless = aInit.mWindowless;
if (aInit.mHasSessionHistory) { if (context->GetHasSessionHistory()) {
context->InitSessionHistory(); context->CreateChildSHistory();
if (StaticPrefs::fission_sessionHistoryInParent()) {
context->GetChildSessionHistory()->SetIndexAndLength(
aInit.mSessionHistoryIndex, aInit.mSessionHistoryCount, nsID());
}
} }
// NOTE: Call through the `Set` methods for these values to ensure that any // NOTE: Call through the `Set` methods for these values to ensure that any
@ -607,7 +611,7 @@ void BrowsingContext::Attach(bool aFromIPC, ContentParent* aOriginProcess) {
PopupBlocker::RegisterOpenPopupSpam(); PopupBlocker::RegisterOpenPopupSpam();
} }
if (IsTop() && GetHasSessionHistory()) { if (IsTop() && GetHasSessionHistory() && !mChildSessionHistory) {
CreateChildSHistory(); CreateChildSHistory();
} }
@ -2069,7 +2073,10 @@ BrowsingContext::IPCInitializer BrowsingContext::GetIPCInitializer() {
init.mUseRemoteTabs = mUseRemoteTabs; init.mUseRemoteTabs = mUseRemoteTabs;
init.mUseRemoteSubframes = mUseRemoteSubframes; init.mUseRemoteSubframes = mUseRemoteSubframes;
init.mOriginAttributes = mOriginAttributes; init.mOriginAttributes = mOriginAttributes;
init.mHasSessionHistory = mChildSessionHistory != nullptr; if (mChildSessionHistory && StaticPrefs::fission_sessionHistoryInParent()) {
init.mSessionHistoryIndex = mChildSessionHistory->Index();
init.mSessionHistoryCount = mChildSessionHistory->Count();
}
init.mRequestContextId = mRequestContextId; init.mRequestContextId = mRequestContextId;
init.mFields = mFields.RawValues(); init.mFields = mFields.RawValues();
return init; return init;
@ -2726,6 +2733,12 @@ void BrowsingContext::HistoryGo(int32_t aIndex,
} }
} }
void BrowsingContext::SetChildSHistory(ChildSHistory* aChildSHistory) {
mChildSessionHistory = aChildSHistory;
mChildSessionHistory->SetBrowsingContext(this);
mFields.SetWithoutSyncing<IDX_HasSessionHistory>(true);
}
} // namespace dom } // namespace dom
namespace ipc { namespace ipc {
@ -2768,6 +2781,8 @@ void IPDLParamTraits<dom::BrowsingContext::IPCInitializer>::Write(
WriteIPDLParam(aMessage, aActor, aInit.mUseRemoteSubframes); WriteIPDLParam(aMessage, aActor, aInit.mUseRemoteSubframes);
WriteIPDLParam(aMessage, aActor, aInit.mOriginAttributes); WriteIPDLParam(aMessage, aActor, aInit.mOriginAttributes);
WriteIPDLParam(aMessage, aActor, aInit.mRequestContextId); WriteIPDLParam(aMessage, aActor, aInit.mRequestContextId);
WriteIPDLParam(aMessage, aActor, aInit.mSessionHistoryIndex);
WriteIPDLParam(aMessage, aActor, aInit.mSessionHistoryCount);
WriteIPDLParam(aMessage, aActor, aInit.mFields); WriteIPDLParam(aMessage, aActor, aInit.mFields);
} }
@ -2783,6 +2798,10 @@ bool IPDLParamTraits<dom::BrowsingContext::IPCInitializer>::Read(
&aInit->mUseRemoteSubframes) || &aInit->mUseRemoteSubframes) ||
!ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mOriginAttributes) || !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mOriginAttributes) ||
!ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mRequestContextId) || !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mRequestContextId) ||
!ReadIPDLParam(aMessage, aIterator, aActor,
&aInit->mSessionHistoryIndex) ||
!ReadIPDLParam(aMessage, aIterator, aActor,
&aInit->mSessionHistoryCount) ||
!ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mFields)) { !ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mFields)) {
return false; return false;
} }

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

@ -591,7 +591,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
bool mWindowless = false; bool mWindowless = false;
bool mUseRemoteTabs = false; bool mUseRemoteTabs = false;
bool mUseRemoteSubframes = false; bool mUseRemoteSubframes = false;
bool mHasSessionHistory = false; int32_t mSessionHistoryIndex = -1;
int32_t mSessionHistoryCount = 0;
OriginAttributes mOriginAttributes; OriginAttributes mOriginAttributes;
uint64_t mRequestContextId = 0; uint64_t mRequestContextId = 0;
@ -679,6 +680,12 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
BrowsingContext(WindowContext* aParentWindow, BrowsingContextGroup* aGroup, BrowsingContext(WindowContext* aParentWindow, BrowsingContextGroup* aGroup,
uint64_t aBrowsingContextId, Type aType, FieldValues&& aInit); uint64_t aBrowsingContextId, Type aType, FieldValues&& aInit);
void SetChildSHistory(ChildSHistory* aChildSHistory);
already_AddRefed<ChildSHistory> ForgetChildSHistory() {
// FIXME Do we need to unset mHasSessionHistory?
return mChildSessionHistory.forget();
}
private: private:
void Attach(bool aFromIPC, ContentParent* aOriginProcess); void Attach(bool aFromIPC, ContentParent* aOriginProcess);

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

@ -164,6 +164,8 @@ void CanonicalBrowsingContext::ReplacedBy(
if (mSessionHistory) { if (mSessionHistory) {
mSessionHistory->SetBrowsingContext(aNewContext); mSessionHistory->SetBrowsingContext(aNewContext);
mSessionHistory.swap(aNewContext->mSessionHistory); mSessionHistory.swap(aNewContext->mSessionHistory);
RefPtr<ChildSHistory> childSHistory = ForgetChildSHistory();
aNewContext->SetChildSHistory(childSHistory);
} }
MOZ_ASSERT(aNewContext->mLoadingEntries.IsEmpty()); MOZ_ASSERT(aNewContext->mLoadingEntries.IsEmpty());

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

@ -21,6 +21,10 @@ namespace dom {
ChildSHistory::ChildSHistory(BrowsingContext* aBrowsingContext) ChildSHistory::ChildSHistory(BrowsingContext* aBrowsingContext)
: mBrowsingContext(aBrowsingContext) {} : mBrowsingContext(aBrowsingContext) {}
void ChildSHistory::SetBrowsingContext(BrowsingContext* aBrowsingContext) {
mBrowsingContext = aBrowsingContext;
}
void ChildSHistory::SetIsInProcess(bool aIsInProcess) { void ChildSHistory::SetIsInProcess(bool aIsInProcess) {
if (!aIsInProcess) { if (!aIsInProcess) {
mHistory = nullptr; mHistory = nullptr;

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

@ -44,6 +44,8 @@ class ChildSHistory : public nsISupports, public nsWrapperCache {
explicit ChildSHistory(BrowsingContext* aBrowsingContext); explicit ChildSHistory(BrowsingContext* aBrowsingContext);
void SetBrowsingContext(BrowsingContext* aBrowsingContext);
// Create or destroy the session history implementation in the child process. // Create or destroy the session history implementation in the child process.
// This can be removed once session history is stored exclusively in the // This can be removed once session history is stored exclusively in the
// parent process. // parent process.