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