зеркало из https://github.com/mozilla/gecko-dev.git
Bug 476297 - Switch frecency idle timer to idle-daily observer. r=dietrich
This commit is contained in:
Родитель
5e03da8640
Коммит
13d86d106c
|
@ -332,6 +332,7 @@ const PRInt32 nsNavHistory::kAutoCompleteBehaviorTyped = 1 << 5;
|
|||
static const char* gQuitApplicationMessage = "quit-application";
|
||||
static const char* gXpcomShutdown = "xpcom-shutdown";
|
||||
static const char* gAutoCompleteFeedback = "autocomplete-will-enter-text";
|
||||
static const char* gIdleDaily = "idle-daily";
|
||||
|
||||
// annotation names
|
||||
const char nsNavHistory::kAnnotationPreviousEncoding[] = "history/encoding";
|
||||
|
@ -523,6 +524,7 @@ nsNavHistory::Init()
|
|||
observerService->AddObserver(this, gQuitApplicationMessage, PR_FALSE);
|
||||
observerService->AddObserver(this, gXpcomShutdown, PR_FALSE);
|
||||
observerService->AddObserver(this, gAutoCompleteFeedback, PR_FALSE);
|
||||
observerService->AddObserver(this, gIdleDaily, PR_FALSE);
|
||||
observerService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_FALSE);
|
||||
// In case we've either imported or done a migration from a pre-frecency
|
||||
// build, we will calculate the first cutoff period's frecencies once the rest
|
||||
|
@ -910,9 +912,6 @@ nsNavHistory::InitializeIdleTimer()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 idleTimerTimeout = EXPIRE_IDLE_TIME_IN_MSECS;
|
||||
if (mFrecencyUpdateIdleTime)
|
||||
idleTimerTimeout = PR_MIN(idleTimerTimeout, mFrecencyUpdateIdleTime);
|
||||
|
||||
rv = mIdleTimer->InitWithFuncCallback(IdleTimerCallback, this,
|
||||
idleTimerTimeout,
|
||||
nsITimer::TYPE_REPEATING_SLACK);
|
||||
|
@ -5203,12 +5202,6 @@ nsNavHistory::OnIdle()
|
|||
rv = idleService->GetIdleTime(&idleTime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// If we've been idle for more than mFrecencyUpdateIdleTime
|
||||
// recalculate some frecency values. A value of zero indicates that
|
||||
// frecency recalculation on idle is disabled.
|
||||
if (mFrecencyUpdateIdleTime && idleTime > mFrecencyUpdateIdleTime)
|
||||
(void)RecalculateFrecencies(mNumCalculateFrecencyOnIdle, PR_TRUE);
|
||||
|
||||
// If we've been idle for more than EXPIRE_IDLE_TIME_IN_MSECS
|
||||
// keep the expiration engine chugging along.
|
||||
// Note: This is done prior to a possible vacuum, to optimize space reduction
|
||||
|
@ -5342,6 +5335,7 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
|
|||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
observerService->RemoveObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC);
|
||||
observerService->RemoveObserver(this, gIdleDaily);
|
||||
observerService->RemoveObserver(this, gAutoCompleteFeedback);
|
||||
observerService->RemoveObserver(this, gXpcomShutdown);
|
||||
observerService->RemoveObserver(this, gQuitApplicationMessage);
|
||||
|
@ -5389,6 +5383,11 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
|
|||
oldVisits != mExpireSites)
|
||||
mExpire.OnExpirationChanged();
|
||||
}
|
||||
else if (strcmp(aTopic, gIdleDaily) == 0) {
|
||||
// Recalculate some frecency values (zero time means don't recalculate)
|
||||
if (mFrecencyUpdateIdleTime)
|
||||
(void)RecalculateFrecencies(mNumCalculateFrecencyOnIdle, PR_TRUE);
|
||||
}
|
||||
else if (strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC) == 0) {
|
||||
if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).Equals(aData)) {
|
||||
mInPrivateBrowsing = PR_TRUE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче