Back to index

lightning-sunbird  0.9+nobinonly
nsSHistory.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Radha Kulkarni <radha@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef nsSHistory_h
00041 #define nsSHistory_h
00042 
00043 // Helper Classes
00044 #include "nsCOMPtr.h"
00045 
00046 //Interfaces Needed
00047 #include "nsISHistory.h"
00048 #include "nsISHistoryInternal.h"
00049 #include "nsISHTransaction.h"
00050 #include "nsIWebNavigation.h"
00051 #include "nsIWeakReference.h"
00052 #include "nsISimpleEnumerator.h"
00053 #include "nsISHistoryListener.h"
00054 #include "nsIHistoryEntry.h"
00055 #include "nsIObserver.h"
00056 
00057 // Needed to maintain global list of all SHistory objects
00058 #include "prclist.h"
00059 
00060 class nsIDocShell;
00061 class nsSHEnumerator;
00062 class nsSHistoryObserver;
00063 class nsSHistory: public PRCList,
00064                   public nsISHistory,
00065                   public nsISHistoryInternal,
00066                   public nsIWebNavigation
00067 {
00068 public:
00069        nsSHistory();
00070 
00071   NS_DECL_ISUPPORTS
00072   NS_DECL_NSISHISTORY
00073   NS_DECL_NSISHISTORYINTERNAL
00074   NS_DECL_NSIWEBNAVIGATION
00075 
00076   // One time initialization method called upon docshell module construction
00077   static nsresult Startup();
00078 
00079   // Calculates a max number of total
00080   // content viewers to cache, based on amount of total memory
00081   static PRUint32 GetMaxTotalViewers();
00082 
00083 protected:
00084   virtual ~nsSHistory();
00085   friend class nsSHEnumerator;
00086   friend class nsSHistoryObserver;
00087 
00088    // Could become part of nsIWebNavigation
00089    NS_IMETHOD GetEntryAtIndex(PRInt32 aIndex, PRBool aModifyIndex, nsISHEntry** aResult);
00090    NS_IMETHOD GetTransactionAtIndex(PRInt32 aIndex, nsISHTransaction ** aResult);
00091    nsresult CompareFrames(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell, long aLoadType, PRBool * aIsFrameFound);
00092    nsresult InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long aLoadType);
00093 
00094    NS_IMETHOD LoadEntry(PRInt32 aIndex, long aLoadType, PRUint32 histCmd);
00095        
00096 #ifdef DEBUG
00097    nsresult PrintHistory();
00098 #endif
00099 
00100   void EvictWindowContentViewers(PRInt32 aFromIndex, PRInt32 aToIndex);
00101   static void EvictGlobalContentViewer();
00102   static void EvictAllContentViewers();
00103 
00104 protected:
00105   nsCOMPtr<nsISHTransaction> mListRoot;
00106   PRInt32 mIndex;
00107   PRInt32 mLength;
00108   PRInt32 mRequestedIndex;
00109   // Session History listener
00110   nsWeakPtr mListener;
00111   // Weak reference. Do not refcount this.
00112   nsIDocShell *  mRootDocShell;
00113 
00114   // Max viewers allowed total, across all SHistory objects
00115   static PRInt32  sHistoryMaxTotalViewers;
00116 };
00117 //*****************************************************************************
00118 //***    nsSHEnumerator: Object Management
00119 //*****************************************************************************
00120 class nsSHEnumerator : public nsISimpleEnumerator
00121 {
00122 public:
00123 
00124   NS_DECL_ISUPPORTS
00125   NS_DECL_NSISIMPLEENUMERATOR
00126 
00127   nsSHEnumerator(nsSHistory *  aHistory);
00128   
00129 protected:
00130   friend class nsSHistory;
00131   virtual ~nsSHEnumerator();
00132 private:
00133   PRInt32     mIndex;
00134   nsSHistory *  mSHistory;  
00135 };
00136 
00137 #endif   /* nsSHistory */