Chromium Code Reviews| 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..d452bd5d744595f3d31a216c2b63d984e381be61 100644 |
| --- a/components/history/core/browser/thumbnail_database.cc |
| +++ b/components/history/core/browser/thumbnail_database.cc |
| @@ -412,11 +412,42 @@ void ThumbnailDatabase::TrimMemory(bool aggressively) { |
| db_.TrimMemory(aggressively); |
| } |
| +std::map<favicon_base::FaviconID, IconMappingsForExpiry> |
| +ThumbnailDatabase::GetOldOnDemandFavicons(base::Time threshold) { |
| + // Restrict to on-demand bitmaps (i.e. with last_requested != 0). This is |
| + // called rarely during history expiration cleanup and hence not worth |
| + // caching. |
| + // TODO(jkrcal): In M63, remove the "(last_requested=0 AND last_updated=0)" |
| + // clause which is only transitional - to clean up expired icons (previously, |
| + // on-demand favicons were stored as expired on-visit favicons). |
| + sql::Statement old_icons(db_.GetUniqueStatement( |
| + "SELECT favicons.id, favicons.url, icon_mapping.page_url " |
| + "FROM favicons " |
| + "JOIN favicon_bitmaps ON (favicon_bitmaps.icon_id = favicons.id) " |
| + "JOIN icon_mapping ON (icon_mapping.icon_id = favicon_bitmaps.icon_id) " |
| + "WHERE ((favicon_bitmaps.last_requested = 0 AND " |
| + " favicon_bitmaps.last_updated = 0) OR " |
| + " (favicon_bitmaps.last_requested > 0 AND " |
| + " favicon_bitmaps.last_requested < ?))")); |
| + old_icons.BindInt64(0, threshold.ToInternalValue()); |
|
jkrcal
2017/07/25 13:40:17
I've ignored a presubmit warning to avoid deprecat
|
| + |
| + std::map<favicon_base::FaviconID, IconMappingsForExpiry> icon_mappings; |
| + |
| + while (old_icons.Step()) { |
| + favicon_base::FaviconID id = old_icons.ColumnInt64(0); |
| + icon_mappings[id].icon_url = GURL(old_icons.ColumnString(1)); |
| + icon_mappings[id].page_urls.push_back(GURL(old_icons.ColumnString(2))); |
| + } |
| + |
| + return icon_mappings; |
| +} |
| + |
| bool ThumbnailDatabase::GetFaviconBitmapIDSizes( |
| favicon_base::FaviconID icon_id, |
| std::vector<FaviconBitmapIDSize>* bitmap_id_sizes) { |
| DCHECK(icon_id); |
| - sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
| + sql::Statement statement(db_.GetCachedStatement( |
| + SQL_FROM_HERE, |
| "SELECT id, width, height FROM favicon_bitmaps WHERE icon_id=?")); |
| statement.BindInt64(0, icon_id); |
| @@ -778,6 +809,16 @@ bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) { |
| return statement.Run(); |
| } |
| +bool ThumbnailDatabase::DeleteIconMappingsForFaviconId( |
| + favicon_base::FaviconID id) { |
| + // This is called rarely during history expiration cleanup and hence not |
| + // worth caching. |
| + sql::Statement statement( |
| + db_.GetUniqueStatement("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=?")); |