зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1488321 - Remove nsISHTransaction. r=nika
Because it's a wafer-thin wrapper around nsISHEntry that just complicates things. This patch leaves behind a combination of "entry" and "transaction" terminology. I'll fix that in a subsequent patch. --HG-- extra : rebase_source : ca15187447bf3d93c65ed3980ead5bca958471be
This commit is contained in:
Родитель
b546759d02
Коммит
54ca088229
|
@ -9,7 +9,6 @@ XPIDL_SOURCES += [
|
|||
'nsISHEntry.idl',
|
||||
'nsISHistory.idl',
|
||||
'nsISHistoryListener.idl',
|
||||
'nsISHTransaction.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'shistory'
|
||||
|
@ -28,7 +27,6 @@ UNIFIED_SOURCES += [
|
|||
'nsSHEntry.cpp',
|
||||
'nsSHEntryShared.cpp',
|
||||
'nsSHistory.cpp',
|
||||
'nsSHTransaction.cpp',
|
||||
'ParentSHistory.cpp',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 "nsISupports.idl"
|
||||
|
||||
interface nsISHEntry;
|
||||
|
||||
[builtinclass, scriptable, uuid(2EDF705F-D252-4971-9F09-71DD0F760DC6)]
|
||||
interface nsISHTransaction : nsISupports
|
||||
{
|
||||
/**
|
||||
* The nsISHEntry for the current transaction. Never null.
|
||||
*/
|
||||
[infallible] attribute nsISHEntry sHEntry;
|
||||
};
|
||||
|
|
@ -9,7 +9,6 @@ interface nsIBFCacheEntry;
|
|||
interface nsIDocShell;
|
||||
interface nsISHEntry;
|
||||
interface nsISHistoryListener;
|
||||
interface nsISHTransaction;
|
||||
interface nsIURI;
|
||||
|
||||
%{C++
|
||||
|
@ -161,7 +160,7 @@ interface nsISHistory: nsISupports
|
|||
/**
|
||||
* Get the transaction at a particular index. Returns non-null on success.
|
||||
*/
|
||||
nsISHTransaction GetTransactionAtIndex(in int32_t aIndex);
|
||||
nsISHEntry GetTransactionAtIndex(in int32_t aIndex);
|
||||
|
||||
/**
|
||||
* Sets the toplevel docshell object to which this SHistory object belongs to.
|
||||
|
|
|
@ -1,44 +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 "nsSHTransaction.h"
|
||||
#include "nsISHEntry.h"
|
||||
|
||||
nsSHTransaction::nsSHTransaction(nsISHEntry* aSHEntry)
|
||||
: mSHEntry(aSHEntry)
|
||||
{
|
||||
MOZ_ASSERT(aSHEntry);
|
||||
}
|
||||
|
||||
nsSHTransaction::~nsSHTransaction()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsSHTransaction)
|
||||
NS_IMPL_RELEASE(nsSHTransaction)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsSHTransaction)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHTransaction)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::GetSHEntry(nsISHEntry** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mSHEntry;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHTransaction::SetSHEntry(nsISHEntry* aSHEntry)
|
||||
{
|
||||
MOZ_ASSERT(aSHEntry);
|
||||
mSHEntry = aSHEntry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -1,30 +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 nsSHTransaction_h
|
||||
#define nsSHTransaction_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISHTransaction.h"
|
||||
|
||||
class nsISHEntry;
|
||||
|
||||
class nsSHTransaction : public nsISHTransaction
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHTRANSACTION
|
||||
|
||||
explicit nsSHTransaction(nsISHEntry* aSHEntry);
|
||||
|
||||
protected:
|
||||
virtual ~nsSHTransaction();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISHEntry> mSHEntry; // never null
|
||||
};
|
||||
|
||||
#endif /* nsSHTransaction_h */
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsIObserverService.h"
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsISHistoryListener.h"
|
||||
#include "nsSHTransaction.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -185,26 +184,24 @@ nsSHistoryObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
namespace {
|
||||
|
||||
already_AddRefed<nsIContentViewer>
|
||||
GetContentViewerForTransaction(nsISHTransaction* aTrans)
|
||||
GetContentViewerForTransaction(nsISHEntry* aTrans)
|
||||
{
|
||||
nsCOMPtr<nsISHEntry> entry = aTrans->GetSHEntry();
|
||||
nsCOMPtr<nsISHEntry> ownerEntry;
|
||||
nsCOMPtr<nsIContentViewer> viewer;
|
||||
entry->GetAnyContentViewer(getter_AddRefs(ownerEntry),
|
||||
getter_AddRefs(viewer));
|
||||
aTrans->GetAnyContentViewer(getter_AddRefs(ownerEntry),
|
||||
getter_AddRefs(viewer));
|
||||
return viewer.forget();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
nsSHistory::EvictContentViewerForTransaction(nsISHTransaction* aTrans)
|
||||
nsSHistory::EvictContentViewerForTransaction(nsISHEntry* aTrans)
|
||||
{
|
||||
nsCOMPtr<nsISHEntry> entry = aTrans->GetSHEntry();
|
||||
nsCOMPtr<nsIContentViewer> viewer;
|
||||
nsCOMPtr<nsISHEntry> ownerEntry;
|
||||
entry->GetAnyContentViewer(getter_AddRefs(ownerEntry),
|
||||
getter_AddRefs(viewer));
|
||||
aTrans->GetAnyContentViewer(getter_AddRefs(ownerEntry),
|
||||
getter_AddRefs(viewer));
|
||||
if (viewer) {
|
||||
NS_ASSERTION(ownerEntry, "Content viewer exists but its SHEntry is null");
|
||||
|
||||
|
@ -222,9 +219,9 @@ nsSHistory::EvictContentViewerForTransaction(nsISHTransaction* aTrans)
|
|||
|
||||
// When dropping bfcache, we have to remove associated dynamic entries as well.
|
||||
int32_t index = -1;
|
||||
GetIndexOfEntry(entry, &index);
|
||||
GetIndexOfEntry(aTrans, &index);
|
||||
if (index != -1) {
|
||||
RemoveDynEntries(index, entry);
|
||||
RemoveDynEntries(index, aTrans);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,7 +607,7 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISHTransaction> currentTxn;
|
||||
nsCOMPtr<nsISHEntry> currentTxn;
|
||||
if (mIndex >= 0) {
|
||||
nsresult rv = GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -625,14 +622,11 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist)
|
|||
aSHEntry->SetDocshellID(&docshellID);
|
||||
}
|
||||
|
||||
if (currentTxn) {
|
||||
nsCOMPtr<nsISHEntry> entry = currentTxn->GetSHEntry();
|
||||
if (!entry->GetPersist()) {
|
||||
NOTIFY_LISTENERS(OnHistoryReplaceEntry, (mIndex));
|
||||
currentTxn->SetSHEntry(aSHEntry);
|
||||
aSHEntry->SetPersist(aPersist);
|
||||
return NS_OK;
|
||||
}
|
||||
if (currentTxn && !currentTxn->GetPersist()) {
|
||||
NOTIFY_LISTENERS(OnHistoryReplaceEntry, (mIndex));
|
||||
aSHEntry->SetPersist(aPersist);
|
||||
mTransactions[mIndex] = aSHEntry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -642,10 +636,9 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist)
|
|||
// Remove all transactions after the current one, add the new one, and set
|
||||
// the new one as the current one.
|
||||
MOZ_ASSERT(mIndex >= -1);
|
||||
nsCOMPtr<nsISHTransaction> txn = new nsSHTransaction(aSHEntry);
|
||||
aSHEntry->SetPersist(aPersist);
|
||||
mTransactions.TruncateLength(mIndex + 1);
|
||||
mTransactions.AppendElement(txn);
|
||||
mTransactions.AppendElement(aSHEntry);
|
||||
mIndex++;
|
||||
|
||||
NOTIFY_LISTENERS(OnLengthChanged, (Length()));
|
||||
|
@ -692,13 +685,10 @@ nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex,
|
|||
nsISHEntry** aResult)
|
||||
{
|
||||
// GetTransactionAtIndex validates aIndex.
|
||||
nsCOMPtr<nsISHTransaction> txn;
|
||||
nsresult rv = GetTransactionAtIndex(aIndex, getter_AddRefs(txn));
|
||||
nsCOMPtr<nsISHEntry> txn;
|
||||
nsresult rv = GetTransactionAtIndex(aIndex, aResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get the entry from the transaction.
|
||||
txn->GetSHEntry(aResult);
|
||||
|
||||
// Set mIndex to the requested index, if asked to do so..
|
||||
if (aModifyIndex) {
|
||||
mIndex = aIndex;
|
||||
|
@ -710,7 +700,7 @@ nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex,
|
|||
|
||||
/* Get the transaction at a given index */
|
||||
NS_IMETHODIMP
|
||||
nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction** aResult)
|
||||
nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHEntry** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
|
@ -732,8 +722,7 @@ nsSHistory::GetIndexOfEntry(nsISHEntry* aSHEntry, int32_t* aResult)
|
|||
*aResult = -1;
|
||||
|
||||
for (int32_t i = 0; i < Length(); i++) {
|
||||
nsCOMPtr<nsISHEntry> entry = mTransactions[i]->GetSHEntry();
|
||||
if (aSHEntry == entry) {
|
||||
if (aSHEntry == mTransactions[i]) {
|
||||
*aResult = i;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -747,8 +736,7 @@ nsresult
|
|||
nsSHistory::PrintHistory()
|
||||
{
|
||||
for (int32_t i = 0; i < Length(); i++) {
|
||||
nsCOMPtr<nsISHTransaction> txn = mTransactions[i];
|
||||
nsCOMPtr<nsISHEntry> entry = txn->GetSHEntry();
|
||||
nsCOMPtr<nsISHEntry> entry = mTransactions[i];
|
||||
nsCOMPtr<nsILayoutHistoryState> layoutHistoryState;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsString title;
|
||||
|
@ -879,6 +867,10 @@ nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry* aReplaceEntry)
|
|||
{
|
||||
NS_ENSURE_ARG(aReplaceEntry);
|
||||
|
||||
if (aIndex < 0 || aIndex >= Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISHistory> shistoryOfEntry;
|
||||
aReplaceEntry->GetSHistory(getter_AddRefs(shistoryOfEntry));
|
||||
if (shistoryOfEntry && shistoryOfEntry != this) {
|
||||
|
@ -888,17 +880,12 @@ nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry* aReplaceEntry)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISHTransaction> currentTxn;
|
||||
nsresult rv = GetTransactionAtIndex(aIndex, getter_AddRefs(currentTxn));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aReplaceEntry->SetSHistory(this);
|
||||
|
||||
NOTIFY_LISTENERS(OnHistoryReplaceEntry, (aIndex));
|
||||
|
||||
// Set the replacement entry in the transaction
|
||||
currentTxn->SetSHEntry(aReplaceEntry);
|
||||
aReplaceEntry->SetPersist(true);
|
||||
mTransactions[aIndex] = aReplaceEntry;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1050,7 +1037,7 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex)
|
|||
// (It's important that the condition checks Length(), rather than a cached
|
||||
// copy of Length(), because the length might change between iterations.)
|
||||
for (int32_t i = 0; i < Length(); i++) {
|
||||
nsCOMPtr<nsISHTransaction> trans = mTransactions[i];
|
||||
nsCOMPtr<nsISHEntry> trans = mTransactions[i];
|
||||
nsCOMPtr<nsIContentViewer> viewer = GetContentViewerForTransaction(trans);
|
||||
if (safeViewers.IndexOf(viewer) == -1) {
|
||||
EvictContentViewerForTransaction(trans);
|
||||
|
@ -1063,7 +1050,7 @@ namespace {
|
|||
class TransactionAndDistance
|
||||
{
|
||||
public:
|
||||
TransactionAndDistance(nsSHistory* aSHistory, nsISHTransaction* aTrans, uint32_t aDist)
|
||||
TransactionAndDistance(nsSHistory* aSHistory, nsISHEntry* aTrans, uint32_t aDist)
|
||||
: mSHistory(aSHistory)
|
||||
, mTransaction(aTrans)
|
||||
, mLastTouched(0)
|
||||
|
@ -1072,8 +1059,7 @@ public:
|
|||
mViewer = GetContentViewerForTransaction(aTrans);
|
||||
NS_ASSERTION(mViewer, "Transaction should have a content viewer");
|
||||
|
||||
nsCOMPtr<nsISHEntry> shentry = mTransaction->GetSHEntry();
|
||||
shentry->GetLastTouched(&mLastTouched);
|
||||
mTransaction->GetLastTouched(&mLastTouched);
|
||||
}
|
||||
|
||||
bool operator<(const TransactionAndDistance& aOther) const
|
||||
|
@ -1096,7 +1082,7 @@ public:
|
|||
}
|
||||
|
||||
RefPtr<nsSHistory> mSHistory;
|
||||
nsCOMPtr<nsISHTransaction> mTransaction;
|
||||
nsCOMPtr<nsISHEntry> mTransaction;
|
||||
nsCOMPtr<nsIContentViewer> mViewer;
|
||||
uint32_t mLastTouched;
|
||||
int32_t mDistance;
|
||||
|
@ -1137,7 +1123,7 @@ nsSHistory::GloballyEvictContentViewers()
|
|||
int32_t startIndex, endIndex;
|
||||
shist->WindowIndices(shist->mIndex, &startIndex, &endIndex);
|
||||
for (int32_t i = startIndex; i <= endIndex; i++) {
|
||||
nsCOMPtr<nsISHTransaction> trans = shist->mTransactions[i];
|
||||
nsCOMPtr<nsISHEntry> trans = shist->mTransactions[i];
|
||||
nsCOMPtr<nsIContentViewer> contentViewer =
|
||||
GetContentViewerForTransaction(trans);
|
||||
|
||||
|
@ -1193,7 +1179,7 @@ nsSHistory::GloballyEvictContentViewers()
|
|||
|
||||
nsresult
|
||||
nsSHistory::FindTransactionForBFCache(nsIBFCacheEntry* aEntry,
|
||||
nsISHTransaction** aResult,
|
||||
nsISHEntry** aResult,
|
||||
int32_t* aResultIndex)
|
||||
{
|
||||
*aResult = nullptr;
|
||||
|
@ -1203,11 +1189,10 @@ nsSHistory::FindTransactionForBFCache(nsIBFCacheEntry* aEntry,
|
|||
WindowIndices(mIndex, &startIndex, &endIndex);
|
||||
|
||||
for (int32_t i = startIndex; i <= endIndex; ++i) {
|
||||
nsCOMPtr<nsISHTransaction> trans = mTransactions[i];
|
||||
nsCOMPtr<nsISHEntry> entry = trans->GetSHEntry();
|
||||
nsCOMPtr<nsISHEntry> trans = mTransactions[i];
|
||||
|
||||
// Does entry have the same BFCacheEntry as the argument to this method?
|
||||
if (entry->HasBFCacheEntry(aEntry)) {
|
||||
if (trans->HasBFCacheEntry(aEntry)) {
|
||||
trans.forget(aResult);
|
||||
*aResultIndex = i;
|
||||
return NS_OK;
|
||||
|
@ -1220,7 +1205,7 @@ nsresult
|
|||
nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry* aEntry)
|
||||
{
|
||||
int32_t index;
|
||||
nsCOMPtr<nsISHTransaction> trans;
|
||||
nsCOMPtr<nsISHEntry> trans;
|
||||
FindTransactionForBFCache(aEntry, getter_AddRefs(trans), &index);
|
||||
|
||||
if (index == mIndex) {
|
||||
|
@ -1463,11 +1448,10 @@ void
|
|||
nsSHistory::RemoveDynEntriesForBFCacheEntry(nsIBFCacheEntry* aEntry)
|
||||
{
|
||||
int32_t index;
|
||||
nsCOMPtr<nsISHTransaction> trans;
|
||||
nsCOMPtr<nsISHEntry> trans;
|
||||
FindTransactionForBFCache(aEntry, getter_AddRefs(trans), &index);
|
||||
if (trans) {
|
||||
nsCOMPtr<nsISHEntry> entry = trans->GetSHEntry();
|
||||
RemoveDynEntries(index, entry);
|
||||
RemoveDynEntries(index, trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ class nsIDocShell;
|
|||
class nsDocShell;
|
||||
class nsSHistoryObserver;
|
||||
class nsISHEntry;
|
||||
class nsISHTransaction;
|
||||
|
||||
class nsSHistory final : public mozilla::LinkedListElement<nsSHistory>,
|
||||
public nsISHistory,
|
||||
|
@ -147,13 +146,13 @@ private:
|
|||
// Find the transaction for a given bfcache entry. It only looks up between
|
||||
// the range where alive viewers may exist (i.e nsISHistory::VIEWER_WINDOW).
|
||||
nsresult FindTransactionForBFCache(nsIBFCacheEntry* aEntry,
|
||||
nsISHTransaction** aResult,
|
||||
nsISHEntry** aResult,
|
||||
int32_t* aResultIndex);
|
||||
|
||||
// Evict content viewers in this window which don't lie in the "safe" range
|
||||
// around aIndex.
|
||||
void EvictOutOfRangeWindowContentViewers(int32_t aIndex);
|
||||
void EvictContentViewerForTransaction(nsISHTransaction* aTrans);
|
||||
void EvictContentViewerForTransaction(nsISHEntry* aTrans);
|
||||
static void GloballyEvictContentViewers();
|
||||
static void GloballyEvictAllContentViewers();
|
||||
|
||||
|
@ -172,7 +171,7 @@ private:
|
|||
// Track all bfcache entries and evict on expiration.
|
||||
mozilla::UniquePtr<HistoryTracker> mHistoryTracker;
|
||||
|
||||
nsTArray<nsCOMPtr<nsISHTransaction>> mTransactions; // entries are never null
|
||||
nsTArray<nsCOMPtr<nsISHEntry>> mTransactions; // entries are never null
|
||||
int32_t mIndex; // -1 means "no index"
|
||||
int32_t mRequestedIndex; // -1 means "no requested index"
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ var SessionHistoryInternal = {
|
|||
skippedCount++;
|
||||
continue;
|
||||
}
|
||||
let entry = this.serializeEntry(txn.sHEntry);
|
||||
let entry = this.serializeEntry(txn);
|
||||
data.entries.push(entry);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче