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

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

Issue 2856873002: [Thumbnails DB] Allow setting last_requested time when accessing favicons. (Closed)
Patch Set: Splitting off clearing Created 3 years, 7 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/history_backend.cc
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index 9c24373f52b4a13f1cdf56c6819052d7168809e2..12bd7b8a133ab667e5e02104e2088500bc197e8e 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -1729,15 +1729,13 @@ void HistoryBackend::SetFavicons(const GURL& page_url,
favicon_base::IconType icon_type,
const GURL& icon_url,
const std::vector<SkBitmap>& bitmaps) {
- SetFaviconsImpl(page_url, icon_type, icon_url, bitmaps,
- /*bitmaps_are_expired=*/false);
+ SetFaviconsImpl(page_url, icon_type, icon_url, bitmaps, /*on_demand=*/false);
}
-bool HistoryBackend::SetLastResortFavicons(
- const GURL& page_url,
- favicon_base::IconType icon_type,
- const GURL& icon_url,
- const std::vector<SkBitmap>& bitmaps) {
+bool HistoryBackend::SetOnDemandFavicons(const GURL& page_url,
+ favicon_base::IconType icon_type,
+ const GURL& icon_url,
+ const std::vector<SkBitmap>& bitmaps) {
if (!thumbnail_db_ || !db_)
return false;
@@ -1748,7 +1746,7 @@ bool HistoryBackend::SetLastResortFavicons(
}
return SetFaviconsImpl(page_url, icon_type, icon_url, bitmaps,
- /*bitmaps_are_expired=*/true);
+ /*on_demand=*/true);
}
void HistoryBackend::SetFaviconsOutOfDateForPage(const GURL& page_url) {
@@ -1765,6 +1763,14 @@ void HistoryBackend::SetFaviconsOutOfDateForPage(const GURL& page_url) {
ScheduleCommit();
}
+void HistoryBackend::TouchOnDemandFavicon(const GURL& icon_url) {
+ if (!thumbnail_db_)
+ return;
+
+ thumbnail_db_->TouchOnDemandFavicon(icon_url, Time::Now());
+ ScheduleCommit();
+}
+
void HistoryBackend::SetImportedFavicons(
const favicon_base::FaviconUsageDataList& favicon_usage) {
if (!db_ || !thumbnail_db_)
@@ -1830,7 +1836,7 @@ bool HistoryBackend::SetFaviconsImpl(const GURL& page_url,
favicon_base::IconType icon_type,
const GURL& icon_url,
const std::vector<SkBitmap>& bitmaps,
- bool bitmaps_are_expired) {
+ bool on_demand) {
if (!thumbnail_db_ || !db_)
return false;
@@ -1846,11 +1852,9 @@ bool HistoryBackend::SetFaviconsImpl(const GURL& page_url,
}
bool favicon_data_modified = false;
- if (favicon_created || !bitmaps_are_expired)
- favicon_data_modified = SetFaviconBitmaps(icon_id, bitmaps);
-
- if (favicon_created && bitmaps_are_expired)
- thumbnail_db_->SetFaviconOutOfDate(icon_id);
jkrcal 2017/05/23 14:18:40 This operation is now performed implicitly in Thum
+ if (favicon_created || !on_demand) {
+ favicon_data_modified = SetFaviconBitmaps(icon_id, bitmaps, on_demand);
+ }
std::vector<favicon_base::FaviconID> icon_ids(1u, icon_id);
bool mapping_changed =
@@ -1904,7 +1908,8 @@ void HistoryBackend::UpdateFaviconMappingsAndFetchImpl(
}
bool HistoryBackend::SetFaviconBitmaps(favicon_base::FaviconID icon_id,
- const std::vector<SkBitmap>& bitmaps) {
+ const std::vector<SkBitmap>& bitmaps,
+ bool on_demand) {
pkotwicz 2017/05/24 15:43:31 Maybe it would be clearer if you passed the |new_l
jkrcal 2017/06/06 15:41:55 This does not work well after merging AddFaviconBi
std::vector<FaviconBitmapIDSize> bitmap_id_sizes;
thumbnail_db_->GetFaviconBitmapIDSizes(icon_id, &bitmap_id_sizes);
@@ -1953,8 +1958,13 @@ bool HistoryBackend::SetFaviconBitmaps(favicon_base::FaviconID icon_id,
}
for (size_t i = 0; i < to_add.size(); ++i) {
- thumbnail_db_->AddFaviconBitmap(icon_id, to_add[i].first, base::Time::Now(),
- to_add[i].second);
+ if (on_demand) {
+ thumbnail_db_->AddOnDemandFaviconBitmap(
+ icon_id, to_add[i].first, base::Time::Now(), to_add[i].second);
+ } else {
+ thumbnail_db_->AddFaviconBitmap(icon_id, to_add[i].first,
+ base::Time::Now(), to_add[i].second);
+ }
favicon_bitmaps_changed = true;
}

Powered by Google App Engine
This is Rietveld 408576698