Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsSHistory_h |
michael@0 | 8 | #define nsSHistory_h |
michael@0 | 9 | |
michael@0 | 10 | // Helper Classes |
michael@0 | 11 | #include "nsCOMPtr.h" |
michael@0 | 12 | |
michael@0 | 13 | //Interfaces Needed |
michael@0 | 14 | #include "nsISHistory.h" |
michael@0 | 15 | #include "nsISHistoryInternal.h" |
michael@0 | 16 | #include "nsIWebNavigation.h" |
michael@0 | 17 | #include "nsISimpleEnumerator.h" |
michael@0 | 18 | #include "nsTObserverArray.h" |
michael@0 | 19 | #include "nsWeakPtr.h" |
michael@0 | 20 | |
michael@0 | 21 | // Needed to maintain global list of all SHistory objects |
michael@0 | 22 | #include "prclist.h" |
michael@0 | 23 | |
michael@0 | 24 | class nsIDocShell; |
michael@0 | 25 | class nsSHEnumerator; |
michael@0 | 26 | class nsSHistoryObserver; |
michael@0 | 27 | class nsISHEntry; |
michael@0 | 28 | class nsISHTransaction; |
michael@0 | 29 | |
michael@0 | 30 | class nsSHistory: public PRCList, |
michael@0 | 31 | public nsISHistory, |
michael@0 | 32 | public nsISHistoryInternal, |
michael@0 | 33 | public nsIWebNavigation |
michael@0 | 34 | { |
michael@0 | 35 | public: |
michael@0 | 36 | nsSHistory(); |
michael@0 | 37 | |
michael@0 | 38 | NS_DECL_ISUPPORTS |
michael@0 | 39 | NS_DECL_NSISHISTORY |
michael@0 | 40 | NS_DECL_NSISHISTORYINTERNAL |
michael@0 | 41 | NS_DECL_NSIWEBNAVIGATION |
michael@0 | 42 | |
michael@0 | 43 | // One time initialization method called upon docshell module construction |
michael@0 | 44 | static nsresult Startup(); |
michael@0 | 45 | static void Shutdown(); |
michael@0 | 46 | static void UpdatePrefs(); |
michael@0 | 47 | |
michael@0 | 48 | // Max number of total cached content viewers. If the pref |
michael@0 | 49 | // browser.sessionhistory.max_total_viewers is negative, then |
michael@0 | 50 | // this value is calculated based on the total amount of memory. |
michael@0 | 51 | // Otherwise, it comes straight from the pref. |
michael@0 | 52 | static uint32_t GetMaxTotalViewers() { return sHistoryMaxTotalViewers; } |
michael@0 | 53 | |
michael@0 | 54 | protected: |
michael@0 | 55 | virtual ~nsSHistory(); |
michael@0 | 56 | friend class nsSHEnumerator; |
michael@0 | 57 | friend class nsSHistoryObserver; |
michael@0 | 58 | |
michael@0 | 59 | // Could become part of nsIWebNavigation |
michael@0 | 60 | NS_IMETHOD GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult); |
michael@0 | 61 | nsresult CompareFrames(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell, long aLoadType, bool * aIsFrameFound); |
michael@0 | 62 | nsresult InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long aLoadType); |
michael@0 | 63 | |
michael@0 | 64 | NS_IMETHOD LoadEntry(int32_t aIndex, long aLoadType, uint32_t histCmd); |
michael@0 | 65 | |
michael@0 | 66 | #ifdef DEBUG |
michael@0 | 67 | nsresult PrintHistory(); |
michael@0 | 68 | #endif |
michael@0 | 69 | |
michael@0 | 70 | // Evict content viewers in this window which don't lie in the "safe" range |
michael@0 | 71 | // around aIndex. |
michael@0 | 72 | void EvictOutOfRangeWindowContentViewers(int32_t aIndex); |
michael@0 | 73 | static void GloballyEvictContentViewers(); |
michael@0 | 74 | static void GloballyEvictAllContentViewers(); |
michael@0 | 75 | |
michael@0 | 76 | // Calculates a max number of total |
michael@0 | 77 | // content viewers to cache, based on amount of total memory |
michael@0 | 78 | static uint32_t CalcMaxTotalViewers(); |
michael@0 | 79 | |
michael@0 | 80 | void RemoveDynEntries(int32_t aOldIndex, int32_t aNewIndex); |
michael@0 | 81 | |
michael@0 | 82 | nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType, uint32_t aHistCmd); |
michael@0 | 83 | protected: |
michael@0 | 84 | // aIndex is the index of the transaction which may be removed. |
michael@0 | 85 | // If aKeepNext is true, aIndex is compared to aIndex + 1, |
michael@0 | 86 | // otherwise comparison is done to aIndex - 1. |
michael@0 | 87 | bool RemoveDuplicate(int32_t aIndex, bool aKeepNext); |
michael@0 | 88 | |
michael@0 | 89 | nsCOMPtr<nsISHTransaction> mListRoot; |
michael@0 | 90 | int32_t mIndex; |
michael@0 | 91 | int32_t mLength; |
michael@0 | 92 | int32_t mRequestedIndex; |
michael@0 | 93 | // Session History listeners |
michael@0 | 94 | nsAutoTObserverArray<nsWeakPtr, 2> mListeners; |
michael@0 | 95 | // Weak reference. Do not refcount this. |
michael@0 | 96 | nsIDocShell * mRootDocShell; |
michael@0 | 97 | |
michael@0 | 98 | // Max viewers allowed total, across all SHistory objects |
michael@0 | 99 | static int32_t sHistoryMaxTotalViewers; |
michael@0 | 100 | }; |
michael@0 | 101 | //***************************************************************************** |
michael@0 | 102 | //*** nsSHEnumerator: Object Management |
michael@0 | 103 | //***************************************************************************** |
michael@0 | 104 | class nsSHEnumerator : public nsISimpleEnumerator |
michael@0 | 105 | { |
michael@0 | 106 | public: |
michael@0 | 107 | |
michael@0 | 108 | NS_DECL_ISUPPORTS |
michael@0 | 109 | NS_DECL_NSISIMPLEENUMERATOR |
michael@0 | 110 | |
michael@0 | 111 | nsSHEnumerator(nsSHistory * aHistory); |
michael@0 | 112 | |
michael@0 | 113 | protected: |
michael@0 | 114 | friend class nsSHistory; |
michael@0 | 115 | virtual ~nsSHEnumerator(); |
michael@0 | 116 | private: |
michael@0 | 117 | int32_t mIndex; |
michael@0 | 118 | nsSHistory * mSHistory; |
michael@0 | 119 | }; |
michael@0 | 120 | |
michael@0 | 121 | #endif /* nsSHistory */ |