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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 void RollbackTransaction(); | 55 void RollbackTransaction(); |
56 | 56 |
57 // Vacuums the database. This will cause sqlite to defragment and collect | 57 // Vacuums the database. This will cause sqlite to defragment and collect |
58 // unused space in the file. It can be VERY SLOW. | 58 // unused space in the file. It can be VERY SLOW. |
59 void Vacuum(); | 59 void Vacuum(); |
60 | 60 |
61 // Try to trim the cache memory used by the database. If |aggressively| is | 61 // Try to trim the cache memory used by the database. If |aggressively| is |
62 // true try to trim all unused cache, otherwise trim by half. | 62 // true try to trim all unused cache, otherwise trim by half. |
63 void TrimMemory(bool aggressively); | 63 void TrimMemory(bool aggressively); |
64 | 64 |
| 65 // Delete all favicon bitmaps that have not been requested long (i.e. not |
| 66 // after |expiration_threshold|). Furthermore, delete all favicons with no |
| 67 // corresponding bitmap and all mappings with no corresponding favicon. |
| 68 void CleanUnusedFavicons(base::Time expiration_threshold); |
| 69 |
65 // Favicon Bitmaps ----------------------------------------------------------- | 70 // Favicon Bitmaps ----------------------------------------------------------- |
66 | 71 |
67 // Returns true if there are favicon bitmaps for |icon_id|. If | 72 // Returns true if there are favicon bitmaps for |icon_id|. If |
68 // |bitmap_id_sizes| is non NULL, sets it to a list of the favicon bitmap ids | 73 // |bitmap_id_sizes| is non NULL, sets it to a list of the favicon bitmap ids |
69 // and their associated pixel sizes for the favicon with |icon_id|. | 74 // and their associated pixel sizes for the favicon with |icon_id|. |
70 // The list contains results for the bitmaps which are cached in the | 75 // The list contains results for the bitmaps which are cached in the |
71 // favicon_bitmaps table. The pixel sizes are a subset of the sizes in the | 76 // favicon_bitmaps table. The pixel sizes are a subset of the sizes in the |
72 // 'sizes' field of the favicons table for |icon_id|. | 77 // 'sizes' field of the favicons table for |icon_id|. |
73 bool GetFaviconBitmapIDSizes( | 78 bool GetFaviconBitmapIDSizes( |
74 favicon_base::FaviconID icon_id, | 79 favicon_base::FaviconID icon_id, |
75 std::vector<FaviconBitmapIDSize>* bitmap_id_sizes); | 80 std::vector<FaviconBitmapIDSize>* bitmap_id_sizes); |
76 | 81 |
77 // Returns true if there are any matched bitmaps for the given |icon_id|. All | 82 // Returns true if there are any matched bitmaps for the given |icon_id|. All |
78 // matched results are returned if |favicon_bitmaps| is not NULL. | 83 // matched results are returned if |favicon_bitmaps| is not NULL. |
79 bool GetFaviconBitmaps(favicon_base::FaviconID icon_id, | 84 bool GetFaviconBitmaps(favicon_base::FaviconID icon_id, |
80 std::vector<FaviconBitmap>* favicon_bitmaps); | 85 std::vector<FaviconBitmap>* favicon_bitmaps); |
81 | 86 |
82 // Gets the last updated time, bitmap data, and pixel size of the favicon | 87 // Gets the last updated time, bitmap data, and pixel size of the favicon |
83 // bitmap at |bitmap_id|. Returns true if successful. | 88 // bitmap at |bitmap_id|. Returns true if successful. The |access_time| is |
| 89 // stored for |bitmap_id| (should be base::Time:Now() in most cases and |
| 90 // base::Time() in incognito profiles to avoid storing the access). The access |
| 91 // times are used to detect that a favicon should be removed if it has not |
| 92 // been used for long. |
84 bool GetFaviconBitmap(FaviconBitmapID bitmap_id, | 93 bool GetFaviconBitmap(FaviconBitmapID bitmap_id, |
| 94 base::Time access_time, |
85 base::Time* last_updated, | 95 base::Time* last_updated, |
86 base::Time* last_requested, | |
87 scoped_refptr<base::RefCountedMemory>* png_icon_data, | 96 scoped_refptr<base::RefCountedMemory>* png_icon_data, |
88 gfx::Size* pixel_size); | 97 gfx::Size* pixel_size); |
89 | 98 |
90 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. | 99 // Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. |
91 // Only favicons representing a .ico file should have multiple favicon bitmaps | 100 // Only favicons representing a .ico file should have multiple favicon bitmaps |
92 // per favicon. | 101 // per favicon. |
93 // |icon_data| is the png encoded data. | 102 // |icon_data| is the png encoded data. |
94 // The |time| indicates the access time, and is used to detect when the | 103 // The |time| indicates the access time, and is used to detect when the |
95 // favicon should be refreshed. | 104 // favicon should be refreshed. |
96 // |pixel_size| is the pixel dimensions of |icon_data|. | 105 // |pixel_size| is the pixel dimensions of |icon_data|. |
97 // Returns the id of the added bitmap or 0 if unsuccessful. | 106 // Returns the id of the added bitmap or 0 if unsuccessful. |
98 FaviconBitmapID AddFaviconBitmap( | 107 FaviconBitmapID AddFaviconBitmap( |
99 favicon_base::FaviconID icon_id, | 108 favicon_base::FaviconID icon_id, |
100 const scoped_refptr<base::RefCountedMemory>& icon_data, | 109 const scoped_refptr<base::RefCountedMemory>& icon_data, |
101 base::Time time, | 110 base::Time time, |
102 const gfx::Size& pixel_size); | 111 const gfx::Size& pixel_size); |
103 | 112 |
104 // Sets the bitmap data and the last updated time for the favicon bitmap at | 113 // Sets the bitmap data and the last updated time for the favicon bitmap at |
105 // |bitmap_id|. | 114 // |bitmap_id|. |
106 // Returns true if successful. | 115 // Returns true if successful. |
107 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, | 116 bool SetFaviconBitmap(FaviconBitmapID bitmap_id, |
108 scoped_refptr<base::RefCountedMemory> bitmap_data, | 117 scoped_refptr<base::RefCountedMemory> bitmap_data, |
109 base::Time time); | 118 base::Time time); |
110 | 119 |
111 // Sets the last updated time for the favicon bitmap at |bitmap_id|. | 120 // Sets the last updated time for the favicon bitmap at |bitmap_id|. |
112 // Returns true if successful. | 121 // Returns true if successful. |
113 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id, | 122 bool SetFaviconBitmapLastUpdateTime(FaviconBitmapID bitmap_id, |
114 base::Time time); | 123 base::Time time); |
115 | 124 |
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|. | 125 // Deletes the favicon bitmap with |bitmap_id|. |
122 // Returns true if successful. | 126 // Returns true if successful. |
123 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); | 127 bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); |
124 | 128 |
125 // Favicons ------------------------------------------------------------------ | 129 // Favicons ------------------------------------------------------------------ |
126 | 130 |
127 // Sets the the favicon as out of date. This will set |last_updated| for all | 131 // 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. | 132 // of the bitmaps for |icon_id| to be out of date. |
129 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); | 133 bool SetFaviconOutOfDate(favicon_base::FaviconID icon_id); |
130 | 134 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 276 |
273 sql::Connection db_; | 277 sql::Connection db_; |
274 sql::MetaTable meta_table_; | 278 sql::MetaTable meta_table_; |
275 | 279 |
276 HistoryBackendClient* backend_client_; | 280 HistoryBackendClient* backend_client_; |
277 }; | 281 }; |
278 | 282 |
279 } // namespace history | 283 } // namespace history |
280 | 284 |
281 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ | 285 #endif // COMPONENTS_HISTORY_CORE_BROWSER_THUMBNAIL_DATABASE_H_ |
OLD | NEW |