diff --git a/mozilla/docshell/base/Makefile.in b/mozilla/docshell/base/Makefile.in index 36bafffcc8f..521264486d5 100644 --- a/mozilla/docshell/base/Makefile.in +++ b/mozilla/docshell/base/Makefile.in @@ -132,3 +132,5 @@ CPPSRCS = \ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk + +LOCAL_INCLUDES += -I$(srcdir)/../shistory/src diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index ebfcfa8cf13..98e8416ddfb 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -101,6 +101,7 @@ #include "nsDocShellLoadInfo.h" #include "nsCDefaultURIFixup.h" #include "nsDocShellEnumerator.h" +#include "nsSHistory.h" // Helper Classes #include "nsDOMError.h" @@ -4964,15 +4965,8 @@ nsDocShell::CanSavePresentation(PRUint32 aLoadType, // Avoid doing the work of saving the presentation state in the case where // the content viewer cache is disabled. - nsCOMPtr rootSH; - GetRootSessionHistory(getter_AddRefs(rootSH)); - if (rootSH) { - nsCOMPtr shistInt(do_QueryInterface(rootSH)); - PRInt32 maxViewers; - shistInt->GetHistoryMaxTotalViewers(&maxViewers); - if (maxViewers == 0) + if (nsSHistory::GetMaxTotalViewers() == 0) return PR_FALSE; - } // Don't cache the content viewer if we're in a subframe and the subframe // pref is disabled. diff --git a/mozilla/docshell/shistory/public/nsISHistoryInternal.idl b/mozilla/docshell/shistory/public/nsISHistoryInternal.idl index 1c46b1d910d..1dfd5961c6b 100644 --- a/mozilla/docshell/shistory/public/nsISHistoryInternal.idl +++ b/mozilla/docshell/shistory/public/nsISHistoryInternal.idl @@ -51,7 +51,7 @@ interface nsIDocShell; #define NS_SHISTORY_INTERNAL_CONTRACTID "@mozilla.org/browser/shistory-internal;1" %} -[scriptable, uuid(494fac3c-64f4-41b8-b209-b4ada899613b)] +[scriptable, uuid(df8788d6-c0ed-4517-b47e-c719afc94284)] interface nsISHistoryInternal: nsISupports { /** @@ -98,12 +98,4 @@ interface nsISHistoryInternal: nsISupports * the previous viewer. */ void evictContentViewers(in long previousIndex, in long index); - - /** - * 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. - */ - readonly attribute long historyMaxTotalViewers; }; diff --git a/mozilla/docshell/shistory/src/nsSHistory.cpp b/mozilla/docshell/shistory/src/nsSHistory.cpp index 7d0de15f6bf..9b536b9f2d3 100644 --- a/mozilla/docshell/shistory/src/nsSHistory.cpp +++ b/mozilla/docshell/shistory/src/nsSHistory.cpp @@ -112,7 +112,7 @@ nsSHistoryObserver::Observe(nsISupports *aSubject, const char *aTopic, prefs->GetIntPref(PREF_SHISTORY_MAX_TOTAL_VIEWERS, &nsSHistory::sHistoryMaxTotalViewers); if (nsSHistory::sHistoryMaxTotalViewers < 0) { - nsSHistory::sHistoryMaxTotalViewers = nsSHistory::GetMaxTotalViewers(); + nsSHistory::sHistoryMaxTotalViewers = nsSHistory::CalcMaxTotalViewers(); } nsSHistory::EvictGlobalContentViewer(); @@ -158,16 +158,9 @@ NS_INTERFACE_MAP_END // nsSHistory: nsISHistory //***************************************************************************** -NS_IMETHODIMP -nsSHistory::GetHistoryMaxTotalViewers(PRInt32 *max) -{ - *max = sHistoryMaxTotalViewers; - return NS_OK; -} - // static PRUint32 -nsSHistory::GetMaxTotalViewers() +nsSHistory::CalcMaxTotalViewers() { // Calculate an estimate of how many ContentViewers we should cache based // on RAM. This assumes that the average ContentViewer is 4MB (conservative) @@ -262,7 +255,7 @@ nsSHistory::Startup() // If the pref is negative, that means we calculate how many viewers // we think we should cache, based on total memory if (sHistoryMaxTotalViewers < 0) { - sHistoryMaxTotalViewers = GetMaxTotalViewers(); + sHistoryMaxTotalViewers = CalcMaxTotalViewers(); } // Initialize the global list of all SHistory objects diff --git a/mozilla/docshell/shistory/src/nsSHistory.h b/mozilla/docshell/shistory/src/nsSHistory.h index d28fe7e5478..4bd252eb84c 100644 --- a/mozilla/docshell/shistory/src/nsSHistory.h +++ b/mozilla/docshell/shistory/src/nsSHistory.h @@ -76,9 +76,11 @@ public: // One time initialization method called upon docshell module construction static nsresult Startup(); - // Calculates a max number of total - // content viewers to cache, based on amount of total memory - static PRUint32 GetMaxTotalViewers(); + // 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. + static PRUint32 GetMaxTotalViewers() { return sHistoryMaxTotalViewers; } protected: virtual ~nsSHistory(); @@ -101,6 +103,10 @@ protected: static void EvictGlobalContentViewer(); static void EvictAllContentViewers(); + // Calculates a max number of total + // content viewers to cache, based on amount of total memory + static PRUint32 CalcMaxTotalViewers(); + protected: nsCOMPtr mListRoot; PRInt32 mIndex;