1 : /* ***** BEGIN LICENSE BLOCK *****
2 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 : *
4 : * The contents of this file are subject to the Mozilla Public License Version
5 : * 1.1 (the "License"); you may not use this file except in compliance with
6 : * the License. You may obtain a copy of the License at
7 : * http://www.mozilla.org/MPL/
8 : *
9 : * Software distributed under the License is distributed on an "AS IS" basis,
10 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : * for the specific language governing rights and limitations under the
12 : * License.
13 : *
14 : * The Original Code is Mozilla.org code.
15 : *
16 : * The Initial Developer of the Original Code is the Mozilla Foundation.
17 : *
18 : * Portions created by the Initial Developer are Copyright (C) 2011
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Justin Lebar <justin.lebar@gmail.com>
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef nsSHEntryShared_h__
39 : #define nsSHEntryShared_h__
40 :
41 : #include "nsCOMPtr.h"
42 : #include "nsAutoPtr.h"
43 : #include "nsCOMArray.h"
44 : #include "nsIBFCacheEntry.h"
45 : #include "nsIMutationObserver.h"
46 : #include "nsExpirationTracker.h"
47 : #include "nsRect.h"
48 : #include "nsString.h"
49 :
50 : class nsSHEntry;
51 : class nsISHEntry;
52 : class nsIDocument;
53 : class nsIContentViewer;
54 : class nsIDocShellTreeItem;
55 : class nsILayoutHistoryState;
56 : class nsISupportsArray;
57 : class nsDocShellEditorData;
58 :
59 : // A document may have multiple SHEntries, either due to hash navigations or
60 : // calls to history.pushState. SHEntries corresponding to the same document
61 : // share many members; in particular, they share state related to the
62 : // back/forward cache.
63 : //
64 : // nsSHEntryShared is the vehicle for this sharing.
65 : class nsSHEntryShared : public nsIBFCacheEntry,
66 : public nsIMutationObserver
67 : {
68 : public:
69 : static void Startup();
70 : static void Shutdown();
71 :
72 : nsSHEntryShared();
73 : ~nsSHEntryShared();
74 :
75 : NS_DECL_ISUPPORTS
76 : NS_DECL_NSIMUTATIONOBSERVER
77 : NS_DECL_NSIBFCACHEENTRY
78 :
79 : private:
80 : friend class nsSHEntry;
81 :
82 : friend class HistoryTracker;
83 : friend class nsExpirationTracker<nsSHEntryShared, 3>;
84 0 : nsExpirationState *GetExpirationState() { return &mExpirationState; }
85 :
86 : static already_AddRefed<nsSHEntryShared> Duplicate(nsSHEntryShared *aEntry);
87 :
88 : void RemoveFromExpirationTracker();
89 : void Expire();
90 : nsresult SyncPresentationState();
91 : void DropPresentationState();
92 :
93 : nsresult SetContentViewer(nsIContentViewer *aViewer);
94 :
95 : // See nsISHEntry.idl for an explanation of these members.
96 :
97 : // These members are copied by nsSHEntryShared::Duplicate(). If you add a
98 : // member here, be sure to update the Duplicate() implementation.
99 : PRUint64 mDocShellID;
100 : nsCOMArray<nsIDocShellTreeItem> mChildShells;
101 : nsCOMPtr<nsISupports> mOwner;
102 : nsCString mContentType;
103 : bool mIsFrameNavigation;
104 : bool mSaveLayoutState;
105 : bool mSticky;
106 : bool mDynamicallyCreated;
107 : nsCOMPtr<nsISupports> mCacheKey;
108 : PRUint32 mLastTouched;
109 :
110 : // These members aren't copied by nsSHEntryShared::Duplicate() because
111 : // they're specific to a particular content viewer.
112 : PRUint64 mID;
113 : nsCOMPtr<nsIContentViewer> mContentViewer;
114 : nsCOMPtr<nsIDocument> mDocument;
115 : nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
116 : bool mExpired;
117 : nsCOMPtr<nsISupports> mWindowState;
118 : nsIntRect mViewerBounds;
119 : nsCOMPtr<nsISupportsArray> mRefreshURIList;
120 : nsExpirationState mExpirationState;
121 : nsAutoPtr<nsDocShellEditorData> mEditorData;
122 : };
123 :
124 : #endif
|