Index: components/bookmarks/browser/bookmark_model.h |
diff --git a/components/bookmarks/browser/bookmark_model.h b/components/bookmarks/browser/bookmark_model.h |
index e222790c4dc1a74035bc837566ef089f1e770ef0..48fc4619690b15deae2a1232e8f7b29b474e8c57 100644 |
--- a/components/bookmarks/browser/bookmark_model.h |
+++ b/components/bookmarks/browser/bookmark_model.h |
@@ -166,6 +166,10 @@ class BookmarkModel : public KeyedService { |
// Returns the set of nodes with the |url|. |
void GetNodesByURL(const GURL& url, std::vector<const BookmarkNode*>* nodes); |
+ // Returns the set of nodes which use the favicon at |icon_url|. |
+ void GetNodesByIconURL(const GURL& icon_url, |
+ std::vector<const BookmarkNode*>* nodes); |
+ |
// Returns the most recently added user node for the |url|; urls from any |
// nodes that are not editable by the user are never returned by this call. |
// Returns NULL if |url| is not bookmarked. |
@@ -296,15 +300,19 @@ class BookmarkModel : public KeyedService { |
void SetNodeSyncTransactionVersion(const BookmarkNode* node, |
int64 sync_transaction_version); |
- // Notify BookmarkModel that the favicons for |urls| have changed and have to |
+ // Notify BookmarkModel that the favicons for the given page URLs |
+ // (e.g. http://www.google.com) and the given icon URLs (e.g. |
+ // http://www.google.com/favicon.ico) have changed and have to |
// be refetched. This notification is sent by BookmarkClient. |
- void OnFaviconChanged(const std::set<GURL>& urls); |
+ void OnFaviconsChanged(const std::vector<GURL>& page_urls, |
+ const std::vector<GURL>& icon_urls); |
// Returns the client used by this BookmarkModel. |
BookmarkClient* client() const { return client_; } |
private: |
friend class BookmarkCodecTest; |
+ friend class BookmarkModelTest; |
friend class BookmarkStorage; |
friend class ScopedGroupBookmarkActions; |
friend class TestBookmarkClient; |
@@ -317,6 +325,14 @@ class BookmarkModel : public KeyedService { |
} |
}; |
+ // Used to order BookmarkNodes by icon URL. |
+ class NodeIconURLComparator { |
+ public: |
+ bool operator()(const BookmarkNode* n1, BookmarkNode* n2) const { |
+ return n1->icon_url() < n2->icon_url(); |
+ } |
+ }; |
+ |
// Implementation of IsBookmarked. Before calling this the caller must obtain |
// a lock on |url_lock_|. |
bool IsBookmarkedNoLock(const GURL& url); |
@@ -378,6 +394,13 @@ class BookmarkModel : public KeyedService { |
// Called to notify the observers that the favicon has been loaded. |
void FaviconLoaded(const BookmarkNode* node); |
+ // Sets |node|'s favicon URL. |
+ void SetFaviconURL(BookmarkNode* node, const GURL& icon_url); |
+ |
+ // Clear |node|'s favicon data. Also cancel's any pending favicon load |
+ // requests for |node|. |
+ void InvalidateFavicon(BookmarkNode* node); |
+ |
// If we're waiting on a favicon for node, the load request is canceled. |
void CancelPendingFaviconLoadRequests(BookmarkNode* node); |
@@ -426,6 +449,13 @@ class BookmarkModel : public KeyedService { |
NodesOrderedByURLSet nodes_ordered_by_url_set_; |
base::Lock url_lock_; |
+ // Set of nodes ordered by favicon URL. Does not contain nodes whose favicon |
+ // has not been loaded or which do not have a favicon. |
+ // WARNING: Only access from the UI thread. |
+ typedef std::multiset<BookmarkNode*, NodeIconURLComparator> |
+ NodesOrderedByIconURLSet; |
+ NodesOrderedByIconURLSet nodes_ordered_by_favicon_url_set_; |
sky
2015/06/15 14:40:54
If you're saying the favicons rarely change, then
pkotwicz
2015/06/15 14:50:21
I expect there to be 5 - 10 changes a day when syn
|
+ |
// Used for loading favicons. |
base::CancelableTaskTracker cancelable_task_tracker_; |