| 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 CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ | 6 #define CHROME_BROWSER_HISTORY_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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // current thumbnail score and places it in |score| and returns | 140 // current thumbnail score and places it in |score| and returns |
| 141 // true. Returns false otherwise. | 141 // true. Returns false otherwise. |
| 142 bool ThumbnailScoreForId(URLID id, ThumbnailScore* score); | 142 bool ThumbnailScoreForId(URLID id, ThumbnailScore* score); |
| 143 | 143 |
| 144 // Called by the to delete all old thumbnails and make a clean table. | 144 // Called by the to delete all old thumbnails and make a clean table. |
| 145 // Returns true on success. | 145 // Returns true on success. |
| 146 bool RecreateThumbnailTable(); | 146 bool RecreateThumbnailTable(); |
| 147 | 147 |
| 148 // Favicon Bitmaps ----------------------------------------------------------- | 148 // Favicon Bitmaps ----------------------------------------------------------- |
| 149 | 149 |
| 150 // Returns a listing of the favicon bitmap ids and their associated pixel |
| 151 // sizes for the favicon with |icon_id|. Returns true if the listing has at |
| 152 // least one entry. |
| 153 bool GetFaviconBitmapIDSizeListing( |
| 154 FaviconID icon_id, |
| 155 std::vector<FaviconBitmapIDSize>* bitmap_size_listing); |
| 156 |
| 150 // Returns true if there are any matched bitmaps for the given |icon_id|. All | 157 // Returns true if there are any matched bitmaps for the given |icon_id|. All |
| 151 // matched results are returned if |favicon_bitmaps| is not NULL. | 158 // matched results are returned if |favicon_bitmaps| is not NULL. |
| 152 bool GetFaviconBitmaps(FaviconID icon_id, | 159 bool GetFaviconBitmaps(FaviconID icon_id, |
| 153 std::vector<FaviconBitmap>* favicon_bitmaps); | 160 std::vector<FaviconBitmap>* favicon_bitmaps); |
| 154 | 161 |
| 162 // Returns true if there is a favicon bitmap with |bitmap_id|. The bitmap |
| 163 // data is returned in the |favicon_bitmap| output parameter if it is not |
| 164 // NULL. |
| 165 bool GetFaviconBitmap(FaviconBitmapID bitmap_id, |
| 166 FaviconBitmap* favicon_bitmap); |
| 167 |
| 155 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. | 168 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. |
| 156 // Only favicons representing a .ico file should have multiple favicon bitmaps | 169 // Only favicons representing a .ico file should have multiple favicon bitmaps |
| 157 // per favicon. | 170 // per favicon. |
| 158 // |icon_data| is the png encoded data. | 171 // |icon_data| is the png encoded data. |
| 159 // The |time| indicates the access time, and is used to detect when the | 172 // The |time| indicates the access time, and is used to detect when the |
| 160 // favicon should be refreshed. | 173 // favicon should be refreshed. |
| 161 // |pixel_size| is the pixel dimensions of |icon_data|. | 174 // |pixel_size| is the pixel dimensions of |icon_data|. |
| 162 // Returns the id of the added bitmap or 0 if unsuccessful. | 175 // Returns the id of the added bitmap or 0 if unsuccessful. |
| 163 FaviconBitmapID AddFaviconBitmap( | 176 FaviconBitmapID AddFaviconBitmap( |
| 164 FaviconID icon_id, | 177 FaviconID icon_id, |
| 165 scoped_refptr<base::RefCountedMemory> icon_data, | 178 scoped_refptr<base::RefCountedMemory> icon_data, |
| 166 base::Time time, | 179 base::Time time, |
| 167 const gfx::Size& pixel_size); | 180 const gfx::Size& pixel_size); |
| 168 | 181 |
| 169 // Sets the bitmap data and the last updated time for a favicon bitmap | 182 // Sets the bitmap data and the last updated time for the favicon bitmap at |
| 170 // contained by the favicon at |favicon_id|. Returns true if successful. | 183 // |bitmap_id|. Returns true if successful. |
| 171 // TODO(pkotwicz): Use FaviconBitmapID instead. | 184 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, |
| 172 bool SetFaviconBitmap(FaviconID favicon_id, | |
| 173 scoped_refptr<base::RefCountedMemory> icon_data, | 185 scoped_refptr<base::RefCountedMemory> icon_data, |
| 174 base::Time time); | 186 base::Time time); |
| 175 | 187 |
| 188 // Deletes the favicon bitmap with |bitmap_id|. Returns true if successful. |
| 189 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); |
| 190 |
| 176 // Favicons ------------------------------------------------------------------ | 191 // Favicons ------------------------------------------------------------------ |
| 177 | 192 |
| 178 // Updates the sizes associated with a favicon to |sizes|. See the comment | 193 // Updates the sizes associated with a favicon to |sizes|. See the comment |
| 179 // at the top of the file for the format of the |sizes| parameter. | 194 // at the top of the file for the format of the |sizes| parameter. |
| 180 bool SetFaviconSizes(FaviconID icon_id, const std::string& sizes); | 195 bool SetFaviconSizes(FaviconID icon_id, const std::string& sizes); |
| 181 | 196 |
| 182 // Sets the the favicon as out of date. This will set |last_updated| for all | 197 // Sets the the favicon as out of date. This will set |last_updated| for all |
| 183 // of the bitmaps for |icon_id| to be out of date. | 198 // of the favicon bitmaps for |icon_id| to be out of date. |
| 184 bool SetFaviconOutOfDate(FaviconID icon_id); | 199 bool SetFaviconOutOfDate(FaviconID icon_id); |
| 185 | 200 |
| 186 // Returns the id of the entry in the favicon database with the specified url | 201 // Returns the id of the entry in the favicon database with the specified url |
| 187 // and icon type. If |required_icon_type| contains multiple icon types and | 202 // and icon type. If |required_icon_type| contains multiple icon types and |
| 188 // there are more than one matched icon in database, only one icon will be | 203 // there are more than one matched icon in database, only one icon will be |
| 189 // returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and | 204 // returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and |
| 190 // FAVICON, and the icon type is returned in icon_type parameter if it is not | 205 // FAVICON. |
| 191 // NULL. | |
| 192 // Returns 0 if no entry exists for the specified url. | 206 // Returns 0 if no entry exists for the specified url. |
| 193 FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, | 207 FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, |
| 194 int required_icon_type, | 208 int required_icon_type); |
| 195 IconType* icon_type); | |
| 196 | 209 |
| 197 // Gets the png encoded favicon, last updated time, icon_url and icon_type for | |
| 198 // the specified favicon id. | |
| 199 // TODO(pkotwicz): Remove this function. | |
| 200 bool GetFavicon(FaviconID icon_id, | |
| 201 base::Time* last_updated, | |
| 202 scoped_refptr<base::RefCountedMemory>* png_icon_data, | |
| 203 GURL* icon_url, | |
| 204 IconType* icon_type); | |
| 205 | 210 |
| 206 // Gets the icon_url, icon_type and sizes for the specified |icon_id|. | 211 // Gets the icon_url, icon_type and sizes for the specified |icon_id|. |
| 207 bool GetFaviconHeader(FaviconID icon_id, | 212 bool GetFaviconHeader(FaviconID icon_id, |
| 208 GURL* icon_url, | 213 GURL* icon_url, |
| 209 IconType* icon_type, | 214 IconType* icon_type, |
| 210 std::string* sizes); | 215 std::string* sizes); |
| 211 | 216 |
| 212 // Adds the favicon URL and icon type to the favicon db, returning its id. | 217 // Adds favicon with |icon_url| and |icon_type| to the favicon db, returning |
| 218 // its id. |
| 213 FaviconID AddFavicon(const GURL& icon_url, IconType icon_type); | 219 FaviconID AddFavicon(const GURL& icon_url, IconType icon_type); |
| 214 | 220 |
| 215 // Adds a favicon with a single bitmap. This call is equivalent to calling | 221 // Adds a favicon with a single bitmap. This call is equivalent to calling |
| 216 // AddFavicon, SetFaviconSizes, and AddFaviconBitmap. | 222 // AddFavicon, SetFaviconSizes, and AddFaviconBitmap. |
| 217 FaviconID AddFavicon(const GURL& icon_url, | 223 FaviconID AddFavicon(const GURL& icon_url, |
| 218 IconType icon_type, | 224 IconType icon_type, |
| 219 const std::string& sizes, | 225 const std::string& sizes, |
| 220 scoped_refptr<base::RefCountedMemory> icon_data, | 226 scoped_refptr<base::RefCountedMemory> icon_data, |
| 221 base::Time time, | 227 base::Time time, |
| 222 const gfx::Size& pixel_size); | 228 const gfx::Size& pixel_size); |
| 223 | 229 |
| 224 // Delete the favicon with the provided id. Returns false on failure | 230 // Delete the favicon with the provided id. Returns false on failure |
| 225 bool DeleteFavicon(FaviconID id); | 231 bool DeleteFavicon(FaviconID id); |
| 226 | 232 |
| 227 // Icon Mapping -------------------------------------------------------------- | 233 // Icon Mapping -------------------------------------------------------------- |
| 228 // | 234 // |
| 229 // Returns true if there is a matched icon mapping for the given page and | 235 // Returns true if there is a matched icon mapping for the given page and |
| 230 // icon type. | 236 // icon type. |
| 231 // The matched icon mapping is returned in the icon_mapping parameter if it is | 237 // The matched icon mapping is returned in the icon_mapping parameter if it is |
| 232 // not NULL. | 238 // not NULL. |
| 233 bool GetIconMappingForPageURL(const GURL& page_url, | 239 |
| 234 IconType required_icon_type, | 240 // Returns true if there are icon mappings for the given page and icon type. |
| 235 IconMapping* icon_mapping); | 241 // If |required_icon_types| contains multiple icon types and there is more |
| 242 // than one matched icon type in the database, icons of only a single type |
| 243 // will be returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, |
| 244 // and FAVICON. |
| 245 // The matched icon mappings are returned in the |icon_mappings| parameter if |
| 246 // it is not NULL. |
| 247 bool GetIconMappingsForPageURL(const GURL& page_url, |
| 248 int required_icon_types, |
| 249 std::vector<IconMapping>* mapping_data); |
| 236 | 250 |
| 237 // Returns true if there is any matched icon mapping for the given page. | 251 // Returns true if there is any matched icon mapping for the given page. |
| 238 // All matched icon mappings are returned in descent order of IconType if | 252 // All matched icon mappings are returned in descent order of IconType if |
| 239 // mapping_data is not NULL. | 253 // mapping_data is not NULL. |
| 240 bool GetIconMappingsForPageURL(const GURL& page_url, | 254 bool GetIconMappingsForPageURL(const GURL& page_url, |
| 241 std::vector<IconMapping>* mapping_data); | 255 std::vector<IconMapping>* mapping_data); |
| 242 | 256 |
| 243 // Adds a mapping between the given page_url and icon_id. | 257 // Adds a mapping between the given page_url and icon_id. |
| 244 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. | 258 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. |
| 245 IconMappingID AddIconMapping(const GURL& page_url, FaviconID icon_id); | 259 IconMappingID AddIconMapping(const GURL& page_url, FaviconID icon_id); |
| 246 | 260 |
| 247 // Updates the page and icon mapping for the given mapping_id with the given | 261 // Updates the page and icon mapping for the given mapping_id with the given |
| 248 // icon_id. | 262 // icon_id. |
| 249 // Returns true if the update succeeded. | 263 // Returns true if the update succeeded. |
| 250 bool UpdateIconMapping(IconMappingID mapping_id, FaviconID icon_id); | 264 bool UpdateIconMapping(IconMappingID mapping_id, FaviconID icon_id); |
| 251 | 265 |
| 252 // Deletes the icon mapping entries for the given page url. | 266 // Deletes the icon mapping entries for the given page url. |
| 253 // Returns true if the deletion succeeded. | 267 // Returns true if the deletion succeeded. |
| 254 bool DeleteIconMappings(const GURL& page_url); | 268 bool DeleteIconMappings(const GURL& page_url); |
| 255 | 269 |
| 270 // Deletes the icon mapping with |mapping_id|. |
| 271 // Returns true if the deletion succeeded. |
| 272 bool DeleteIconMapping(IconMappingID mapping_id); |
| 273 |
| 256 // Checks whether a favicon is used by any URLs in the database. | 274 // Checks whether a favicon is used by any URLs in the database. |
| 257 bool HasMappingFor(FaviconID id); | 275 bool HasMappingFor(FaviconID id); |
| 258 | 276 |
| 259 // Clones the existing mappings from |old_page_url| if |new_page_url| has no | 277 // Clones the existing mappings from |old_page_url| if |new_page_url| has no |
| 260 // mappings. Otherwise, will leave mappings alone. | 278 // mappings. Otherwise, will leave mappings alone. |
| 261 bool CloneIconMapping(const GURL& old_page_url, const GURL& new_page_url); | 279 bool CloneIconMapping(const GURL& old_page_url, const GURL& new_page_url); |
| 262 | 280 |
| 263 // The class to enumerate icon mappings. Use InitIconMappingEnumerator to | 281 // The class to enumerate icon mappings. Use InitIconMappingEnumerator to |
| 264 // initialize. | 282 // initialize. |
| 265 class IconMappingEnumerator { | 283 class IconMappingEnumerator { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 const HistoryPublisher* history_publisher_; | 430 const HistoryPublisher* history_publisher_; |
| 413 | 431 |
| 414 // True if migration to TopSites has been done and the thumbnails | 432 // True if migration to TopSites has been done and the thumbnails |
| 415 // table should not be used. | 433 // table should not be used. |
| 416 bool use_top_sites_; | 434 bool use_top_sites_; |
| 417 }; | 435 }; |
| 418 | 436 |
| 419 } // namespace history | 437 } // namespace history |
| 420 | 438 |
| 421 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ | 439 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ |
| OLD | NEW |