Index: chrome/browser/history/history_backend.h |
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h |
index 6d50cc18f68ebc0dcb8f6be4751bcbb7353e24af..c60a6ef920d7f8816d68701f3fa892d425138419 100644 |
--- a/chrome/browser/history/history_backend.h |
+++ b/chrome/browser/history/history_backend.h |
@@ -248,27 +248,39 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
// Favicon ------------------------------------------------------------------- |
- void GetFavicon(scoped_refptr<GetFaviconRequest> request, |
- const GURL& icon_url, |
- int icon_types); |
+ void GetFaviconClosestToSize(scoped_refptr<GetFaviconRequest> request, |
+ const GURL& icon_url, |
+ int icon_types, |
+ const gfx::Size& pixel_size); |
- void GetFaviconForURL(scoped_refptr<GetFaviconRequest> request, |
- const GURL& page_url, |
- int icon_types); |
+ void GetFavicons(scoped_refptr<GetFaviconRequest> request, |
+ const std::vector<GURL>& icon_urls, |
+ int icon_types); |
- void GetFaviconForID(scoped_refptr<GetFaviconRequest> request, FaviconID id); |
+ void GetFaviconForURLClosestToSize(scoped_refptr<GetFaviconRequest> request, |
+ const GURL& page_url, |
+ int icon_types, |
+ const gfx::Size& pixel_size); |
- void SetFavicon(const GURL& page_url, |
- const GURL& icon_url, |
- scoped_refptr<base::RefCountedMemory> data, |
- IconType icon_type); |
+ void GetFaviconsForURL(scoped_refptr<GetFaviconRequest> request, |
+ const GURL& page_url, |
+ int icon_types); |
- void UpdateFaviconMappingAndFetch(scoped_refptr<GetFaviconRequest> request, |
- const GURL& page_url, |
- const GURL& icon_url, |
- IconType icon_type); |
+ void UpdateFaviconMappingsAndFetch(scoped_refptr<GetFaviconRequest> request, |
+ const GURL& page_url, |
+ const std::vector<GURL>& icon_urls, |
+ IconType icon_type); |
- void SetFaviconOutOfDateForPage(const GURL& page_url); |
+ void AddFavicons(const GURL& page_url, |
+ IconType icon_type, |
+ const std::vector<FaviconDataElement>& elements); |
+ |
+ void SetFavicons(const GURL& page_url, |
+ IconType icon_type, |
+ const std::vector<FaviconDataElement>& elements, |
+ const IconURLSizesMap& icon_url_sizes); |
+ |
+ void SetFaviconsOutOfDateForPage(const GURL& page_url); |
void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); |
@@ -463,10 +475,19 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsTransitions); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationIconMapping); |
- FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconMapping); |
- FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddOrUpdateIconMapping); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
+ SetFaviconMappingsForPageAndRedirects); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
+ SetFaviconMappingsForPageDuplicates); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFavicons); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsDeleteBitmaps); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, SetFaviconsReplaceBitmapData); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetMostRecentVisits); |
- FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconForURL); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDB); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBDesiredSize); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
CloneFaviconIsRestrictedToSameDomain); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); |
@@ -578,32 +599,75 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
// Favicons ------------------------------------------------------------------ |
- // Used by both UpdateFaviconMappingAndFetch and GetFavicon. |
- // If page_url is non-null and SetFavicon has previously been invoked for |
- // icon_url the favicon url for page_url (and all redirects) is set to |
- // icon_url. |
+ // Used by UpdateFaviconMappingsAndFetch, GetFavicons and |
+ // GetFaviconClosestToSize. |
+ // If |page_url| is non-null, the icon urls for |page_url| (and all |
+ // redirects) are set to the subset of |icon_urls| for which icons are |
+ // already stored in the database. |
// Only a single type can be given in icon_type when page_url is specified. |
- void UpdateFaviconMappingAndFetchImpl( |
+ void UpdateFaviconMappingsAndFetchImpl( |
const GURL* page_url, |
- const GURL& icon_url, |
+ const std::vector<GURL>& icon_urls, |
scoped_refptr<GetFaviconRequest> request, |
- int icon_type); |
- |
- // Sets the favicon url id for page_url to id. This will also broadcast |
- // notifications as necessary. |
- void SetFaviconMapping(const GURL& page_url, |
- FaviconID id, |
- IconType icon_type); |
- |
- // Updates the FaviconID associated with the url of a page. If there is an |
- // existing mapping between |page_url| and |id| this does nothing and returns |
- // false. If the mapping needs to be added or updated, true is returned. If |
- // there is an existing mapping but it does not map to |id|, then the |id| of |
- // the replaced FaviconID is set in |replaced_icon_id|. |
- bool AddOrUpdateIconMapping(const GURL& page_url, |
- FaviconID id, |
- IconType icon_type, |
- FaviconID* replaced_icon_id); |
+ int icon_types, |
+ const gfx::Size* desired_pixel_size); |
stevenjb
2012/08/15 22:59:18
Why a const* here instead of a const&?
|
+ |
+ // Set the favicon bitmaps for the favicon at |icon_id|. |
+ void SetFaviconBitmaps(FaviconID icon_id, |
+ const std::vector<FaviconDataElement>& elements); |
+ |
+ // Returns true if the params passed to SetFavicons: |elements| and |
+ // |icon_url_sizes| are valid. |
+ bool ValidateSetFaviconsParams( |
+ const std::vector<FaviconDataElement>& elements, |
+ const IconURLSizesMap& icon_url_sizes) const; |
+ |
+ // Sets the sizes that the thumbnail database knows that the favicon at |
+ // |icon_id| is available at from the web. See history_types for a more |
+ // in depth discussion about FaviconSizes. |
+ void SetFaviconSizes(FaviconID icon_id, |
+ const FaviconSizes& sizes); |
+ |
+ // If there are favicons for |page_url| and one of the types in |
+ // |icon_types|, |favicon_data| is set appropriately and true is returned. |
+ // If |desired_pixel_size| is non NULL, |favicon_data| is set to the favicon |
+ // bitmap which most closely matches |desired_pixel_size|. |
+ bool GetFaviconsFromDB(const GURL& page_url, |
+ int icon_types, |
+ const gfx::Size* desired_pixel_size, |
+ FaviconData* favicon_data); |
+ |
+ // Add data for the favicon at |favicon_id| to |favicon_data|. |
+ // As FaviconData only contains FaviconDataElements for a single IconType, |
+ // the IconType of the favicon at favicon_id must match that of previous |
+ // |FaviconData::elements|. |
+ // Returns true on success. |
+ bool AddToFaviconData(FaviconID favicon_id, |
+ const gfx::Size* desired_pixel_size, |
+ FaviconData* favicon_data); |
+ |
+ // Returns index of the element in |elements| whose pixel size most closely |
+ // matches |desired_pixel_size|. |
+ int GetBestElementForSizeIndex( |
+ const std::vector<FaviconDataElement>& elements, |
+ const gfx::Size& desired_pixel_size) const; |
+ |
+ // Define type used solely in SetFaviconMappingsForPageAndRedirects. |
+ typedef std::map<GURL, FaviconID> IconURLFaviconIDMap; |
+ |
+ // Updates the favicon ids for |icon_type| and |page_url| (including any |
+ // redirects) to the favicon ids in |icon_url_id_map|. This will also |
+ // broadcast notifications as necessary. |
+ void SetFaviconMappingsForPageAndRedirects( |
+ const GURL& page_url, |
+ const IconType icon_type, |
+ const IconURLFaviconIDMap& icon_url_id_map); |
+ |
+ // Updates the favicon ids for |icon_type| and |page_url| to the ids in |
+ // |icon_url_id_map|. |
+ bool SetFaviconMappingsForPage(const GURL& page_url, |
+ IconType icon_type, |
+ const IconURLFaviconIDMap& icon_url_id_map); |
// Generic stuff ------------------------------------------------------------- |
@@ -647,16 +711,6 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
// NULL during testing. |
BookmarkService* GetBookmarkService(); |
- // If there is a favicon for |page_url| and one of the types in |icon_types|, |
- // |favicon| is set appropriately and true is returned. |
- bool GetFaviconFromDB(const GURL& page_url, |
- int icon_types, |
- FaviconData* favicon); |
- |
- // Get favicon by the given |favicon_id|, the |favicon| is set appropriately |
- // and true if returned on success, otherwise false is returned. |
- bool GetFaviconFromDB(FaviconID favicon_id, FaviconData* favicon); |
- |
// Notify any observers of an addition to the visit database. |
void NotifyVisitObservers(const VisitRow& visit); |