nsSHEntryShared.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsSHEntryShared_h__
  6. #define nsSHEntryShared_h__
  7. #include "nsCOMPtr.h"
  8. #include "nsAutoPtr.h"
  9. #include "nsCOMArray.h"
  10. #include "nsIBFCacheEntry.h"
  11. #include "nsIMutationObserver.h"
  12. #include "nsISHEntry.h"
  13. #include "nsExpirationTracker.h"
  14. #include "nsRect.h"
  15. #include "nsString.h"
  16. #include "mozilla/Attributes.h"
  17. class nsSHEntry;
  18. class nsISHEntry;
  19. class nsIDocument;
  20. class nsIContentViewer;
  21. class nsIDocShellTreeItem;
  22. class nsILayoutHistoryState;
  23. class nsDocShellEditorData;
  24. class nsIMutableArray;
  25. // A document may have multiple SHEntries, either due to hash navigations or
  26. // calls to history.pushState. SHEntries corresponding to the same document
  27. // share many members; in particular, they share state related to the
  28. // back/forward cache.
  29. //
  30. // nsSHEntryShared is the vehicle for this sharing.
  31. class nsSHEntryShared final
  32. : public nsIBFCacheEntry
  33. , public nsIMutationObserver
  34. {
  35. public:
  36. static void EnsureHistoryTracker();
  37. static void Shutdown();
  38. nsSHEntryShared();
  39. NS_DECL_ISUPPORTS
  40. NS_DECL_NSIMUTATIONOBSERVER
  41. NS_DECL_NSIBFCACHEENTRY
  42. nsExpirationState *GetExpirationState() { return &mExpirationState; }
  43. private:
  44. ~nsSHEntryShared();
  45. friend class nsSHEntry;
  46. friend class HistoryTracker;
  47. static already_AddRefed<nsSHEntryShared> Duplicate(nsSHEntryShared* aEntry);
  48. void RemoveFromExpirationTracker();
  49. void Expire();
  50. nsresult SyncPresentationState();
  51. void DropPresentationState();
  52. nsresult SetContentViewer(nsIContentViewer* aViewer);
  53. // See nsISHEntry.idl for an explanation of these members.
  54. // These members are copied by nsSHEntryShared::Duplicate(). If you add a
  55. // member here, be sure to update the Duplicate() implementation.
  56. uint64_t mDocShellID;
  57. nsCOMArray<nsIDocShellTreeItem> mChildShells;
  58. nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
  59. nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
  60. nsCString mContentType;
  61. bool mIsFrameNavigation;
  62. bool mSaveLayoutState;
  63. bool mSticky;
  64. bool mDynamicallyCreated;
  65. nsCOMPtr<nsISupports> mCacheKey;
  66. uint32_t mLastTouched;
  67. // These members aren't copied by nsSHEntryShared::Duplicate() because
  68. // they're specific to a particular content viewer.
  69. uint64_t mID;
  70. nsCOMPtr<nsIContentViewer> mContentViewer;
  71. nsCOMPtr<nsIDocument> mDocument;
  72. nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
  73. bool mExpired;
  74. nsCOMPtr<nsISupports> mWindowState;
  75. nsIntRect mViewerBounds;
  76. nsCOMPtr<nsIMutableArray> mRefreshURIList;
  77. nsExpirationState mExpirationState;
  78. nsAutoPtr<nsDocShellEditorData> mEditorData;
  79. };
  80. #endif