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..9249149b0e23bed2d9530da408623197101076bf 100644 |
--- a/chrome/browser/history/history_backend.h |
+++ b/chrome/browser/history/history_backend.h |
@@ -248,29 +248,31 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
// Favicon ------------------------------------------------------------------- |
- void GetFavicon(scoped_refptr<GetFaviconRequest> request, |
- const GURL& icon_url, |
- int icon_types); |
+ void GetFavicons(scoped_refptr<GetFaviconRequest> request, |
+ const std::vector<GURL>& icon_urls, |
+ int icon_types); |
- void GetFaviconForURL(scoped_refptr<GetFaviconRequest> request, |
- const GURL& page_url, |
- int icon_types); |
+ void GetFaviconsForURL(scoped_refptr<GetFaviconRequest> request, |
+ const GURL& page_url, |
+ int icon_types); |
- void GetFaviconForID(scoped_refptr<GetFaviconRequest> request, FaviconID id); |
+ void UpdateFaviconMappingsAndFetch(scoped_refptr<GetFaviconRequest> request, |
+ const GURL& page_url, |
+ const std::vector<GURL>& icon_urls, |
+ IconType icon_type); |
- void SetFavicon(const GURL& page_url, |
- const GURL& icon_url, |
- scoped_refptr<base::RefCountedMemory> data, |
- IconType icon_type); |
+ void AddFavicons(const GURL& page_url, |
+ IconType icon_type, |
+ const std::vector<FaviconDataElement>& elements); |
- void UpdateFaviconMappingAndFetch(scoped_refptr<GetFaviconRequest> request, |
- const GURL& page_url, |
- const GURL& icon_url, |
- IconType icon_type); |
+ void SetFavicons(const GURL& page_url, |
+ IconType icon_type, |
+ const std::vector<FaviconDataElement>& elements, |
+ const IconURLSizesMap& icon_url_sizes); |
- void SetFaviconOutOfDateForPage(const GURL& page_url); |
+ void SetFaviconsOutOfDateForPage(const GURL& page_url); |
- void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); |
+ void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url); |
void SetImportedFavicons( |
const std::vector<ImportedFaviconUsage>& favicon_usage); |
@@ -442,6 +444,14 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
// code to avoid syncing visits that would immediately be expired). |
virtual bool IsExpiredVisitTime(const base::Time& time); |
+ // Set whether HistoryBackend::SetFavicon is cripled such that it can only be |
+ // used to set favicon bitmaps of size 0 0 for a single URL. |
+ // TODO(pkotwicz): Remove this restriction. |
+ void set_single_favicon_bitmap_per_icon_type( |
+ bool single_favicon_bitmap_per_icon_type) { |
+ single_favicon_bitmap_per_icon_type_ = single_favicon_bitmap_per_icon_type; |
+ } |
+ |
protected: |
virtual ~HistoryBackend(); |
@@ -463,10 +473,18 @@ 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, GetFaviconsFromDBIconType); |
+ FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
CloneFaviconIsRestrictedToSameDomain); |
FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); |
@@ -578,32 +596,62 @@ 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 both UpdateFaviconMappingsAndFetch and GetFavicons. |
+ // 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); |
+ |
+ // Set the favicon bitmaps for the favicon at |icon_id|. |
+ void SetFaviconBitmaps(FaviconID icon_id, |
+ const std::vector<FaviconDataElement>& elements); |
+ |
+ // Returns true if |elements| and |icon_url_sizes| passed to SetFavicons |
+ // 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. |
+ bool GetFaviconsFromDB(const GURL& page_url, |
+ int icon_types, |
+ 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, |
sky
2012/08/21 20:16:56
Using 'Add' in the name makes it sound as though t
|
+ FaviconData* favicon_data); |
+ |
+ // Define type used solely in SetFaviconMappingsForPageAndRedirects. |
+ typedef std::map<GURL, FaviconID> IconURLFaviconIDMap; |
+ |
+ // Maps the favicon ids in |icon_url_id_map| to |page_url| (and all |
+ // redirects) for |icon_type|. This will also broadcast notifications as |
+ // necessary. |
+ void SetFaviconMappingsForPageAndRedirects( |
+ const GURL& page_url, |
+ const IconType icon_type, |
+ const IconURLFaviconIDMap& icon_url_id_map); |
+ |
+ // Maps the favicon ids in |icon_url_id_map| to |page_url| for |icon_type|. |
+ bool SetFaviconMappingsForPage(const GURL& page_url, |
+ IconType icon_type, |
+ const IconURLFaviconIDMap& icon_url_id_map); |
// Generic stuff ------------------------------------------------------------- |
@@ -647,16 +695,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); |
@@ -756,6 +794,10 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
scoped_ptr<AndroidProviderBackend> android_provider_backend_; |
#endif |
+ // If true HistoryBackend::SetFavicons is cripled such that it can only be |
+ // used to set favicon bitmapas for a single URL and 0 0 bitmap size. |
+ bool single_favicon_bitmap_per_icon_type_; |
+ |
DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
}; |