зеркало из https://github.com/mozilla/pjs.git
Bug 401722 aggressively expire history visits that are not top-level (r=sspitzer)
This commit is contained in:
Родитель
8b13692802
Коммит
9b600acfb4
|
@ -90,6 +90,9 @@ const PRTime EXPIRATION_POLICY_DAYS = ((PRTime)7 * 86400 * PR_USEC_PER_SEC);
|
|||
const PRTime EXPIRATION_POLICY_WEEKS = ((PRTime)30 * 86400 * PR_USEC_PER_SEC);
|
||||
const PRTime EXPIRATION_POLICY_MONTHS = ((PRTime)180 * 86400 * PR_USEC_PER_SEC);
|
||||
|
||||
// Expiration policy for embedded links (bug #401722)
|
||||
const PRTime EMBEDDED_LINK_LIFETIME = ((PRTime)10 * 86400 * PR_USEC_PER_SEC);
|
||||
|
||||
// nsNavHistoryExpire::nsNavHistoryExpire
|
||||
//
|
||||
// Warning: don't do anything with aHistory in the constructor, since
|
||||
|
@ -184,6 +187,13 @@ nsNavHistoryExpire::OnQuit()
|
|||
if (NS_FAILED(rv))
|
||||
NS_WARNING("ExpireForDegenerateRuns failed.");
|
||||
|
||||
// Expire embedded links
|
||||
// NOTE: This must come before ExpireHistoryParanoid, or the moz_places
|
||||
// records won't be immediately deleted.
|
||||
rv = ExpireEmbeddedLinks(connection);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING("ExpireEmbeddedLinks failed.");
|
||||
|
||||
// vacuum up dangling items
|
||||
rv = ExpireHistoryParanoid(connection);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -632,6 +642,29 @@ nsNavHistoryExpire::ExpireAnnotations(mozIStorageConnection* aConnection)
|
|||
}
|
||||
|
||||
|
||||
// nsNavHistoryExpire::ExpireEmbeddedLinks
|
||||
|
||||
nsresult
|
||||
nsNavHistoryExpire::ExpireEmbeddedLinks(mozIStorageConnection* aConnection)
|
||||
{
|
||||
PRTime maxEmbeddedAge = PR_Now() - EMBEDDED_LINK_LIFETIME;
|
||||
nsCOMPtr<mozIStorageStatement> expireEmbeddedLinksStatement;
|
||||
// Note: This query also removes visit_type = 0 entries, for bug #375777.
|
||||
nsresult rv = aConnection->CreateStatement(NS_LITERAL_CSTRING(
|
||||
"DELETE FROM moz_historyvisits WHERE visit_date < ?1 "
|
||||
"AND (visit_type = ?2 OR visit_type = 0)"),
|
||||
getter_AddRefs(expireEmbeddedLinksStatement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = expireEmbeddedLinksStatement->BindInt64Parameter(0, maxEmbeddedAge);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = expireEmbeddedLinksStatement->BindInt32Parameter(1, mHistory->TRANSITION_EMBED);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = expireEmbeddedLinksStatement->Execute();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsNavHistoryExpire::ExpireHistoryParanoid
|
||||
//
|
||||
// Deletes any dangling history entries that aren't associated with any
|
||||
|
|
|
@ -88,6 +88,7 @@ protected:
|
|||
|
||||
nsresult ExpireItems(PRUint32 aNumToExpire, PRBool* aKeepGoing);
|
||||
nsresult ExpireAnnotations(mozIStorageConnection* aConnection);
|
||||
nsresult ExpireEmbeddedLinks(mozIStorageConnection* aConnection);
|
||||
|
||||
// parts of ExpireItems
|
||||
nsresult FindVisits(PRTime aExpireThreshold, PRUint32 aNumToExpire,
|
||||
|
|
Загрузка…
Ссылка в новой задаче