| 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..93105f8f1637dcffd48b0ad520330dfdb3abd769 100644
|
| --- a/components/history/core/browser/thumbnail_database.cc
|
| +++ b/components/history/core/browser/thumbnail_database.cc
|
| @@ -412,6 +412,33 @@ void ThumbnailDatabase::TrimMemory(bool aggressively) {
|
| db_.TrimMemory(aggressively);
|
| }
|
|
|
| +std::map<favicon_base::FaviconID, FaviconURLs>
|
| +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 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 = "
|
| + "icon_mapping.icon_id AND favicons.id = favicon_bitmaps.icon_id AND "
|
| + "((last_requested=0 AND last_updated=0) OR "
|
| + "(last_requested>0 AND last_requested<?));"));
|
| + old_icons.BindInt64(0, threshold.ToInternalValue());
|
| +
|
| + std::map<favicon_base::FaviconID, FaviconURLs> favicons;
|
| +
|
| + while (old_icons.Step()) {
|
| + favicon_base::FaviconID id = old_icons.ColumnInt64(0);
|
| + favicons[id].icon_url = GURL(old_icons.ColumnString(1));
|
| + favicons[id].page_urls.push_back(GURL(old_icons.ColumnString(2)));
|
| + }
|
| +
|
| + return favicons;
|
| +}
|
| +
|
| bool ThumbnailDatabase::GetFaviconBitmapIDSizes(
|
| favicon_base::FaviconID icon_id,
|
| std::vector<FaviconBitmapIDSize>* bitmap_id_sizes) {
|
| @@ -778,6 +805,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=?"));
|
|
|