| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Returns true if there are any matched bitmaps for the given |icon_id|. All | 76 // Returns true if there are any matched bitmaps for the given |icon_id|. All |
| 77 // matched results are returned if |favicon_bitmaps| is not NULL. | 77 // matched results are returned if |favicon_bitmaps| is not NULL. |
| 78 bool GetFaviconBitmaps(favicon_base::FaviconID icon_id, | 78 bool GetFaviconBitmaps(favicon_base::FaviconID icon_id, |
| 79 std::vector<FaviconBitmap>* favicon_bitmaps); | 79 std::vector<FaviconBitmap>* favicon_bitmaps); |
| 80 | 80 |
| 81 // Gets the last updated time, bitmap data, and pixel size of the favicon | 81 // Gets the last updated time, bitmap data, and pixel size of the favicon |
| 82 // bitmap at |bitmap_id|. Returns true if successful. | 82 // bitmap at |bitmap_id|. Returns true if successful. |
| 83 bool GetFaviconBitmap(FaviconBitmapID bitmap_id, | 83 bool GetFaviconBitmap(FaviconBitmapID bitmap_id, |
| 84 base::Time* last_updated, | 84 base::Time* last_updated, |
| 85 base::Time* last_requested, |
| 85 scoped_refptr<base::RefCountedMemory>* png_icon_data, | 86 scoped_refptr<base::RefCountedMemory>* png_icon_data, |
| 86 gfx::Size* pixel_size); | 87 gfx::Size* pixel_size); |
| 87 | 88 |
| 88 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. | 89 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. |
| 89 // Only favicons representing a .ico file should have multiple favicon bitmaps | 90 // Only favicons representing a .ico file should have multiple favicon bitmaps |
| 90 // per favicon. | 91 // per favicon. |
| 91 // |icon_data| is the png encoded data. | 92 // |icon_data| is the png encoded data. |
| 92 // The |time| indicates the access time, and is used to detect when the | 93 // The |time| indicates the access time, and is used to detect when the |
| 93 // favicon should be refreshed. | 94 // favicon should be refreshed. |
| 94 // |pixel_size| is the pixel dimensions of |icon_data|. | 95 // |pixel_size| is the pixel dimensions of |icon_data|. |
| 95 // Returns the id of the added bitmap or 0 if unsuccessful. | 96 // Returns the id of the added bitmap or 0 if unsuccessful. |
| 96 FaviconBitmapID AddFaviconBitmap( | 97 FaviconBitmapID AddFaviconBitmap( |
| 97 favicon_base::FaviconID icon_id, | 98 favicon_base::FaviconID icon_id, |
| 98 const scoped_refptr<base::RefCountedMemory>& icon_data, | 99 const scoped_refptr<base::RefCountedMemory>& icon_data, |
| 99 base::Time time, | 100 base::Time time, |
| 100 const gfx::Size& pixel_size); | 101 const gfx::Size& pixel_size); |
| 101 | 102 |
| 102 // Sets the bitmap data and the last updated time for the favicon bitmap at | 103 // Sets the bitmap data and the last updated time for the favicon bitmap at |
| 103 // |bitmap_id|. | 104 // |bitmap_id|. |
| 104 // Returns true if successful. | 105 // Returns true if successful. |
| 105 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, | 106 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, |
| 106 scoped_refptr<base::RefCountedMemory> bitmap_data, | 107 scoped_refptr<base::RefCountedMemory> bitmap_data, |
| 107 base::Time time); | 108 base::Time time); |
| 108 | 109 |
| 109 // Sets the last updated time for the favicon bitmap at |bitmap_id|. | 110 // Sets the last updated time for the favicon bitmap at |bitmap_id|. |
| 110 // Returns true if successful. | 111 // Returns true if successful. |
| 111 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id, | 112 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id, |
| 112 base::Time time); | 113 base::Time time); |
| 113 | 114 |
| 115 // Sets the last requested time for the favicon bitmap at |bitmap_id|. |
| 116 // Returns true if successful. |
| 117 bool SetFaviconBitmapLastRequestedTime(FaviconBitmapID bitmap_id, |
| 118 base::Time time); |
| 119 |
| 114 // Deletes the favicon bitmap with |bitmap_id|. | 120 // Deletes the favicon bitmap with |bitmap_id|. |
| 115 // Returns true if successful. | 121 // Returns true if successful. |
| 116 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); | 122 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); |
| 117 | 123 |
| 118 // Favicons ------------------------------------------------------------------ | 124 // Favicons ------------------------------------------------------------------ |
| 119 | 125 |
| 120 // 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 |
| 121 // of the bitmaps for |icon_id| to be out of date. | 127 // of the bitmaps for |icon_id| to be out of date. |
| 122 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); | 128 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); |
| 123 | 129 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // so failure causes any outer transaction to be rolled back. | 240 // so failure causes any outer transaction to be rolled back. |
| 235 bool RetainDataForPageUrls(const std::vector<GURL>& urls_to_keep); | 241 bool RetainDataForPageUrls(const std::vector<GURL>& urls_to_keep); |
| 236 | 242 |
| 237 private: | 243 private: |
| 238 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, RetainDataForPageUrls); | 244 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, RetainDataForPageUrls); |
| 239 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version3); | 245 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version3); |
| 240 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version4); | 246 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version4); |
| 241 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version5); | 247 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version5); |
| 242 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version6); | 248 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version6); |
| 243 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version7); | 249 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version7); |
| 250 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version8); |
| 244 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, WildSchema); | 251 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, WildSchema); |
| 245 | 252 |
| 246 // Open database on a given filename. If the file does not exist, | 253 // Open database on a given filename. If the file does not exist, |
| 247 // it is created. | 254 // it is created. |
| 248 // |db| is the database to open. | 255 // |db| is the database to open. |
| 249 // |db_name| is a path to the database file. | 256 // |db_name| is a path to the database file. |
| 250 sql::InitStatus OpenDatabase(sql::Connection* db, | 257 sql::InitStatus OpenDatabase(sql::Connection* db, |
| 251 const base::FilePath& db_name); | 258 const base::FilePath& db_name); |
| 252 | 259 |
| 253 // Helper function to implement internals of Init(). This allows | 260 // Helper function to implement internals of Init(). This allows |
| 254 // Init() to retry in case of failure, since some failures run | 261 // Init() to retry in case of failure, since some failures run |
| 255 // recovery code. | 262 // recovery code. |
| 256 sql::InitStatus InitImpl(const base::FilePath& db_name); | 263 sql::InitStatus InitImpl(const base::FilePath& db_name); |
| 257 | 264 |
| 258 // Helper function to handle cleanup on upgrade failures. | 265 // Helper function to handle cleanup on upgrade failures. |
| 259 sql::InitStatus CantUpgradeToVersion(int cur_version); | 266 sql::InitStatus CantUpgradeToVersion(int cur_version); |
| 260 | 267 |
| 261 // Adds support for size in favicons table. | 268 // Adds support for size in favicons table. |
| 262 bool UpgradeToVersion6(); | 269 bool UpgradeToVersion6(); |
| 263 | 270 |
| 264 // Removes sizes column. | 271 // Removes sizes column. |
| 265 bool UpgradeToVersion7(); | 272 bool UpgradeToVersion7(); |
| 266 | 273 |
| 274 // Adds support for bitmap usage tracking. |
| 275 bool UpgradeToVersion8(); |
| 276 |
| 267 // Returns true if the |favicons| database is missing a column. | 277 // Returns true if the |favicons| database is missing a column. |
| 268 bool IsFaviconDBStructureIncorrect(); | 278 bool IsFaviconDBStructureIncorrect(); |
| 269 | 279 |
| 270 sql::Connection db_; | 280 sql::Connection db_; |
| 271 sql::MetaTable meta_table_; | 281 sql::MetaTable meta_table_; |
| 272 | 282 |
| 273 HistoryClient* history_client_; | 283 HistoryClient* history_client_; |
| 274 }; | 284 }; |
| 275 | 285 |
| 276 } // namespace history | 286 } // namespace history |
| 277 | 287 |
| 278 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ | 288 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ |
| OLD | NEW |