OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ |
6 #define COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 std::vector<FaviconBitmap>* favicon_bitmaps); | 80 std::vector<FaviconBitmap>* favicon_bitmaps); |
81 | 81 |
82 // Gets the last updated time, bitmap data, and pixel size of the favicon | 82 // Gets the last updated time, bitmap data, and pixel size of the favicon |
83 // bitmap at |bitmap_id|. Returns true if successful. | 83 // bitmap at |bitmap_id|. Returns true if successful. |
84 bool GetFaviconBitmap(FaviconBitmapID bitmap_id, | 84 bool GetFaviconBitmap(FaviconBitmapID bitmap_id, |
85 base::Time* last_updated, | 85 base::Time* last_updated, |
86 base::Time* last_requested, | 86 base::Time* last_requested, |
87 scoped_refptr<base::RefCountedMemory>* png_icon_data, | 87 scoped_refptr<base::RefCountedMemory>* png_icon_data, |
88 gfx::Size* pixel_size); | 88 gfx::Size* pixel_size); |
89 | 89 |
90 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. | 90 // Adds a bitmap component of |type| at |pixel_size| for the favicon with |
91 // Only favicons representing a .ico file should have multiple favicon bitmaps | 91 // |icon_id|. Only favicons representing a .ico file should have multiple |
92 // per favicon. | 92 // favicon bitmaps per favicon. |
93 // |icon_data| is the png encoded data. | 93 // |icon_data| is the png encoded data. |
94 // The |time| indicates the access time, and is used to detect when the | 94 // The |type| indicates how the lifetime of this icon should be managed. |
95 // favicon should be refreshed. | 95 // The |time| is used for lifetime management of the bitmap (should be Now()). |
96 // |pixel_size| is the pixel dimensions of |icon_data|. | 96 // |pixel_size| is the pixel dimensions of |icon_data|. |
97 // Returns the id of the added bitmap or 0 if unsuccessful. | 97 // Returns the id of the added bitmap or 0 if unsuccessful. |
98 FaviconBitmapID AddFaviconBitmap( | 98 FaviconBitmapID AddFaviconBitmap( |
99 favicon_base::FaviconID icon_id, | 99 favicon_base::FaviconID icon_id, |
100 const scoped_refptr<base::RefCountedMemory>& icon_data, | 100 const scoped_refptr<base::RefCountedMemory>& icon_data, |
101 FaviconBitmapType type, | |
101 base::Time time, | 102 base::Time time, |
102 const gfx::Size& pixel_size); | 103 const gfx::Size& pixel_size); |
103 | 104 |
104 // Sets the bitmap data and the last updated time for the favicon bitmap at | 105 // Sets the bitmap data and the last updated time for the favicon bitmap at |
105 // |bitmap_id|. | 106 // |bitmap_id|. Should not be called for bitmaps of type ON_DEMAND as they |
107 // should never get updated (the call silently changes the type to ON_VISIT). | |
106 // Returns true if successful. | 108 // Returns true if successful. |
107 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, | 109 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, |
108 scoped_refptr<base::RefCountedMemory> bitmap_data, | 110 scoped_refptr<base::RefCountedMemory> bitmap_data, |
109 base::Time time); | 111 base::Time time); |
110 | 112 |
111 // Sets the last updated time for the favicon bitmap at |bitmap_id|. | 113 // Sets the last_updated time for the favicon bitmap at |bitmap_id|. Should |
112 // Returns true if successful. | 114 // not be called for bitmaps of type ON_DEMAND as last_updated time is only |
115 // tracked for ON_VISIT bitmaps (the call silently changes the type to | |
116 // ON_VISIT). Returns true if successful. | |
113 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id, | 117 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id, |
114 base::Time time); | 118 base::Time time); |
115 | 119 |
116 // Sets the last requested time for the favicon bitmap at |bitmap_id|. | |
117 // Returns true if successful. | |
118 bool SetFaviconBitmapLastRequestedTime(FaviconBitmapID bitmap_id, | |
119 base::Time time); | |
120 | |
121 // Deletes the favicon bitmap with |bitmap_id|. | 120 // Deletes the favicon bitmap with |bitmap_id|. |
122 // Returns true if successful. | 121 // Returns true if successful. |
123 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); | 122 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); |
124 | 123 |
125 // Favicons ------------------------------------------------------------------ | 124 // Favicons ------------------------------------------------------------------ |
126 | 125 |
127 // Sets the the favicon as out of date. This will set |last_updated| for all | 126 // Sets the the favicon as out of date. This will set |last_updated| for all |
128 // of the bitmaps for |icon_id| to be out of date. | 127 // of the bitmaps for |icon_id| to be out of date. |
129 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); | 128 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); |
130 | 129 |
130 // Mark all bitmaps of type ON_DEMAND at |icon_url| as requested at |time|. | |
131 // This postpones their automatic eviction from the database. Not all calls | |
132 // end up in a write into the DB: | |
133 // - it is no-op if the bitmaps are not of type ON_DEMAND; | |
134 // - the updates of the last requested time have limited frequency for each | |
pkotwicz
2017/06/07 17:40:53
Nit: Add quotes around 'last requested time'
jkrcal
2017/06/09 16:38:38
Done.
| |
135 // particular bitmap (e.g. once per week). This limits the overhead of | |
136 // cache management for on-demand favicons. | |
137 // Returns true if successful. | |
138 bool TouchOnDemandFavicon(const GURL& icon_url, base::Time time); | |
139 | |
131 // Returns the id of the entry in the favicon database with the specified url | 140 // Returns the id of the entry in the favicon database with the specified url |
132 // and icon type. | 141 // and icon type. |
133 // Returns 0 if no entry exists for the specified url. | 142 // Returns 0 if no entry exists for the specified url. |
134 favicon_base::FaviconID GetFaviconIDForFaviconURL( | 143 favicon_base::FaviconID GetFaviconIDForFaviconURL( |
135 const GURL& icon_url, | 144 const GURL& icon_url, |
136 favicon_base::IconType icon_type); | 145 favicon_base::IconType icon_type); |
137 | 146 |
138 // Gets the icon_url, icon_type and sizes for the specified |icon_id|. | 147 // Gets the icon_url, icon_type and sizes for the specified |icon_id|. |
139 bool GetFaviconHeader(favicon_base::FaviconID icon_id, | 148 bool GetFaviconHeader(favicon_base::FaviconID icon_id, |
140 GURL* icon_url, | 149 GURL* icon_url, |
141 favicon_base::IconType* icon_type); | 150 favicon_base::IconType* icon_type); |
142 | 151 |
143 // Adds favicon with |icon_url|, |icon_type| and |favicon_sizes| to the | 152 // Adds favicon with |icon_url|, |icon_type| and |favicon_sizes| to the |
144 // favicon db, returning its id. | 153 // favicon db, returning its id. |
145 favicon_base::FaviconID AddFavicon(const GURL& icon_url, | 154 favicon_base::FaviconID AddFavicon(const GURL& icon_url, |
146 favicon_base::IconType icon_type); | 155 favicon_base::IconType icon_type); |
147 | 156 |
148 // Adds a favicon with a single bitmap. This call is equivalent to calling | 157 // Adds a favicon with a single bitmap. This call is equivalent to calling |
149 // AddFavicon and AddFaviconBitmap. | 158 // AddFavicon and AddFaviconBitmap (of type FaviconBitmapType::ON_VISIT). |
pkotwicz
2017/06/07 17:40:53
Can you please add the type as a parameter?
jkrcal
2017/06/09 16:38:38
Hm, I wanted to avoid it because it has many call
| |
150 favicon_base::FaviconID AddFavicon( | 159 favicon_base::FaviconID AddFavicon( |
151 const GURL& icon_url, | 160 const GURL& icon_url, |
152 favicon_base::IconType icon_type, | 161 favicon_base::IconType icon_type, |
153 const scoped_refptr<base::RefCountedMemory>& icon_data, | 162 const scoped_refptr<base::RefCountedMemory>& icon_data, |
154 base::Time time, | 163 base::Time time, |
155 const gfx::Size& pixel_size); | 164 const gfx::Size& pixel_size); |
156 | 165 |
157 // Delete the favicon with the provided id. Returns false on failure | 166 // Delete the favicon with the provided id. Returns false on failure |
158 bool DeleteFavicon(favicon_base::FaviconID id); | 167 bool DeleteFavicon(favicon_base::FaviconID id); |
159 | 168 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 | 272 |
264 sql::Connection db_; | 273 sql::Connection db_; |
265 sql::MetaTable meta_table_; | 274 sql::MetaTable meta_table_; |
266 | 275 |
267 HistoryBackendClient* backend_client_; | 276 HistoryBackendClient* backend_client_; |
268 }; | 277 }; |
269 | 278 |
270 } // namespace history | 279 } // namespace history |
271 | 280 |
272 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ | 281 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ |
OLD | NEW |