| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 // Called by the to delete all old thumbnails and make a clean table. | 92 // Called by the to delete all old thumbnails and make a clean table. |
| 93 // Returns true on success. | 93 // Returns true on success. |
| 94 bool RecreateThumbnailTable(); | 94 bool RecreateThumbnailTable(); |
| 95 | 95 |
| 96 // FavIcons ------------------------------------------------------------------ | 96 // FavIcons ------------------------------------------------------------------ |
| 97 | 97 |
| 98 // Sets the bits for a favicon. This should be png encoded data. | 98 // Sets the bits for a favicon. This should be png encoded data. |
| 99 // The time indicates the access time, and is used to detect when the favicon | 99 // The time indicates the access time, and is used to detect when the favicon |
| 100 // should be refreshed. | 100 // should be refreshed. |
| 101 bool SetFavicon(FavIconID icon_id, | 101 bool SetFavicon(FaviconID icon_id, |
| 102 scoped_refptr<RefCountedMemory> icon_data, | 102 scoped_refptr<RefCountedMemory> icon_data, |
| 103 base::Time time); | 103 base::Time time); |
| 104 | 104 |
| 105 // Sets the time the favicon was last updated. | 105 // Sets the time the favicon was last updated. |
| 106 bool SetFaviconLastUpdateTime(FavIconID icon_id, base::Time time); | 106 bool SetFaviconLastUpdateTime(FaviconID icon_id, base::Time time); |
| 107 | 107 |
| 108 // Returns the id of the entry in the favicon database with the specified url | 108 // Returns the id of the entry in the favicon database with the specified url |
| 109 // and icon type. If |required_icon_type| contains multiple icon types and | 109 // and icon type. If |required_icon_type| contains multiple icon types and |
| 110 // there are more than one matched icon in database, only one icon will be | 110 // there are more than one matched icon in database, only one icon will be |
| 111 // returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and | 111 // returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and |
| 112 // FAV_ICON, and the icon type is returned in icon_type parameter if it is not | 112 // FAV_ICON, and the icon type is returned in icon_type parameter if it is not |
| 113 // NULL. | 113 // NULL. |
| 114 // Returns 0 if no entry exists for the specified url. | 114 // Returns 0 if no entry exists for the specified url. |
| 115 FavIconID GetFavIconIDForFavIconURL(const GURL& icon_url, | 115 FaviconID GetFaviconIDForFavIconURL(const GURL& icon_url, |
| 116 int required_icon_type, | 116 int required_icon_type, |
| 117 IconType* icon_type); | 117 IconType* icon_type); |
| 118 | 118 |
| 119 // Gets the png encoded favicon and last updated time for the specified | 119 // Gets the png encoded favicon and last updated time for the specified |
| 120 // favicon id. | 120 // favicon id. |
| 121 bool GetFavicon(FavIconID icon_id, | 121 bool GetFavicon(FaviconID icon_id, |
| 122 base::Time* last_updated, | 122 base::Time* last_updated, |
| 123 std::vector<unsigned char>* png_icon_data, | 123 std::vector<unsigned char>* png_icon_data, |
| 124 GURL* icon_url); | 124 GURL* icon_url); |
| 125 | 125 |
| 126 // Adds the favicon URL and icon type to the favicon db, returning its id. | 126 // Adds the favicon URL and icon type to the favicon db, returning its id. |
| 127 FavIconID AddFavIcon(const GURL& icon_url, IconType icon_type); | 127 FaviconID AddFavIcon(const GURL& icon_url, IconType icon_type); |
| 128 | 128 |
| 129 // Delete the favicon with the provided id. Returns false on failure | 129 // Delete the favicon with the provided id. Returns false on failure |
| 130 bool DeleteFavIcon(FavIconID id); | 130 bool DeleteFavIcon(FaviconID id); |
| 131 | 131 |
| 132 // Icon Mapping -------------------------------------------------------------- | 132 // Icon Mapping -------------------------------------------------------------- |
| 133 // | 133 // |
| 134 // Returns true if there is a matched icon mapping for the given page and | 134 // Returns true if there is a matched icon mapping for the given page and |
| 135 // icon type. | 135 // icon type. |
| 136 // The matched icon mapping is returned in the icon_mapping parameter if it is | 136 // The matched icon mapping is returned in the icon_mapping parameter if it is |
| 137 // not NULL. | 137 // not NULL. |
| 138 bool GetIconMappingForPageURL(const GURL& page_url, | 138 bool GetIconMappingForPageURL(const GURL& page_url, |
| 139 IconType required_icon_type, | 139 IconType required_icon_type, |
| 140 IconMapping* icon_mapping); | 140 IconMapping* icon_mapping); |
| 141 | 141 |
| 142 // Returns true if there is any matched icon mapping for the given page. | 142 // Returns true if there is any matched icon mapping for the given page. |
| 143 // All matched icon mappings are returned in descent order of IconType if | 143 // All matched icon mappings are returned in descent order of IconType if |
| 144 // mapping_data is not NULL. | 144 // mapping_data is not NULL. |
| 145 bool GetIconMappingsForPageURL(const GURL& page_url, | 145 bool GetIconMappingsForPageURL(const GURL& page_url, |
| 146 std::vector<IconMapping>* mapping_data); | 146 std::vector<IconMapping>* mapping_data); |
| 147 | 147 |
| 148 // Adds a mapping between the given page_url and icon_id. | 148 // Adds a mapping between the given page_url and icon_id. |
| 149 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. | 149 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. |
| 150 IconMappingID AddIconMapping(const GURL& page_url, FavIconID icon_id); | 150 IconMappingID AddIconMapping(const GURL& page_url, FaviconID icon_id); |
| 151 | 151 |
| 152 // Updates the page and icon mapping for the given mapping_id with the given | 152 // Updates the page and icon mapping for the given mapping_id with the given |
| 153 // icon_id. | 153 // icon_id. |
| 154 // Returns true if the update succeeded. | 154 // Returns true if the update succeeded. |
| 155 bool UpdateIconMapping(IconMappingID mapping_id, FavIconID icon_id); | 155 bool UpdateIconMapping(IconMappingID mapping_id, FaviconID icon_id); |
| 156 | 156 |
| 157 // Deletes the icon mapping entries for the given page url. | 157 // Deletes the icon mapping entries for the given page url. |
| 158 // Returns true if the deletion succeeded. | 158 // Returns true if the deletion succeeded. |
| 159 bool DeleteIconMappings(const GURL& page_url); | 159 bool DeleteIconMappings(const GURL& page_url); |
| 160 | 160 |
| 161 // Checks whether a favicon is used by any URLs in the database. | 161 // Checks whether a favicon is used by any URLs in the database. |
| 162 bool HasMappingFor(FavIconID id); | 162 bool HasMappingFor(FaviconID id); |
| 163 | 163 |
| 164 // Temporary IconMapping ----------------------------------------------------- | 164 // Temporary IconMapping ----------------------------------------------------- |
| 165 // | 165 // |
| 166 // Creates a temporary table to store icon mapping. Icon mapping will be | 166 // Creates a temporary table to store icon mapping. Icon mapping will be |
| 167 // copied to this table by AddToTemporaryIconMappingTable() and then the | 167 // copied to this table by AddToTemporaryIconMappingTable() and then the |
| 168 // original table will be dropped, leaving only those copied mapping | 168 // original table will be dropped, leaving only those copied mapping |
| 169 // remaining. This is used to quickly delete most of the icon mapping when | 169 // remaining. This is used to quickly delete most of the icon mapping when |
| 170 // clearing history. | 170 // clearing history. |
| 171 bool InitTemporaryIconMappingTable() { | 171 bool InitTemporaryIconMappingTable() { |
| 172 return InitIconMappingTable(&db_, true); | 172 return InitIconMappingTable(&db_, true); |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Copies the given icon mapping from the "main" icon_mapping table to the | 175 // Copies the given icon mapping from the "main" icon_mapping table to the |
| 176 // temporary one. This is only valid in between calls to | 176 // temporary one. This is only valid in between calls to |
| 177 // InitTemporaryIconMappingTable() | 177 // InitTemporaryIconMappingTable() |
| 178 // and CommitTemporaryIconMappingTable(). | 178 // and CommitTemporaryIconMappingTable(). |
| 179 // | 179 // |
| 180 // The ID of the favicon will change when this copy takes place. The new ID | 180 // The ID of the favicon will change when this copy takes place. The new ID |
| 181 // is returned, or 0 on failure. | 181 // is returned, or 0 on failure. |
| 182 IconMappingID AddToTemporaryIconMappingTable(const GURL& page_url, | 182 IconMappingID AddToTemporaryIconMappingTable(const GURL& page_url, |
| 183 const FavIconID icon_id); | 183 const FaviconID icon_id); |
| 184 | 184 |
| 185 // Replaces the main icon mapping table with the temporary table created by | 185 // Replaces the main icon mapping table with the temporary table created by |
| 186 // InitTemporaryIconMappingTable(). This will mean all icon mapping not copied | 186 // InitTemporaryIconMappingTable(). This will mean all icon mapping not copied |
| 187 // over will be deleted. Returns true on success. | 187 // over will be deleted. Returns true on success. |
| 188 bool CommitTemporaryIconMappingTable(); | 188 bool CommitTemporaryIconMappingTable(); |
| 189 | 189 |
| 190 // Temporary FavIcons -------------------------------------------------------- | 190 // Temporary FavIcons -------------------------------------------------------- |
| 191 | 191 |
| 192 // Create a temporary table to store favicons. Favicons will be copied to | 192 // Create a temporary table to store favicons. Favicons will be copied to |
| 193 // this table by CopyToTemporaryFavIconTable() and then the original table | 193 // this table by CopyToTemporaryFavIconTable() and then the original table |
| 194 // will be dropped, leaving only those copied favicons remaining. This is | 194 // will be dropped, leaving only those copied favicons remaining. This is |
| 195 // used to quickly delete most of the favicons when clearing history. | 195 // used to quickly delete most of the favicons when clearing history. |
| 196 bool InitTemporaryFavIconsTable() { | 196 bool InitTemporaryFavIconsTable() { |
| 197 return InitFavIconsTable(&db_, true); | 197 return InitFavIconsTable(&db_, true); |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Copies the given favicon from the "main" favicon table to the temporary | 200 // Copies the given favicon from the "main" favicon table to the temporary |
| 201 // one. This is only valid in between calls to InitTemporaryFavIconsTable() | 201 // one. This is only valid in between calls to InitTemporaryFavIconsTable() |
| 202 // and CommitTemporaryFavIconTable(). | 202 // and CommitTemporaryFavIconTable(). |
| 203 // | 203 // |
| 204 // The ID of the favicon will change when this copy takes place. The new ID | 204 // The ID of the favicon will change when this copy takes place. The new ID |
| 205 // is returned, or 0 on failure. | 205 // is returned, or 0 on failure. |
| 206 FavIconID CopyToTemporaryFavIconTable(FavIconID source); | 206 FaviconID CopyToTemporaryFavIconTable(FaviconID source); |
| 207 | 207 |
| 208 // Replaces the main URL table with the temporary table created by | 208 // Replaces the main URL table with the temporary table created by |
| 209 // InitTemporaryFavIconsTable(). This will mean all favicons not copied over | 209 // InitTemporaryFavIconsTable(). This will mean all favicons not copied over |
| 210 // will be deleted. Returns true on success. | 210 // will be deleted. Returns true on success. |
| 211 bool CommitTemporaryFavIconTable(); | 211 bool CommitTemporaryFavIconTable(); |
| 212 | 212 |
| 213 // Returns true iff the thumbnails table exists. | 213 // Returns true iff the thumbnails table exists. |
| 214 // Migrating to TopSites is dropping the thumbnails table. | 214 // Migrating to TopSites is dropping the thumbnails table. |
| 215 bool NeedsMigrationToTopSites(); | 215 bool NeedsMigrationToTopSites(); |
| 216 | 216 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // initialization after the table is created. This is a separate function | 260 // initialization after the table is created. This is a separate function |
| 261 // because it is used by CommitTemporaryIconMappingTable to create an index | 261 // because it is used by CommitTemporaryIconMappingTable to create an index |
| 262 // over the newly-renamed icon_mapping table (formerly the temporary table | 262 // over the newly-renamed icon_mapping table (formerly the temporary table |
| 263 // with no index). | 263 // with no index). |
| 264 void InitIconMappingIndex(); | 264 void InitIconMappingIndex(); |
| 265 | 265 |
| 266 // Adds a mapping between the given page_url and icon_id; The mapping will be | 266 // Adds a mapping between the given page_url and icon_id; The mapping will be |
| 267 // added to temp_icon_mapping table if is_temporary is true. | 267 // added to temp_icon_mapping table if is_temporary is true. |
| 268 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. | 268 // Returns the new mapping id if the adding succeeds, otherwise 0 is returned. |
| 269 IconMappingID AddIconMapping(const GURL& page_url, | 269 IconMappingID AddIconMapping(const GURL& page_url, |
| 270 FavIconID icon_id, | 270 FaviconID icon_id, |
| 271 bool is_temporary); | 271 bool is_temporary); |
| 272 | 272 |
| 273 sql::Connection db_; | 273 sql::Connection db_; |
| 274 sql::MetaTable meta_table_; | 274 sql::MetaTable meta_table_; |
| 275 | 275 |
| 276 // This object is created and managed by the history backend. We maintain an | 276 // This object is created and managed by the history backend. We maintain an |
| 277 // opaque pointer to the object for our use. | 277 // opaque pointer to the object for our use. |
| 278 // This can be NULL if there are no indexers registered to receive indexing | 278 // This can be NULL if there are no indexers registered to receive indexing |
| 279 // data from us. | 279 // data from us. |
| 280 const HistoryPublisher* history_publisher_; | 280 const HistoryPublisher* history_publisher_; |
| 281 | 281 |
| 282 // True if migration to TopSites has been done and the thumbnails | 282 // True if migration to TopSites has been done and the thumbnails |
| 283 // table should not be used. | 283 // table should not be used. |
| 284 bool use_top_sites_; | 284 bool use_top_sites_; |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 } // namespace history | 287 } // namespace history |
| 288 | 288 |
| 289 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ | 289 #endif // CHROME_BROWSER_HISTORY_THUMBNAIL_DATABASE_H_ |
| OLD | NEW |