Chromium Code Reviews| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 // current thumbnail score and places it in |score| and returns | 92 // current thumbnail score and places it in |score| and returns |
| 93 // true. Returns false otherwise. | 93 // true. Returns false otherwise. |
| 94 bool ThumbnailScoreForId(URLID id, ThumbnailScore* score); | 94 bool ThumbnailScoreForId(URLID id, ThumbnailScore* score); |
| 95 | 95 |
| 96 // Called by the to delete all old thumbnails and make a clean table. | 96 // Called by the to delete all old thumbnails and make a clean table. |
| 97 // Returns true on success. | 97 // Returns true on success. |
| 98 bool RecreateThumbnailTable(); | 98 bool RecreateThumbnailTable(); |
| 99 | 99 |
| 100 // Favicon Bitmaps ----------------------------------------------------------- | 100 // Favicon Bitmaps ----------------------------------------------------------- |
| 101 | 101 |
| 102 // Returns a listing of the favicon bitmap ids and their associated pixel | |
| 103 // sizes for the favicon with |icon_id|. Returns true if the listing has at | |
| 104 // least one entry. | |
| 105 bool GetFaviconBitmapIDSizeListing( | |
|
sky
2012/08/21 20:16:56
GetFaviconBitmapIDSizes
| |
| 106 FaviconID icon_id, | |
| 107 std::vector<FaviconBitmapIDSize>* bitmap_size_listing); | |
| 108 | |
| 102 // Returns true if there are any matched bitmaps for the given |icon_id|. All | 109 // Returns true if there are any matched bitmaps for the given |icon_id|. All |
| 103 // matched results are returned if |favicon_bitmaps| is not NULL. | 110 // matched results are returned if |favicon_bitmaps| is not NULL. |
| 104 bool GetFaviconBitmaps(FaviconID icon_id, | 111 bool GetFaviconBitmaps(FaviconID icon_id, |
| 105 std::vector<FaviconBitmap>* favicon_bitmaps); | 112 std::vector<FaviconBitmap>* favicon_bitmaps); |
| 106 | 113 |
| 114 // Sets the bitmap data and the last updated time for the favicon bitmap at | |
| 115 // |bitmap_id|. Returns true if successful. | |
| 116 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, | |
| 117 scoped_refptr<base::RefCountedMemory> icon_data, | |
| 118 base::Time time); | |
| 119 | |
| 107 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. | 120 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. |
| 108 // Only favicons representing a .ico file should have multiple favicon bitmaps | 121 // Only favicons representing a .ico file should have multiple favicon bitmaps |
| 109 // per favicon. | 122 // per favicon. |
| 110 // |icon_data| is the png encoded data. | 123 // |icon_data| is the png encoded data. |
| 111 // The |time| indicates the access time, and is used to detect when the | 124 // The |time| indicates the access time, and is used to detect when the |
| 112 // favicon should be refreshed. | 125 // favicon should be refreshed. |
| 113 // |pixel_size| is the pixel dimensions of |icon_data|. | 126 // |pixel_size| is the pixel dimensions of |icon_data|. |
| 114 // Returns the id of the added bitmap or 0 if unsuccessful. | 127 // Returns the id of the added bitmap or 0 if unsuccessful. |
| 115 FaviconBitmapID AddFaviconBitmap( | 128 FaviconBitmapID AddFaviconBitmap( |
| 116 FaviconID icon_id, | 129 FaviconID icon_id, |
| 117 const scoped_refptr<base::RefCountedMemory>& icon_data, | 130 const scoped_refptr<base::RefCountedMemory>& icon_data, |
| 118 base::Time time, | 131 base::Time time, |
| 119 const gfx::Size& pixel_size); | 132 const gfx::Size& pixel_size); |
| 120 | 133 |
| 121 // Deletes the favicon bitmaps for the favicon with with |icon_id|. | 134 // Deletes the favicon bitmap with |bitmap_id|. Returns true if successful. |
| 122 // Returns true if successful. | 135 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); |
| 123 bool DeleteFaviconBitmapsForFavicon(FaviconID icon_id); | |
| 124 | 136 |
| 125 // Favicons ------------------------------------------------------------------ | 137 // Favicons ------------------------------------------------------------------ |
| 126 | 138 |
| 127 // Updates the sizes associated with a favicon to |sizes|. See the comment | 139 // Updates the sizes associated with a favicon to |sizes|. See the comment |
| 128 // at the top of the .cc file for the format of the |sizes| parameter. | 140 // at the top of the .cc file for the format of the |sizes| parameter. |
| 129 bool SetFaviconSizes(FaviconID icon_id, const std::string& sizes); | 141 bool SetFaviconSizes(FaviconID icon_id, const std::string& sizes); |
| 130 | 142 |
| 131 // Sets the the favicon as out of date. This will set |last_updated| for all | 143 // Sets the the favicon as out of date. This will set |last_updated| for all |
| 132 // of the bitmaps for |icon_id| to be out of date. | 144 // of the bitmaps for |icon_id| to be out of date. |
| 133 bool SetFaviconOutOfDate(FaviconID icon_id); | 145 bool SetFaviconOutOfDate(FaviconID icon_id); |
| 134 | 146 |
| 135 // Returns the id of the entry in the favicon database with the specified url | 147 // Returns the id of the entry in the favicon database with the specified url |
| 136 // and icon type. If |required_icon_type| contains multiple icon types and | 148 // and icon type. If |required_icon_type| contains multiple icon types and |
| 137 // there are more than one matched icon in database, only one icon will be | 149 // there are more than one matched icon in database, only one icon will be |
| 138 // returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and | 150 // returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and |
| 139 // FAVICON, and the icon type is returned in icon_type parameter if it is not | 151 // FAVICON. |
| 140 // NULL. | |
| 141 // Returns 0 if no entry exists for the specified url. | 152 // Returns 0 if no entry exists for the specified url. |
| 142 FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, | 153 FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, |
| 143 int required_icon_type, | 154 int required_icon_type); |
| 144 IconType* icon_type); | |
| 145 | |
| 146 // Gets the png encoded favicon, last updated time, icon_url and icon_type for | |
| 147 // the specified favicon id. | |
| 148 // TODO(pkotwicz): Remove this function. | |
| 149 bool GetFavicon(FaviconID icon_id, | |
| 150 base::Time* last_updated, | |
| 151 scoped_refptr<base::RefCountedMemory>* png_icon_data, | |
| 152 GURL* icon_url, | |
| 153 IconType* icon_type); | |
| 154 | 155 |
| 155 // Gets the icon_url, icon_type and sizes for the specified |icon_id|. | 156 // Gets the icon_url, icon_type and sizes for the specified |icon_id|. |
| 156 bool GetFaviconHeader(FaviconID icon_id, | 157 bool GetFaviconHeader(FaviconID icon_id, |
| 157 GURL* icon_url, | 158 GURL* icon_url, |
| 158 IconType* icon_type, | 159 IconType* icon_type, |
| 159 std::string* sizes); | 160 std::string* sizes); |
| 160 | 161 |
| 161 // Adds the favicon URL and icon type to the favicon db, returning its id. | 162 // Adds favicon with |icon_url| and |icon_type| to the favicon db, returning |
| 163 // its id. | |
| 162 FaviconID AddFavicon(const GURL& icon_url, IconType icon_type); | 164 FaviconID AddFavicon(const GURL& icon_url, IconType icon_type); |
| 163 | 165 |
| 164 // Adds a favicon with a single bitmap. This call is equivalent to calling | 166 // Adds a favicon with a single bitmap. This call is equivalent to calling |
| 165 // AddFavicon, SetFaviconSizes, and AddFaviconBitmap. | 167 // AddFavicon, SetFaviconSizes, and AddFaviconBitmap. |
| 166 FaviconID AddFavicon(const GURL& icon_url, | 168 FaviconID AddFavicon(const GURL& icon_url, |
| 167 IconType icon_type, | 169 IconType icon_type, |
| 168 const std::string& sizes, | 170 const std::string& sizes, |
| 169 const scoped_refptr<base::RefCountedMemory>& icon_data, | 171 const scoped_refptr<base::RefCountedMemory>& icon_data, |
| 170 base::Time time, | 172 base::Time time, |
| 171 const gfx::Size& pixel_size); | 173 const gfx::Size& pixel_size); |
| 172 | 174 |
| 173 // Delete the favicon with the provided id. Returns false on failure | 175 // Delete the favicon with the provided id. Returns false on failure |
| 174 bool DeleteFavicon(FaviconID id); | 176 bool DeleteFavicon(FaviconID id); |
| 175 | 177 |
| 176 // Icon Mapping -------------------------------------------------------------- | 178 // Icon Mapping -------------------------------------------------------------- |
| 177 // | 179 // |
| 178 // Returns true if there is a matched icon mapping for the given page and | 180 // Returns true if there is a matched icon mapping for the given page and |
| 179 // icon type. | 181 // icon type. |
| 180 // The matched icon mapping is returned in the icon_mapping parameter if it is | 182 // The matched icon mapping is returned in the icon_mapping parameter if it is |
| 181 // not NULL. | 183 // not NULL. |
| 182 bool GetIconMappingForPageURL(const GURL& page_url, | 184 |
| 183 IconType required_icon_type, | 185 // Returns true if there are icon mappings for the given page and icon type. |
| 184 IconMapping* icon_mapping); | 186 // If |required_icon_types| contains multiple icon types and there is more |
| 187 // than one matched icon type in the database, icons of only a single type | |
| 188 // will be returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, | |
| 189 // and FAVICON. | |
| 190 // The matched icon mappings are returned in the |icon_mappings| parameter if | |
| 191 // it is not NULL. | |
| 192 bool GetIconMappingsForPageURL(const GURL& page_url, | |
| 193 int required_icon_types, | |
| 194 std::vector<IconMapping>* mapping_data); | |
| 185 | 195 |
| 186 // Returns true if there is any matched icon mapping for the given page. | 196 // Returns true if there is any matched icon mapping for the given page. |
| 187 // All matched icon mappings are returned in descent order of IconType if | 197 // All matched icon mappings are returned in descent order of IconType if |
| 188 // mapping_data is not NULL. | 198 // mapping_data is not NULL. |
| 189 bool GetIconMappingsForPageURL(const GURL& page_url, | 199 bool GetIconMappingsForPageURL(const GURL& page_url, |
| 190 std::vector<IconMapping>* mapping_data); | 200 std::vector<IconMapping>* mapping_data); |
| 191 | 201 |
| 192 // Adds a mapping between the given page_url and icon_id. | 202 // Adds a mapping between the given page_url and icon_id. |
| 193 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. | 203 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. |
| 194 IconMappingID AddIconMapping(const GURL& page_url, FaviconID icon_id); | 204 IconMappingID AddIconMapping(const GURL& page_url, FaviconID icon_id); |
| 195 | 205 |
| 196 // Updates the page and icon mapping for the given mapping_id with the given | 206 // Updates the page and icon mapping for the given mapping_id with the given |
| 197 // icon_id. | 207 // icon_id. |
| 198 // Returns true if the update succeeded. | 208 // Returns true if the update succeeded. |
| 199 bool UpdateIconMapping(IconMappingID mapping_id, FaviconID icon_id); | 209 bool UpdateIconMapping(IconMappingID mapping_id, FaviconID icon_id); |
| 200 | 210 |
| 201 // Deletes the icon mapping entries for the given page url. | 211 // Deletes the icon mapping entries for the given page url. |
| 202 // Returns true if the deletion succeeded. | 212 // Returns true if the deletion succeeded. |
| 203 bool DeleteIconMappings(const GURL& page_url); | 213 bool DeleteIconMappings(const GURL& page_url); |
| 204 | 214 |
| 215 // Deletes the icon mapping with |mapping_id|. | |
| 216 // Returns true if the deletion succeeded. | |
| 217 bool DeleteIconMapping(IconMappingID mapping_id); | |
| 218 | |
| 205 // Checks whether a favicon is used by any URLs in the database. | 219 // Checks whether a favicon is used by any URLs in the database. |
| 206 bool HasMappingFor(FaviconID id); | 220 bool HasMappingFor(FaviconID id); |
| 207 | 221 |
| 208 // Clones the existing mappings from |old_page_url| if |new_page_url| has no | 222 // Clones the existing mappings from |old_page_url| if |new_page_url| has no |
| 209 // mappings. Otherwise, will leave mappings alone. | 223 // mappings. Otherwise, will leave mappings alone. |
| 210 bool CloneIconMapping(const GURL& old_page_url, const GURL& new_page_url); | 224 bool CloneIconMappings(const GURL& old_page_url, const GURL& new_page_url); |
| 211 | 225 |
| 212 // The class to enumerate icon mappings. Use InitIconMappingEnumerator to | 226 // The class to enumerate icon mappings. Use InitIconMappingEnumerator to |
| 213 // initialize. | 227 // initialize. |
| 214 class IconMappingEnumerator { | 228 class IconMappingEnumerator { |
| 215 public: | 229 public: |
| 216 IconMappingEnumerator(); | 230 IconMappingEnumerator(); |
| 217 ~IconMappingEnumerator(); | 231 ~IconMappingEnumerator(); |
| 218 | 232 |
| 219 // Get the next icon mapping, return false if no more are available. | 233 // Get the next icon mapping, return false if no more are available. |
| 220 bool GetNextIconMapping(IconMapping* icon_mapping); | 234 bool GetNextIconMapping(IconMapping* icon_mapping); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 const HistoryPublisher* history_publisher_; | 375 const HistoryPublisher* history_publisher_; |
| 362 | 376 |
| 363 // True if migration to TopSites has been done and the thumbnails | 377 // True if migration to TopSites has been done and the thumbnails |
| 364 // table should not be used. | 378 // table should not be used. |
| 365 bool use_top_sites_; | 379 bool use_top_sites_; |
| 366 }; | 380 }; |
| 367 | 381 |
| 368 } // namespace history | 382 } // namespace history |
| 369 | 383 |
| 370 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ | 384 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ |
| OLD | NEW |