зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1102975 - Add a pref to control the content viewer expiration time in bfcache, r=khuey
--HG-- extra : rebase_source : 6fb403cdb1b73fa8e1f61945ddfd3bfe8e75a92d
This commit is contained in:
Родитель
02d26f50a3
Коммит
3324f67238
|
@ -99,6 +99,7 @@ pref("network.predictor.preserve", 50); // percentage of predictor data to keep
|
|||
/* session history */
|
||||
pref("browser.sessionhistory.max_total_viewers", 1);
|
||||
pref("browser.sessionhistory.max_entries", 50);
|
||||
pref("browser.sessionhistory.contentViewerTimeout", 360);
|
||||
|
||||
/* session store */
|
||||
pref("browser.sessionstore.resume_session_once", false);
|
||||
|
|
|
@ -53,7 +53,6 @@ Initialize()
|
|||
nsresult rv = nsSHistory::Startup();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsSHEntryShared::Startup();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
namespace dom = mozilla::dom;
|
||||
|
@ -26,16 +27,15 @@ uint64_t gSHEntrySharedID = 0;
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// Hardcode this to time out unused content viewers after 30 minutes
|
||||
// XXX jlebar shouldn't this be a pref?
|
||||
#define CONTENT_VIEWER_TIMEOUT_SECONDS (30*60)
|
||||
#define CONTENT_VIEWER_TIMEOUT_SECONDS "browser.sessionhistory.contentViewerTimeout"
|
||||
// Default this to time out unused content viewers after 30 minutes
|
||||
#define CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT (30*60)
|
||||
|
||||
typedef nsExpirationTracker<nsSHEntryShared, 3> HistoryTrackerBase;
|
||||
class HistoryTracker MOZ_FINAL : public HistoryTrackerBase {
|
||||
public:
|
||||
// Expire cached contentviewers after 20-30 minutes in the cache.
|
||||
HistoryTracker()
|
||||
: HistoryTrackerBase(1000 * CONTENT_VIEWER_TIMEOUT_SECONDS / 2)
|
||||
HistoryTracker(uint32_t aTimeout)
|
||||
: HistoryTrackerBase(1000 * aTimeout / 2)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,15 @@ protected:
|
|||
static HistoryTracker *gHistoryTracker = nullptr;
|
||||
|
||||
void
|
||||
nsSHEntryShared::Startup()
|
||||
nsSHEntryShared::EnsureHistoryTracker()
|
||||
{
|
||||
gHistoryTracker = new HistoryTracker();
|
||||
if (!gHistoryTracker) {
|
||||
// nsExpirationTracker doesn't allow one to change the timer period,
|
||||
// so just set it once when the history tracker is used for the first time.
|
||||
gHistoryTracker = new HistoryTracker(
|
||||
mozilla::Preferences::GetUint(CONTENT_VIEWER_TIMEOUT_SECONDS,
|
||||
CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -79,6 +85,7 @@ nsSHEntryShared::~nsSHEntryShared()
|
|||
RemoveFromExpirationTracker();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (gHistoryTracker) {
|
||||
// Check that we're not still on track to expire. We shouldn't be, because
|
||||
// we just removed ourselves!
|
||||
nsExpirationTracker<nsSHEntryShared, 3>::Iterator
|
||||
|
@ -88,6 +95,7 @@ nsSHEntryShared::~nsSHEntryShared()
|
|||
while ((elem = iterator.Next()) != nullptr) {
|
||||
NS_ASSERTION(elem != this, "Found dead entry still in the tracker!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mContentViewer) {
|
||||
|
@ -118,7 +126,7 @@ nsSHEntryShared::Duplicate(nsSHEntryShared *aEntry)
|
|||
|
||||
void nsSHEntryShared::RemoveFromExpirationTracker()
|
||||
{
|
||||
if (GetExpirationState()->IsTracked()) {
|
||||
if (gHistoryTracker && GetExpirationState()->IsTracked()) {
|
||||
gHistoryTracker->RemoveObject(this);
|
||||
}
|
||||
}
|
||||
|
@ -201,6 +209,7 @@ nsSHEntryShared::SetContentViewer(nsIContentViewer *aViewer)
|
|||
mContentViewer = aViewer;
|
||||
|
||||
if (mContentViewer) {
|
||||
EnsureHistoryTracker();
|
||||
gHistoryTracker->AddObject(this);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
|
|
|
@ -34,7 +34,7 @@ class nsSHEntryShared MOZ_FINAL : public nsIBFCacheEntry,
|
|||
public nsIMutationObserver
|
||||
{
|
||||
public:
|
||||
static void Startup();
|
||||
static void EnsureHistoryTracker();
|
||||
static void Shutdown();
|
||||
|
||||
nsSHEntryShared();
|
||||
|
|
|
@ -114,6 +114,7 @@ pref("browser.display.remotetabs.timeout", 10);
|
|||
/* session history */
|
||||
pref("browser.sessionhistory.max_total_viewers", 1);
|
||||
pref("browser.sessionhistory.max_entries", 50);
|
||||
pref("browser.sessionhistory.contentViewerTimeout", 360);
|
||||
|
||||
/* session store */
|
||||
pref("browser.sessionstore.resume_session_once", false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче