| Index: components/history/core/browser/thumbnail_database.cc
|
| diff --git a/components/history/core/browser/thumbnail_database.cc b/components/history/core/browser/thumbnail_database.cc
|
| index c8b430f4f71d8dd70f0111995c5ce74297cec7d9..1415b037f45f4295a175d30e06ef98435941f630 100644
|
| --- a/components/history/core/browser/thumbnail_database.cc
|
| +++ b/components/history/core/browser/thumbnail_database.cc
|
| @@ -412,6 +412,31 @@ void ThumbnailDatabase::TrimMemory(bool aggressively) {
|
| db_.TrimMemory(aggressively);
|
| }
|
|
|
| +std::vector<std::pair<favicon_base::FaviconID, GURL>>
|
| +ThumbnailDatabase::GetOldOnDemandFavicons(base::Time threshold) {
|
| + // Select all bitmaps (and their page URLs) that have not been accessed for a
|
| + // while. Restrict to on-demand bitmaps (i.e. with last_requested != 0).
|
| + // TODO(jkrcal): In M63, remove the "(last_requested=0 AND last_updated=0)"
|
| + // clause which is only transitional - to clean up on demand favicons stored
|
| + // before this function has been implemented.
|
| + sql::Statement delete_candidates(db_.GetCachedStatement(
|
| + SQL_FROM_HERE,
|
| + "SELECT favicon_bitmaps.icon_id, icon_mapping.page_url FROM "
|
| + "favicon_bitmaps, icon_mapping WHERE favicon_bitmaps.icon_id = "
|
| + "icon_mapping.icon_id AND ((last_requested=0 AND last_updated=0) OR "
|
| + "(last_requested>0 AND last_requested<?));"));
|
| + delete_candidates.BindInt64(0, threshold.ToInternalValue());
|
| +
|
| + std::vector<std::pair<favicon_base::FaviconID, GURL>> favicons;
|
| +
|
| + while (delete_candidates.Step()) {
|
| + favicons.push_back(std::make_pair(delete_candidates.ColumnInt64(0),
|
| + GURL(delete_candidates.ColumnString(1))));
|
| + }
|
| +
|
| + return favicons;
|
| +}
|
| +
|
| bool ThumbnailDatabase::GetFaviconBitmapIDSizes(
|
| favicon_base::FaviconID icon_id,
|
| std::vector<FaviconBitmapIDSize>* bitmap_id_sizes) {
|
| @@ -778,6 +803,14 @@ bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) {
|
| return statement.Run();
|
| }
|
|
|
| +bool ThumbnailDatabase::DeleteIconMappingsForFaviconId(
|
| + favicon_base::FaviconID id) {
|
| + sql::Statement statement(db_.GetCachedStatement(
|
| + SQL_FROM_HERE, "DELETE FROM icon_mapping WHERE icon_id=?"));
|
| + statement.BindInt64(0, id);
|
| + return statement.Run();
|
| +}
|
| +
|
| bool ThumbnailDatabase::DeleteIconMapping(IconMappingID mapping_id) {
|
| sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
|
| "DELETE FROM icon_mapping WHERE id=?"));
|
|
|