Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: components/history/core/browser/thumbnail_database.h

Issue 1004373002: Add last_requested field to the favicon_bitmaps table of the favicons database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial CL for review. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 scoped_refptr<base::RefCountedMemory>* png_icon_data, 85 scoped_refptr<base::RefCountedMemory>* png_icon_data,
86 gfx::Size* pixel_size); 86 gfx::Size* pixel_size);
87 87
88 // Gets the last requested time for the favicon bitmap at |bitmap_id|.
89 // Returns true if successful.
90 bool GetFaviconBitmapLastRequestedTime(FaviconBitmapID bitmap_id,
91 base::Time* time);
92
88 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. 93 // 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 94 // Only favicons representing a .ico file should have multiple favicon bitmaps
90 // per favicon. 95 // per favicon.
91 // |icon_data| is the png encoded data. 96 // |icon_data| is the png encoded data.
92 // The |time| indicates the access time, and is used to detect when the 97 // The |time| indicates the access time, and is used to detect when the
93 // favicon should be refreshed. 98 // favicon should be refreshed.
94 // |pixel_size| is the pixel dimensions of |icon_data|. 99 // |pixel_size| is the pixel dimensions of |icon_data|.
95 // Returns the id of the added bitmap or 0 if unsuccessful. 100 // Returns the id of the added bitmap or 0 if unsuccessful.
96 FaviconBitmapID AddFaviconBitmap( 101 FaviconBitmapID AddFaviconBitmap(
97 favicon_base::FaviconID icon_id, 102 favicon_base::FaviconID icon_id,
98 const scoped_refptr<base::RefCountedMemory>& icon_data, 103 const scoped_refptr<base::RefCountedMemory>& icon_data,
99 base::Time time, 104 base::Time time,
100 const gfx::Size& pixel_size); 105 const gfx::Size& pixel_size);
101 106
102 // Sets the bitmap data and the last updated time for the favicon bitmap at 107 // Sets the bitmap data and the last updated time for the favicon bitmap at
103 // |bitmap_id|. 108 // |bitmap_id|.
104 // Returns true if successful. 109 // Returns true if successful.
105 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, 110 bool SetFaviconBitmap(FaviconBitmapID bitmap_id,
106 scoped_refptr<base::RefCountedMemory> bitmap_data, 111 scoped_refptr<base::RefCountedMemory> bitmap_data,
107 base::Time time); 112 base::Time time);
108 113
109 // Sets the last updated time for the favicon bitmap at |bitmap_id|. 114 // Sets the last updated time for the favicon bitmap at |bitmap_id|.
110 // Returns true if successful. 115 // Returns true if successful.
111 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id, 116 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id,
112 base::Time time); 117 base::Time time);
113 118
119 // Sets the last requested time for the favicon bitmap at |bitmap_id|.
120 // Returns true if successful.
121 bool SetFaviconBitmapLastRequestedTime(FaviconBitmapID bitmap_id,
122 base::Time time);
123
114 // Deletes the favicon bitmap with |bitmap_id|. 124 // Deletes the favicon bitmap with |bitmap_id|.
115 // Returns true if successful. 125 // Returns true if successful.
116 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); 126 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id);
117 127
118 // Favicons ------------------------------------------------------------------ 128 // Favicons ------------------------------------------------------------------
119 129
120 // Sets the the favicon as out of date. This will set |last_updated| for all 130 // 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. 131 // of the bitmaps for |icon_id| to be out of date.
122 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); 132 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id);
123 133
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // so failure causes any outer transaction to be rolled back. 244 // so failure causes any outer transaction to be rolled back.
235 bool RetainDataForPageUrls(const std::vector<GURL>& urls_to_keep); 245 bool RetainDataForPageUrls(const std::vector<GURL>& urls_to_keep);
236 246
237 private: 247 private:
238 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, RetainDataForPageUrls); 248 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, RetainDataForPageUrls);
239 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version3); 249 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version3);
240 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version4); 250 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version4);
241 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version5); 251 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version5);
242 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version6); 252 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version6);
243 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version7); 253 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version7);
254 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, Version8);
244 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, WildSchema); 255 FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, WildSchema);
245 256
246 // Open database on a given filename. If the file does not exist, 257 // Open database on a given filename. If the file does not exist,
247 // it is created. 258 // it is created.
248 // |db| is the database to open. 259 // |db| is the database to open.
249 // |db_name| is a path to the database file. 260 // |db_name| is a path to the database file.
250 sql::InitStatus OpenDatabase(sql::Connection* db, 261 sql::InitStatus OpenDatabase(sql::Connection* db,
251 const base::FilePath& db_name); 262 const base::FilePath& db_name);
252 263
253 // Helper function to implement internals of Init(). This allows 264 // Helper function to implement internals of Init(). This allows
254 // Init() to retry in case of failure, since some failures run 265 // Init() to retry in case of failure, since some failures run
255 // recovery code. 266 // recovery code.
256 sql::InitStatus InitImpl(const base::FilePath& db_name); 267 sql::InitStatus InitImpl(const base::FilePath& db_name);
257 268
258 // Helper function to handle cleanup on upgrade failures. 269 // Helper function to handle cleanup on upgrade failures.
259 sql::InitStatus CantUpgradeToVersion(int cur_version); 270 sql::InitStatus CantUpgradeToVersion(int cur_version);
260 271
261 // Adds support for size in favicons table. 272 // Adds support for size in favicons table.
262 bool UpgradeToVersion6(); 273 bool UpgradeToVersion6();
263 274
264 // Removes sizes column. 275 // Removes sizes column.
265 bool UpgradeToVersion7(); 276 bool UpgradeToVersion7();
266 277
278 // Adds support for bitmap usage tracking.
279 bool UpgradeToVersion8();
280
267 // Returns true if the |favicons| database is missing a column. 281 // Returns true if the |favicons| database is missing a column.
268 bool IsFaviconDBStructureIncorrect(); 282 bool IsFaviconDBStructureIncorrect();
269 283
270 sql::Connection db_; 284 sql::Connection db_;
271 sql::MetaTable meta_table_; 285 sql::MetaTable meta_table_;
272 286
273 HistoryClient* history_client_; 287 HistoryClient* history_client_;
274 }; 288 };
275 289
276 } // namespace history 290 } // namespace history
277 291
278 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ 292 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698