Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: components/history/core/browser/expire_history_backend.cc

Issue 2903573002: [Thumbnails DB] Add functionality to clear unused on-demand favicons. (Closed)
Patch Set: Implementation variants + unit-tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/expire_history_backend.cc
diff --git a/components/history/core/browser/expire_history_backend.cc b/components/history/core/browser/expire_history_backend.cc
index d57a60432afb85c3f74790c13d50d8e7865dd7b9..481af20408b231942de7fd6caec9dd6002063e6f 100644
--- a/components/history/core/browser/expire_history_backend.cc
+++ b/components/history/core/browser/expire_history_backend.cc
@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
+#include "base/feature_list.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/location.h"
@@ -114,6 +115,10 @@ const int kExpirationDelaySec = 30;
// iteration, so we want to wait longer before checking to avoid wasting CPU.
const int kExpirationEmptyDelayMin = 5;
+// Feature that enables clearing old on-demand favicons.
+const base::Feature kClearOldOnDemandFavicons{
+ "ClearOldOnDemandFavicons", base::FEATURE_DISABLED_BY_DEFAULT};
+
} // namespace
@@ -300,6 +305,19 @@ void ExpireHistoryBackend::StartExpiringOldStuff(
// Initialize the queue with all tasks for the first set of iterations.
InitWorkQueue();
ScheduleExpire();
+
+ // Remove favicons that are not bound to visits.
+ if (!base::FeatureList::IsEnabled(kClearOldOnDemandFavicons))
+ return;
+ task_runner_->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ExpireHistoryBackend::ClearOldOnDemandFavicons,
+ weak_factory_.GetWeakPtr()),
+ base::TimeDelta::FromSeconds(kExpirationDelaySec));
+}
+
+void ExpireHistoryBackend::ClearOldOnDemandFavicons() {
+ thumb_db_->ClearOldOnDemandFavicons(GetCurrentExpirationTime());
}
void ExpireHistoryBackend::DeleteFaviconsIfPossible(DeleteEffects* effects) {
« no previous file with comments | « components/history/core/browser/expire_history_backend.h ('k') | components/history/core/browser/thumbnail_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698