Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: components/bookmarks/browser/bookmark_model.h

Issue 1133463005: Update all bookmarks which use an icon URL when a favicon's bitmap is updated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@startup_do_not_unexpire
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/bookmarks/DEPS ('k') | components/bookmarks/browser/bookmark_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 // Sets the URL of |node|. 160 // Sets the URL of |node|.
161 void SetURL(const BookmarkNode* node, const GURL& url); 161 void SetURL(const BookmarkNode* node, const GURL& url);
162 162
163 // Sets the date added time of |node|. 163 // Sets the date added time of |node|.
164 void SetDateAdded(const BookmarkNode* node, base::Time date_added); 164 void SetDateAdded(const BookmarkNode* node, base::Time date_added);
165 165
166 // Returns the set of nodes with the |url|. 166 // Returns the set of nodes with the |url|.
167 void GetNodesByURL(const GURL& url, std::vector<const BookmarkNode*>* nodes); 167 void GetNodesByURL(const GURL& url, std::vector<const BookmarkNode*>* nodes);
168 168
169 // Returns the set of nodes which use the favicon at |icon_url|.
170 void GetNodesByIconURL(const GURL& icon_url,
171 std::vector<const BookmarkNode*>* nodes);
172
169 // Returns the most recently added user node for the |url|; urls from any 173 // Returns the most recently added user node for the |url|; urls from any
170 // nodes that are not editable by the user are never returned by this call. 174 // nodes that are not editable by the user are never returned by this call.
171 // Returns NULL if |url| is not bookmarked. 175 // Returns NULL if |url| is not bookmarked.
172 const BookmarkNode* GetMostRecentlyAddedUserNodeForURL(const GURL& url); 176 const BookmarkNode* GetMostRecentlyAddedUserNodeForURL(const GURL& url);
173 177
174 // Returns true if there are bookmarks, otherwise returns false. 178 // Returns true if there are bookmarks, otherwise returns false.
175 // This method is thread safe. 179 // This method is thread safe.
176 bool HasBookmarks(); 180 bool HasBookmarks();
177 181
178 // Returns true if the specified URL is bookmarked. 182 // Returns true if the specified URL is bookmarked.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Returns the set of meta info keys that should not be copied when a node is 293 // Returns the set of meta info keys that should not be copied when a node is
290 // cloned. 294 // cloned.
291 const std::set<std::string>& non_cloned_keys() const { 295 const std::set<std::string>& non_cloned_keys() const {
292 return non_cloned_keys_; 296 return non_cloned_keys_;
293 } 297 }
294 298
295 // Sets the sync transaction version of |node|. 299 // Sets the sync transaction version of |node|.
296 void SetNodeSyncTransactionVersion(const BookmarkNode* node, 300 void SetNodeSyncTransactionVersion(const BookmarkNode* node,
297 int64 sync_transaction_version); 301 int64 sync_transaction_version);
298 302
299 // Notify BookmarkModel that the favicons for |urls| have changed and have to 303 // Notify BookmarkModel that the favicons for the given page URLs
304 // (e.g. http://www.google.com) and the given icon URLs (e.g.
305 // http://www.google.com/favicon.ico) have changed and have to
300 // be refetched. This notification is sent by BookmarkClient. 306 // be refetched. This notification is sent by BookmarkClient.
301 void OnFaviconChanged(const std::set<GURL>& urls); 307 void OnFaviconsChanged(const std::vector<GURL>& page_urls,
308 const std::vector<GURL>& icon_urls);
302 309
303 // Returns the client used by this BookmarkModel. 310 // Returns the client used by this BookmarkModel.
304 BookmarkClient* client() const { return client_; } 311 BookmarkClient* client() const { return client_; }
305 312
306 private: 313 private:
307 friend class BookmarkCodecTest; 314 friend class BookmarkCodecTest;
315 friend class BookmarkModelTest;
308 friend class BookmarkStorage; 316 friend class BookmarkStorage;
309 friend class ScopedGroupBookmarkActions; 317 friend class ScopedGroupBookmarkActions;
310 friend class TestBookmarkClient; 318 friend class TestBookmarkClient;
311 319
312 // Used to order BookmarkNodes by URL. 320 // Used to order BookmarkNodes by URL.
313 class NodeURLComparator { 321 class NodeURLComparator {
314 public: 322 public:
315 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) const { 323 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) const {
316 return n1->url() < n2->url(); 324 return n1->url() < n2->url();
317 } 325 }
318 }; 326 };
319 327
328 // Used to order BookmarkNodes by icon URL.
329 class NodeIconURLComparator {
330 public:
331 bool operator()(const BookmarkNode* n1, BookmarkNode* n2) const {
332 return n1->icon_url() < n2->icon_url();
333 }
334 };
335
320 // Implementation of IsBookmarked. Before calling this the caller must obtain 336 // Implementation of IsBookmarked. Before calling this the caller must obtain
321 // a lock on |url_lock_|. 337 // a lock on |url_lock_|.
322 bool IsBookmarkedNoLock(const GURL& url); 338 bool IsBookmarkedNoLock(const GURL& url);
323 339
324 // Removes the node from internal maps and recurses through all children. If 340 // Removes the node from internal maps and recurses through all children. If
325 // the node is a url, its url is added to removed_urls. 341 // the node is a url, its url is added to removed_urls.
326 // 342 //
327 // This does NOT delete the node. 343 // This does NOT delete the node.
328 void RemoveNode(BookmarkNode* node, std::set<GURL>* removed_urls); 344 void RemoveNode(BookmarkNode* node, std::set<GURL>* removed_urls);
329 345
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 favicon_base::IconType icon_type, 387 favicon_base::IconType icon_type,
372 const favicon_base::FaviconImageResult& image_result); 388 const favicon_base::FaviconImageResult& image_result);
373 389
374 // Invoked from the node to load the favicon. Requests the favicon from the 390 // Invoked from the node to load the favicon. Requests the favicon from the
375 // favicon service. 391 // favicon service.
376 void LoadFavicon(BookmarkNode* node, favicon_base::IconType icon_type); 392 void LoadFavicon(BookmarkNode* node, favicon_base::IconType icon_type);
377 393
378 // Called to notify the observers that the favicon has been loaded. 394 // Called to notify the observers that the favicon has been loaded.
379 void FaviconLoaded(const BookmarkNode* node); 395 void FaviconLoaded(const BookmarkNode* node);
380 396
397 // Sets |node|'s favicon URL.
398 void SetFaviconURL(BookmarkNode* node, const GURL& icon_url);
399
400 // Clear |node|'s favicon data. Also cancel's any pending favicon load
401 // requests for |node|.
402 void InvalidateFavicon(BookmarkNode* node);
403
381 // If we're waiting on a favicon for node, the load request is canceled. 404 // If we're waiting on a favicon for node, the load request is canceled.
382 void CancelPendingFaviconLoadRequests(BookmarkNode* node); 405 void CancelPendingFaviconLoadRequests(BookmarkNode* node);
383 406
384 // Notifies the observers that a set of changes initiated by a single user 407 // Notifies the observers that a set of changes initiated by a single user
385 // action is about to happen and has completed. 408 // action is about to happen and has completed.
386 void BeginGroupedChanges(); 409 void BeginGroupedChanges();
387 void EndGroupedChanges(); 410 void EndGroupedChanges();
388 411
389 // Generates and returns the next node ID. 412 // Generates and returns the next node ID.
390 int64 generate_next_node_id(); 413 int64 generate_next_node_id();
(...skipping 28 matching lines...) Expand all
419 ObserverList<BookmarkModelObserver> observers_; 442 ObserverList<BookmarkModelObserver> observers_;
420 443
421 // Set of nodes ordered by URL. This is not a map to avoid copying the 444 // Set of nodes ordered by URL. This is not a map to avoid copying the
422 // urls. 445 // urls.
423 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As 446 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As
424 // such, be sure and wrap all usage of it around |url_lock_|. 447 // such, be sure and wrap all usage of it around |url_lock_|.
425 typedef std::multiset<BookmarkNode*, NodeURLComparator> NodesOrderedByURLSet; 448 typedef std::multiset<BookmarkNode*, NodeURLComparator> NodesOrderedByURLSet;
426 NodesOrderedByURLSet nodes_ordered_by_url_set_; 449 NodesOrderedByURLSet nodes_ordered_by_url_set_;
427 base::Lock url_lock_; 450 base::Lock url_lock_;
428 451
452 // Set of nodes ordered by favicon URL. Does not contain nodes whose favicon
453 // has not been loaded or which do not have a favicon.
454 // WARNING: Only access from the UI thread.
455 typedef std::multiset<BookmarkNode*, NodeIconURLComparator>
456 NodesOrderedByIconURLSet;
457 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
458
429 // Used for loading favicons. 459 // Used for loading favicons.
430 base::CancelableTaskTracker cancelable_task_tracker_; 460 base::CancelableTaskTracker cancelable_task_tracker_;
431 461
432 // Reads/writes bookmarks to disk. 462 // Reads/writes bookmarks to disk.
433 scoped_ptr<BookmarkStorage> store_; 463 scoped_ptr<BookmarkStorage> store_;
434 464
435 scoped_ptr<BookmarkIndex> index_; 465 scoped_ptr<BookmarkIndex> index_;
436 466
437 base::WaitableEvent loaded_signal_; 467 base::WaitableEvent loaded_signal_;
438 468
439 // See description of IsDoingExtensiveChanges above. 469 // See description of IsDoingExtensiveChanges above.
440 int extensive_changes_; 470 int extensive_changes_;
441 471
442 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 472 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
443 473
444 std::set<std::string> non_cloned_keys_; 474 std::set<std::string> non_cloned_keys_;
445 475
446 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 476 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
447 }; 477 };
448 478
449 } // namespace bookmarks 479 } // namespace bookmarks
450 480
451 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ 481 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
OLDNEW
« no previous file with comments | « components/bookmarks/DEPS ('k') | components/bookmarks/browser/bookmark_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698