Bug 1689601, add assertions to ensure SessionHistoryEntry objects are created only when session history in parent is enabled, r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D105234
This commit is contained in:
Olli Pettay 2021-03-02 09:44:11 +00:00
Родитель 787048eb87
Коммит 09b5456656
1 изменённых файлов: 13 добавлений и 4 удалений

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

@ -9,6 +9,7 @@
#include "nsDocShell.h"
#include "nsDocShellLoadState.h"
#include "nsIHttpChannel.h"
#include "nsIXULRuntime.h"
#include "nsSHEntryShared.h"
#include "nsSHistory.h"
#include "nsStructuredCloneContainer.h"
@ -387,20 +388,28 @@ void SessionHistoryEntry::RemoveLoadId(uint64_t aLoadId) {
}
SessionHistoryEntry::SessionHistoryEntry()
: mInfo(new SessionHistoryInfo()), mID(++gEntryID) {}
: mInfo(new SessionHistoryInfo()), mID(++gEntryID) {
MOZ_ASSERT(mozilla::SessionHistoryInParent());
}
SessionHistoryEntry::SessionHistoryEntry(nsDocShellLoadState* aLoadState,
nsIChannel* aChannel)
: mInfo(new SessionHistoryInfo(aLoadState, aChannel)), mID(++gEntryID) {}
: mInfo(new SessionHistoryInfo(aLoadState, aChannel)), mID(++gEntryID) {
MOZ_ASSERT(mozilla::SessionHistoryInParent());
}
SessionHistoryEntry::SessionHistoryEntry(SessionHistoryInfo* aInfo)
: mInfo(MakeUnique<SessionHistoryInfo>(*aInfo)), mID(++gEntryID) {}
: mInfo(MakeUnique<SessionHistoryInfo>(*aInfo)), mID(++gEntryID) {
MOZ_ASSERT(mozilla::SessionHistoryInParent());
}
SessionHistoryEntry::SessionHistoryEntry(const SessionHistoryEntry& aEntry)
: mInfo(MakeUnique<SessionHistoryInfo>(*aEntry.mInfo)),
mParent(aEntry.mParent),
mID(aEntry.mID),
mBCHistoryLength(aEntry.mBCHistoryLength) {}
mBCHistoryLength(aEntry.mBCHistoryLength) {
MOZ_ASSERT(mozilla::SessionHistoryInParent());
}
SessionHistoryEntry::~SessionHistoryEntry() {
// Null out the mParent pointers on all our kids.