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..1d5a0870f409d79d76ca3fb7e026d35a118186e3 100644 |
--- a/components/history/core/browser/thumbnail_database.cc |
+++ b/components/history/core/browser/thumbnail_database.cc |
@@ -412,6 +412,32 @@ 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). |
+ // 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_.GetCachedStatement( |
+ SQL_FROM_HERE, |
+ "SELECT favicons.id, favicons.url, icon_mapping.page_url FROM " |
+ "favicons, favicon_bitmaps, icon_mapping WHERE favicon_bitmaps.icon_id = " |
brettw
2017/07/11 19:26:43
Can you express this as an explicit JOIN across th
jkrcal
2017/07/13 20:26:10
Done.
|
+ "icon_mapping.icon_id AND favicons.id = favicon_bitmaps.icon_id AND " |
+ "((last_requested=0 AND last_updated=0) OR " |
brettw
2017/07/11 19:26:43
I like to be explicit about the table names for th
jkrcal
2017/07/13 20:26:10
Done.
|
+ "(last_requested>0 AND last_requested<?));")); |
+ old_icons.BindInt64(0, threshold.ToInternalValue()); |
+ |
+ 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) { |
@@ -778,6 +804,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=?")); |