2015-05-08 14:37:00 +03:00
|
|
|
/* -*- 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
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2005-08-18 15:15:08 +04:00
|
|
|
|
|
|
|
#ifndef nsSHistory_h
|
|
|
|
#define nsSHistory_h
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2005-08-18 15:15:33 +04:00
|
|
|
#include "nsISHistory.h"
|
2005-08-18 15:16:01 +04:00
|
|
|
#include "nsISHistoryInternal.h"
|
2005-08-18 15:15:34 +04:00
|
|
|
#include "nsIWebNavigation.h"
|
2005-08-18 15:16:01 +04:00
|
|
|
#include "nsISimpleEnumerator.h"
|
2012-09-20 18:41:18 +04:00
|
|
|
#include "nsTObserverArray.h"
|
2013-09-04 19:26:20 +04:00
|
|
|
#include "nsWeakPtr.h"
|
2005-09-23 22:16:40 +04:00
|
|
|
|
|
|
|
#include "prclist.h"
|
2005-08-18 15:15:08 +04:00
|
|
|
|
2005-08-18 15:15:34 +04:00
|
|
|
class nsIDocShell;
|
2005-08-18 15:16:01 +04:00
|
|
|
class nsSHEnumerator;
|
2005-09-30 00:24:27 +04:00
|
|
|
class nsSHistoryObserver;
|
2013-09-04 19:26:20 +04:00
|
|
|
class nsISHEntry;
|
|
|
|
class nsISHTransaction;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsSHistory final : public PRCList,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsISHistory,
|
|
|
|
public nsISHistoryInternal,
|
|
|
|
public nsIWebNavigation
|
2005-08-18 15:15:08 +04:00
|
|
|
{
|
|
|
|
public:
|
2009-09-01 20:45:05 +04:00
|
|
|
nsSHistory();
|
2005-08-18 15:16:01 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISHISTORY
|
|
|
|
NS_DECL_NSISHISTORYINTERNAL
|
|
|
|
NS_DECL_NSIWEBNAVIGATION
|
2005-08-18 15:15:08 +04:00
|
|
|
|
2005-09-23 22:16:40 +04:00
|
|
|
// One time initialization method called upon docshell module construction
|
|
|
|
static nsresult Startup();
|
2011-06-25 05:55:46 +04:00
|
|
|
static void Shutdown();
|
|
|
|
static void UpdatePrefs();
|
2005-09-23 22:16:40 +04:00
|
|
|
|
2005-10-02 00:38:47 +04:00
|
|
|
// Max number of total cached content viewers. If the pref
|
|
|
|
// browser.sessionhistory.max_total_viewers is negative, then
|
|
|
|
// this value is calculated based on the total amount of memory.
|
|
|
|
// Otherwise, it comes straight from the pref.
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t GetMaxTotalViewers() { return sHistoryMaxTotalViewers; }
|
2005-08-18 15:15:59 +04:00
|
|
|
|
2005-08-18 15:15:33 +04:00
|
|
|
protected:
|
2005-08-18 15:16:01 +04:00
|
|
|
virtual ~nsSHistory();
|
|
|
|
friend class nsSHEnumerator;
|
2005-09-30 00:24:27 +04:00
|
|
|
friend class nsSHistoryObserver;
|
2005-08-18 15:15:59 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
// Could become part of nsIWebNavigation
|
|
|
|
NS_IMETHOD GetTransactionAtIndex(int32_t aIndex, nsISHTransaction** aResult);
|
2016-10-20 12:33:22 +03:00
|
|
|
nsresult LoadDifferingEntries(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry,
|
|
|
|
nsIDocShell* aRootDocShell, long aLoadType,
|
|
|
|
bool& aDifferenceFound);
|
2015-05-06 20:57:23 +03:00
|
|
|
nsresult InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
|
|
|
|
long aLoadType);
|
2005-08-18 15:16:33 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHOD LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd);
|
2009-09-01 20:45:05 +04:00
|
|
|
|
2005-08-18 15:16:52 +04:00
|
|
|
#ifdef DEBUG
|
2015-05-06 20:57:23 +03:00
|
|
|
nsresult PrintHistory();
|
2005-08-18 15:16:52 +04:00
|
|
|
#endif
|
|
|
|
|
2011-10-21 19:26:34 +04:00
|
|
|
// Evict content viewers in this window which don't lie in the "safe" range
|
|
|
|
// around aIndex.
|
2012-08-22 19:56:38 +04:00
|
|
|
void EvictOutOfRangeWindowContentViewers(int32_t aIndex);
|
2011-10-21 19:26:34 +04:00
|
|
|
static void GloballyEvictContentViewers();
|
|
|
|
static void GloballyEvictAllContentViewers();
|
2005-08-18 15:17:00 +04:00
|
|
|
|
2005-10-02 00:38:47 +04:00
|
|
|
// Calculates a max number of total
|
|
|
|
// content viewers to cache, based on amount of total memory
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t CalcMaxTotalViewers();
|
2005-10-02 00:38:47 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void RemoveDynEntries(int32_t aOldIndex, int32_t aNewIndex);
|
2010-08-17 18:13:55 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
|
|
|
|
uint32_t aHistCmd);
|
|
|
|
|
2005-08-18 15:15:08 +04:00
|
|
|
protected:
|
2010-11-15 13:11:51 +03:00
|
|
|
// aIndex is the index of the transaction which may be removed.
|
2011-10-17 18:59:28 +04:00
|
|
|
// If aKeepNext is true, aIndex is compared to aIndex + 1,
|
2010-11-15 13:11:51 +03:00
|
|
|
// otherwise comparison is done to aIndex - 1.
|
2012-08-22 19:56:38 +04:00
|
|
|
bool RemoveDuplicate(int32_t aIndex, bool aKeepNext);
|
2010-09-05 22:10:35 +04:00
|
|
|
|
2005-08-18 15:15:59 +04:00
|
|
|
nsCOMPtr<nsISHTransaction> mListRoot;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mIndex;
|
|
|
|
int32_t mLength;
|
|
|
|
int32_t mRequestedIndex;
|
2012-09-20 18:41:18 +04:00
|
|
|
// Session History listeners
|
|
|
|
nsAutoTObserverArray<nsWeakPtr, 2> mListeners;
|
2005-08-18 15:15:59 +04:00
|
|
|
// Weak reference. Do not refcount this.
|
2015-05-06 20:57:23 +03:00
|
|
|
nsIDocShell* mRootDocShell;
|
2005-09-23 22:16:40 +04:00
|
|
|
|
|
|
|
// Max viewers allowed total, across all SHistory objects
|
2015-05-06 20:57:23 +03:00
|
|
|
static int32_t sHistoryMaxTotalViewers;
|
2005-08-18 15:15:08 +04:00
|
|
|
};
|
2015-05-06 20:57:23 +03:00
|
|
|
|
2005-08-18 15:16:01 +04:00
|
|
|
class nsSHEnumerator : public nsISimpleEnumerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISIMPLEENUMERATOR
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
explicit nsSHEnumerator(nsSHistory* aHistory);
|
|
|
|
|
2005-08-18 15:16:01 +04:00
|
|
|
protected:
|
|
|
|
friend class nsSHistory;
|
|
|
|
virtual ~nsSHEnumerator();
|
2015-05-06 20:57:23 +03:00
|
|
|
|
2005-08-18 15:16:01 +04:00
|
|
|
private:
|
2015-05-06 20:57:23 +03:00
|
|
|
int32_t mIndex;
|
|
|
|
nsSHistory* mSHistory;
|
2005-08-18 15:16:01 +04:00
|
|
|
};
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
#endif /* nsSHistory */
|