OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // Sets the in-memory history backend. The in-memory backend is created by | 113 // Sets the in-memory history backend. The in-memory backend is created by |
114 // the main backend. For non-unit tests, this happens on the background | 114 // the main backend. For non-unit tests, this happens on the background |
115 // thread. It is to be used on the main thread, so this would transfer | 115 // thread. It is to be used on the main thread, so this would transfer |
116 // it to the history service. Unit tests can override this behavior. | 116 // it to the history service. Unit tests can override this behavior. |
117 // | 117 // |
118 // This function is NOT guaranteed to be called. If there is an error, | 118 // This function is NOT guaranteed to be called. If there is an error, |
119 // there may be no in-memory database. | 119 // there may be no in-memory database. |
120 virtual void SetInMemoryBackend( | 120 virtual void SetInMemoryBackend( |
121 scoped_ptr<InMemoryHistoryBackend> backend) = 0; | 121 scoped_ptr<InMemoryHistoryBackend> backend) = 0; |
122 | 122 |
123 // Notify HistoryService that some URLs favicon changed that will forward | 123 // Notify HistoryService that the favicons for the given page URLs (e.g. |
124 // the events to the FaviconChangedObservers in the correct thread. | 124 // http://www.google.com) and the given icon URLs (e.g. |
125 virtual void NotifyFaviconChanged(const std::set<GURL>& urls) = 0; | 125 // http://www.google.com/favicon.ico) have changed. HistoryService notifies |
| 126 // any registered callbacks. |
| 127 virtual void NotifyFaviconsChanged(const std::vector<GURL>& page_urls, |
| 128 const std::vector<GURL>& icon_urls) = 0; |
126 | 129 |
127 // Notify HistoryService that the user is visiting an URL. The event will | 130 // Notify HistoryService that the user is visiting an URL. The event will |
128 // be forwarded to the HistoryServiceObservers in the correct thread. | 131 // be forwarded to the HistoryServiceObservers in the correct thread. |
129 virtual void NotifyURLVisited(ui::PageTransition transition, | 132 virtual void NotifyURLVisited(ui::PageTransition transition, |
130 const URLRow& row, | 133 const URLRow& row, |
131 const RedirectList& redirects, | 134 const RedirectList& redirects, |
132 base::Time visit_time) = 0; | 135 base::Time visit_time) = 0; |
133 | 136 |
134 // Notify HistoryService that some URLs have been modified. The event will | 137 // Notify HistoryService that some URLs have been modified. The event will |
135 // be forwarded to the HistoryServiceObservers in the correct thread. | 138 // be forwarded to the HistoryServiceObservers in the correct thread. |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 488 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
486 UpdateFaviconMappingsAndFetchNoChange); | 489 UpdateFaviconMappingsAndFetchNoChange); |
487 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLNotInDB); | 490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLNotInDB); |
488 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLInDB); | 491 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLInDB); |
489 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconMaxFaviconsPerPage); | 492 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconMaxFaviconsPerPage); |
490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 493 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
491 MergeFaviconIconURLMappedToDifferentPageURL); | 494 MergeFaviconIconURLMappedToDifferentPageURL); |
492 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 495 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
493 MergeFaviconMaxFaviconBitmapsPerIconURL); | 496 MergeFaviconMaxFaviconBitmapsPerIconURL); |
494 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 497 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
| 498 FaviconChangedNotificationNewFavicon); |
| 499 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
| 500 FaviconChangedNotificationBitmapDataChanged); |
| 501 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
| 502 FaviconChangedNotificationIconMappingChanged); |
| 503 FRIEND_TEST_ALL_PREFIXES( |
| 504 HistoryBackendTest, |
| 505 FaviconChangedNotificationIconMappingAndBitmapDataChanged); |
| 506 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
| 507 FaviconChangedNotificationsMergeCopy); |
| 508 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, NoFaviconChangedNotifications); |
| 509 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
495 UpdateFaviconMappingsAndFetchMultipleIconTypes); | 510 UpdateFaviconMappingsAndFetchMultipleIconTypes); |
496 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty); | 511 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty); |
497 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 512 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
498 GetFaviconsFromDBNoFaviconBitmaps); | 513 GetFaviconsFromDBNoFaviconBitmaps); |
499 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 514 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
500 GetFaviconsFromDBSelectClosestMatch); | 515 GetFaviconsFromDBSelectClosestMatch); |
501 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType); | 516 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType); |
502 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); | 517 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); |
503 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 518 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
504 UpdateFaviconMappingsAndFetchNoDB); | 519 UpdateFaviconMappingsAndFetchNoDB); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 const GURL& page_url, | 699 const GURL& page_url, |
685 favicon_base::IconType icon_type, | 700 favicon_base::IconType icon_type, |
686 const std::vector<favicon_base::FaviconID>& icon_ids); | 701 const std::vector<favicon_base::FaviconID>& icon_ids); |
687 | 702 |
688 // Returns all the page URLs in the redirect chain for |page_url|. If there | 703 // Returns all the page URLs in the redirect chain for |page_url|. If there |
689 // are no known redirects for |page_url|, returns a vector with |page_url|. | 704 // are no known redirects for |page_url|, returns a vector with |page_url|. |
690 void GetCachedRecentRedirects(const GURL& page_url, | 705 void GetCachedRecentRedirects(const GURL& page_url, |
691 RedirectList* redirect_list); | 706 RedirectList* redirect_list); |
692 | 707 |
693 // Send notification that the favicon has changed for |page_url| and all its | 708 // Send notification that the favicon has changed for |page_url| and all its |
694 // redirects. | 709 // redirects. This should be called if the mapping between the page URL |
| 710 // (e.g. http://www.google.com) and the icon URL (e.g. |
| 711 // http://www.google.com/favicon.ico) has changed. |
695 void SendFaviconChangedNotificationForPageAndRedirects(const GURL& page_url); | 712 void SendFaviconChangedNotificationForPageAndRedirects(const GURL& page_url); |
696 | 713 |
| 714 // Send notification that the bitmap data for the favicon at |icon_url| has |
| 715 // changed. Sending this notification is important because the favicon at |
| 716 // |icon_url| may be mapped to hundreds of page URLs. |
| 717 void SendFaviconChangedNotificationForIconURL(const GURL& icon_url); |
| 718 |
697 // Generic stuff ------------------------------------------------------------- | 719 // Generic stuff ------------------------------------------------------------- |
698 | 720 |
699 // Processes the next scheduled HistoryDBTask, scheduling this method | 721 // Processes the next scheduled HistoryDBTask, scheduling this method |
700 // to be invoked again if there are more tasks that need to run. | 722 // to be invoked again if there are more tasks that need to run. |
701 void ProcessDBTaskImpl(); | 723 void ProcessDBTaskImpl(); |
702 | 724 |
703 // HistoryBackendNotifier: | 725 // HistoryBackendNotifier: |
704 void NotifyFaviconChanged(const std::set<GURL>& urls) override; | 726 void NotifyFaviconsChanged(const std::vector<GURL>& page_urls, |
| 727 const std::vector<GURL>& icon_urls) override; |
705 void NotifyURLVisited(ui::PageTransition transition, | 728 void NotifyURLVisited(ui::PageTransition transition, |
706 const URLRow& row, | 729 const URLRow& row, |
707 const RedirectList& redirects, | 730 const RedirectList& redirects, |
708 base::Time visit_time) override; | 731 base::Time visit_time) override; |
709 void NotifyURLsModified(const URLRows& rows) override; | 732 void NotifyURLsModified(const URLRows& rows) override; |
710 void NotifyURLsDeleted(bool all_history, | 733 void NotifyURLsDeleted(bool all_history, |
711 bool expired, | 734 bool expired, |
712 const URLRows& rows, | 735 const URLRows& rows, |
713 const std::set<GURL>& favicon_urls) override; | 736 const std::set<GURL>& favicon_urls) override; |
714 | 737 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 | 840 |
818 // List of observers | 841 // List of observers |
819 ObserverList<HistoryBackendObserver> observers_; | 842 ObserverList<HistoryBackendObserver> observers_; |
820 | 843 |
821 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 844 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
822 }; | 845 }; |
823 | 846 |
824 } // namespace history | 847 } // namespace history |
825 | 848 |
826 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 849 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
OLD | NEW |