Index: chrome/browser/history/thumbnail_database.h |
diff --git a/chrome/browser/history/thumbnail_database.h b/chrome/browser/history/thumbnail_database.h |
index 7a1780f776fc909fe8e6291e41b6e6752ebe2fbd..feb170906db6adee2b2a9000e98552f412dc6f39 100644 |
--- a/chrome/browser/history/thumbnail_database.h |
+++ b/chrome/browser/history/thumbnail_database.h |
@@ -99,11 +99,33 @@ class ThumbnailDatabase { |
// Favicon Bitmaps ----------------------------------------------------------- |
+ // Returns true if there are favicon bitmaps for |icon_id|. If |
+ // |bitmap_size_listing| is non NULL, sets it to a listing of the favicon |
+ // bitmap ids and their associated pixel sizes for the favicon with |
+ // |icon_id|. |
+ bool GetFaviconBitmapIDSizeList( |
+ FaviconID icon_id, |
+ std::vector<FaviconBitmapIDSize>* bitmap_id_size_list); |
+ |
// Returns true if there are any matched bitmaps for the given |icon_id|. All |
// matched results are returned if |favicon_bitmaps| is not NULL. |
bool GetFaviconBitmaps(FaviconID icon_id, |
std::vector<FaviconBitmap>* favicon_bitmaps); |
+ // Gets the favicon id, last updated time, bitmap data, and pixel size of the |
+ // favicon bitmap at |bitmap_id|. |
+ // Returns true if successful. |
+ bool GetFaviconBitmap(FaviconBitmapID bitmap_id, |
+ base::Time* last_updated, |
+ scoped_refptr<base::RefCountedMemory>* png_icon_data, |
+ gfx::Size* pixel_size); |
+ |
+ // Sets the bitmap data and the last updated time for the favicon bitmap at |
+ // |bitmap_id|. Returns true if successful. |
+ bool SetFaviconBitmap(FaviconBitmapID bitmap_id, |
+ scoped_refptr<base::RefCountedMemory> icon_data, |
+ base::Time time); |
+ |
// Adds a bitmap component at |pixel_size| for the favicon with |icon_id|. |
// Only favicons representing a .ico file should have multiple favicon bitmaps |
// per favicon. |
@@ -118,15 +140,14 @@ class ThumbnailDatabase { |
base::Time time, |
const gfx::Size& pixel_size); |
- // Deletes the favicon bitmaps for the favicon with with |icon_id|. |
- // Returns true if successful. |
- bool DeleteFaviconBitmapsForFavicon(FaviconID icon_id); |
+ // Deletes the favicon bitmap with |bitmap_id|. Returns true if successful. |
+ bool DeleteFaviconBitmap(FaviconBitmapID bitmap_id); |
// Favicons ------------------------------------------------------------------ |
- // Updates the sizes associated with a favicon to |sizes|. See the comment |
- // at the top of the .cc file for the format of the |sizes| parameter. |
- bool SetFaviconSizes(FaviconID icon_id, const std::string& sizes); |
+ // Updates the sizes associated with a favicon to |sizes|. See comment at |
+ // top of the .ccc file for description of |sizes|. |
+ bool SetFaviconSizes(FaviconID icon_id, const FaviconSizes& sizes); |
// Sets the the favicon as out of date. This will set |last_updated| for all |
// of the bitmaps for |icon_id| to be out of date. |
@@ -136,36 +157,26 @@ class ThumbnailDatabase { |
// and icon type. If |required_icon_type| contains multiple icon types and |
// there are more than one matched icon in database, only one icon will be |
// returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and |
- // FAVICON, and the icon type is returned in icon_type parameter if it is not |
- // NULL. |
+ // FAVICON. |
// Returns 0 if no entry exists for the specified url. |
FaviconID GetFaviconIDForFaviconURL(const GURL& icon_url, |
- int required_icon_type, |
- IconType* icon_type); |
- |
- // Gets the png encoded favicon, last updated time, icon_url and icon_type for |
- // the specified favicon id. |
- // TODO(pkotwicz): Remove this function. |
- bool GetFavicon(FaviconID icon_id, |
- base::Time* last_updated, |
- scoped_refptr<base::RefCountedMemory>* png_icon_data, |
- GURL* icon_url, |
- IconType* icon_type); |
+ int required_icon_type); |
// Gets the icon_url, icon_type and sizes for the specified |icon_id|. |
bool GetFaviconHeader(FaviconID icon_id, |
GURL* icon_url, |
IconType* icon_type, |
- std::string* sizes); |
+ FaviconSizes* sizes); |
- // Adds the favicon URL and icon type to the favicon db, returning its id. |
+ // Adds favicon with |icon_url| and |icon_type| to the favicon db, returning |
+ // its id. |
FaviconID AddFavicon(const GURL& icon_url, IconType icon_type); |
// Adds a favicon with a single bitmap. This call is equivalent to calling |
// AddFavicon, SetFaviconSizes, and AddFaviconBitmap. |
FaviconID AddFavicon(const GURL& icon_url, |
IconType icon_type, |
- const std::string& sizes, |
+ const FaviconSizes& sizes, |
const scoped_refptr<base::RefCountedMemory>& icon_data, |
base::Time time, |
const gfx::Size& pixel_size); |
@@ -179,9 +190,17 @@ class ThumbnailDatabase { |
// icon type. |
// The matched icon mapping is returned in the icon_mapping parameter if it is |
// not NULL. |
- bool GetIconMappingForPageURL(const GURL& page_url, |
- IconType required_icon_type, |
- IconMapping* icon_mapping); |
+ |
+ // Returns true if there are icon mappings for the given page and icon type. |
+ // If |required_icon_types| contains multiple icon types and there is more |
+ // than one matched icon type in the database, icons of only a single type |
+ // will be returned in the priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, |
+ // and FAVICON. |
+ // The matched icon mappings are returned in the |icon_mappings| parameter if |
+ // it is not NULL. |
+ bool GetIconMappingsForPageURL(const GURL& page_url, |
+ int required_icon_types, |
+ std::vector<IconMapping>* mapping_data); |
// Returns true if there is any matched icon mapping for the given page. |
// All matched icon mappings are returned in descent order of IconType if |
@@ -202,12 +221,16 @@ class ThumbnailDatabase { |
// Returns true if the deletion succeeded. |
bool DeleteIconMappings(const GURL& page_url); |
+ // Deletes the icon mapping with |mapping_id|. |
+ // Returns true if the deletion succeeded. |
+ bool DeleteIconMapping(IconMappingID mapping_id); |
+ |
// Checks whether a favicon is used by any URLs in the database. |
bool HasMappingFor(FaviconID id); |
// Clones the existing mappings from |old_page_url| if |new_page_url| has no |
// mappings. Otherwise, will leave mappings alone. |
- bool CloneIconMapping(const GURL& old_page_url, const GURL& new_page_url); |
+ bool CloneIconMappings(const GURL& old_page_url, const GURL& new_page_url); |
// The class to enumerate icon mappings. Use InitIconMappingEnumerator to |
// initialize. |
@@ -279,6 +302,7 @@ class ThumbnailDatabase { |
FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion4); |
FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion5); |
FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, UpgradeToVersion6); |
+ FRIEND_TEST_ALL_PREFIXES(ThumbnailDatabaseTest, FaviconSizesToAndFromString); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping); |
// Creates the thumbnail table, returning true if the table already exists |
@@ -351,6 +375,22 @@ class ThumbnailDatabase { |
// Returns True if the current database is latest. |
bool IsLatestVersion(); |
+ // Converts the vector representation of sizes as passed into SetFaviconSizes |
+ // to a string to store in the |favicons| database table. |
+ // Format: |
+ // Each widthxheight pair is separated by a space. |
+ // Width and height are separated by a space. |
+ // For instance, if sizes contains pixel sizes (16x16, 32x32), the |
+ // string representation is "16 16 32 32". |
+ static void FaviconSizesToDatabaseString(const FaviconSizes& sizes, |
+ std::string* sizes_string); |
+ |
+ // Converts the string representation of sizes as stored in the |favicons| |
+ // database table to a vector. |
+ // Returns true if there were no errors. |
+ static bool DatabaseStringToFaviconSizes(const std::string sizes_string, |
+ FaviconSizes* sizes); |
+ |
sql::Connection db_; |
sql::MetaTable meta_table_; |