Index: components/favicon/core/favicon_service.h |
diff --git a/components/favicon/core/favicon_service.h b/components/favicon/core/favicon_service.h |
index d36180093497dc83e2031acae57945ebdfbb56be..60552b13691d278c63fc51c0096a29b147cbfb1d 100644 |
--- a/components/favicon/core/favicon_service.h |
+++ b/components/favicon/core/favicon_service.h |
@@ -139,6 +139,15 @@ class FaviconService : public KeyedService { |
// Marks all types of favicon for the page as being out of date. |
virtual void SetFaviconOutOfDateForPage(const GURL& page_url) = 0; |
+ // Mark that the on-demand favicon at |icon_url| was requested now. This |
+ // postpones the automatic eviction of the favicon from the database. Not all |
+ // calls end up in a write into the DB: |
+ // - It is no-op if the bitmaps are not stored using SetOnDemandFavicons(). |
+ // - The updates of the "last requested time" have limited frequency for each |
+ // particular favicon (e.g. once per week). This limits the overhead of |
+ // cache management for on-demand favicons. |
+ virtual void TouchOnDemandFavicon(const GURL& icon_url) = 0; |
+ |
// Allows the importer to set many favicons for many pages at once. The pages |
// must exist, any favicon sets for unknown pages will be discarded. Existing |
// favicons will not be overwritten. |
@@ -171,19 +180,29 @@ class FaviconService : public KeyedService { |
favicon_base::IconType icon_type, |
const gfx::Image& image) = 0; |
- // Same as SetFavicons() with three differences: |
+ // Same as SetFavicons with three differences: |
// 1) It will be a no-op if there is an existing cached favicon for *any* type |
// for |page_url|. |
// 2) If |icon_url| is known to the database, |bitmaps| will be ignored (i.e. |
// the icon won't be overwritten) but the mappings from |page_url| to |
// |icon_url| will be stored (conditioned to point 1 above). |
- // 3) If |icon_url| is stored, it will be marked as expired. |
+ // 3) If |icon_url| is stored, it will be marked as "on-demand". |
+ // |
+ // On-demand favicons are those that are fetched without visiting their page. |
+ // For this reason, their life-time cannot be bound to the life-time of the |
+ // corresponding visit in history. |
+ // - These bitmaps are evicted from the database based on the last time they |
+ // get requested. The last requested time is initially set to Now() and is |
+ // further updated by calling TouchOnDemandFavicon(). |
+ // - Furthermore, on-demand bitmaps are immediately marked as expired. Hence, |
+ // they are always replaced by standard favicons whenever their page gets |
+ // visited. |
// The callback will receive whether the write actually happened. |
- virtual void SetLastResortFavicons(const GURL& page_url, |
- const GURL& icon_url, |
- favicon_base::IconType icon_type, |
- const gfx::Image& image, |
- base::Callback<void(bool)> callback) = 0; |
+ virtual void SetOnDemandFavicons(const GURL& page_url, |
+ const GURL& icon_url, |
+ favicon_base::IconType icon_type, |
+ const gfx::Image& image, |
+ base::Callback<void(bool)> callback) = 0; |
// Avoid repeated requests to download missing favicon. |
virtual void UnableToDownloadFavicon(const GURL& icon_url) = 0; |