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 CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 | 165 |
166 // Init must be called to complete object creation. This object can be | 166 // Init must be called to complete object creation. This object can be |
167 // constructed on any thread, but all other functions including Init() must | 167 // constructed on any thread, but all other functions including Init() must |
168 // be called on the history thread. | 168 // be called on the history thread. |
169 // | 169 // |
170 // |history_dir| is the directory where the history files will be placed. | 170 // |history_dir| is the directory where the history files will be placed. |
171 // See the definition of BroadcastNotificationsCallback above. This function | 171 // See the definition of BroadcastNotificationsCallback above. This function |
172 // takes ownership of the callback pointer. | 172 // takes ownership of the callback pointer. |
173 // | 173 // |
174 // |history_client| is used to determine bookmarked URLs when deleting and | 174 // |history_client| is used to determine bookmarked URLs when deleting and |
175 // may be NULL. | 175 // may be null. |
176 // | 176 // |
177 // This constructor is fast and does no I/O, so can be called at any time. | 177 // This constructor is fast and does no I/O, so can be called at any time. |
178 HistoryBackend(const base::FilePath& history_dir, | 178 HistoryBackend(Delegate* delegate, HistoryClient* history_client); |
179 Delegate* delegate, | |
180 HistoryClient* history_client); | |
181 | 179 |
182 // Must be called after creation but before any objects are created. If this | 180 // Must be called after creation but before any objects are created. If this |
183 // fails, all other functions will fail as well. (Since this runs on another | 181 // fails, all other functions will fail as well. (Since this runs on another |
184 // thread, we don't bother returning failure.) | 182 // thread, we don't bother returning failure.) |
185 // | 183 // |
186 // |languages| gives a list of language encodings with which the history | 184 // |languages| gives a list of language encodings with which the history |
187 // URLs and omnibox searches are interpreted. | 185 // URLs and omnibox searches are interpreted. |
188 // |force_fail| can be set during unittests to unconditionally fail to init. | 186 // |force_fail| can be set during unittests to unconditionally fail to init. |
189 void Init(const std::string& languages, | 187 void Init(const std::string& languages, |
190 bool force_fail, | 188 bool force_fail, |
(...skipping 13 matching lines...) Expand all Loading... | |
204 virtual void SetPageTitle(const GURL& url, const base::string16& title); | 202 virtual void SetPageTitle(const GURL& url, const base::string16& title); |
205 void AddPageNoVisitForBookmark(const GURL& url, const base::string16& title); | 203 void AddPageNoVisitForBookmark(const GURL& url, const base::string16& title); |
206 void UpdateWithPageEndTime(ContextID context_id, | 204 void UpdateWithPageEndTime(ContextID context_id, |
207 int nav_entry_id, | 205 int nav_entry_id, |
208 const GURL& url, | 206 const GURL& url, |
209 base::Time end_ts); | 207 base::Time end_ts); |
210 | 208 |
211 // Querying ------------------------------------------------------------------ | 209 // Querying ------------------------------------------------------------------ |
212 | 210 |
213 // Run the |callback| on the History thread. | 211 // Run the |callback| on the History thread. |
214 // |callback| should handle the NULL database case. | 212 // |callback| should handle the null database case. |
215 void ScheduleAutocomplete(const base::Callback< | 213 void ScheduleAutocomplete(const base::Callback< |
216 void(history::HistoryBackend*, history::URLDatabase*)>& callback); | 214 void(history::HistoryBackend*, history::URLDatabase*)>& callback); |
217 | 215 |
218 void QueryURL(const GURL& url, | 216 void QueryURL(const GURL& url, |
219 bool want_visits, | 217 bool want_visits, |
220 QueryURLResult* query_url_result); | 218 QueryURLResult* query_url_result); |
221 void QueryHistory(const base::string16& text_query, | 219 void QueryHistory(const base::string16& text_query, |
222 const QueryOptions& options, | 220 const QueryOptions& options, |
223 QueryResults* query_results); | 221 QueryResults* query_results); |
224 | 222 |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 bool expired, | 720 bool expired, |
723 const URLRows& rows, | 721 const URLRows& rows, |
724 const std::set<GURL>& favicon_urls) override; | 722 const std::set<GURL>& favicon_urls) override; |
725 | 723 |
726 // Deleting all history ------------------------------------------------------ | 724 // Deleting all history ------------------------------------------------------ |
727 | 725 |
728 // Deletes all history. This is a special case of deleting that is separated | 726 // Deletes all history. This is a special case of deleting that is separated |
729 // from our normal dependency-following method for performance reasons. The | 727 // from our normal dependency-following method for performance reasons. The |
730 // logic lives here instead of ExpireHistoryBackend since it will cause | 728 // logic lives here instead of ExpireHistoryBackend since it will cause |
731 // re-initialization of some databases (e.g. Thumbnails) that could fail. | 729 // re-initialization of some databases (e.g. Thumbnails) that could fail. |
732 // When these databases are not valid, our pointers must be NULL, so we need | 730 // When these databases are not valid, our pointers must be null, so we need |
733 // to handle this type of operation to keep the pointers in sync. | 731 // to handle this type of operation to keep the pointers in sync. |
734 void DeleteAllHistory(); | 732 void DeleteAllHistory(); |
735 | 733 |
736 // Given a vector of all URLs that we will keep, removes all thumbnails | 734 // Given a vector of all URLs that we will keep, removes all thumbnails |
737 // referenced by any URL, and also all favicons that aren't used by those | 735 // referenced by any URL, and also all favicons that aren't used by those |
738 // URLs. | 736 // URLs. |
739 bool ClearAllThumbnailHistory(const URLRows& kept_urls); | 737 bool ClearAllThumbnailHistory(const URLRows& kept_urls); |
740 | 738 |
741 // Deletes all information in the history database, except for the supplied | 739 // Deletes all information in the history database, except for the supplied |
742 // set of URLs in the URL table (these should correspond to the bookmarked | 740 // set of URLs in the URL table (these should correspond to the bookmarked |
743 // URLs). | 741 // URLs). |
744 // | 742 // |
745 // The IDs of the URLs may change. | 743 // The IDs of the URLs may change. |
746 bool ClearAllMainHistory(const URLRows& kept_urls); | 744 bool ClearAllMainHistory(const URLRows& kept_urls); |
747 | 745 |
748 // Deletes the FTS index database files, which are no longer used. | 746 // Deletes the FTS index database files, which are no longer used. |
749 void DeleteFTSIndexDatabases(); | 747 void DeleteFTSIndexDatabases(); |
750 | 748 |
751 // Returns the HistoryClient, blocking until the bookmarks are loaded. This | 749 // Returns the HistoryClient, blocking until the bookmarks are loaded. This |
752 // may return NULL during testing. | 750 // may return null during testing. |
753 HistoryClient* GetHistoryClient(); | 751 HistoryClient* GetHistoryClient(); |
754 | 752 |
755 // Notify any observers of an addition to the visit database. | 753 // Notify any observers of an addition to the visit database. |
756 void NotifyVisitObservers(const VisitRow& visit); | 754 void NotifyVisitObservers(const VisitRow& visit); |
757 | 755 |
758 // Data ---------------------------------------------------------------------- | 756 // Data ---------------------------------------------------------------------- |
759 | 757 |
760 // Delegate. See the class definition above for more information. This will | 758 // Delegate. See the class definition above for more information. This will |
761 // be NULL before Init is called and after Cleanup, but is guaranteed | 759 // be null before Init is called and after Cleanup, but is guaranteed |
762 // non-NULL in between. | 760 // non-null in between. |
763 scoped_ptr<Delegate> delegate_; | 761 scoped_ptr<Delegate> delegate_; |
764 | 762 |
765 // Directory where database files will be stored. | 763 // Directory where database files will be stored, empty until Init is called. |
766 base::FilePath history_dir_; | 764 base::FilePath history_dir_; |
767 | 765 |
768 // The history/thumbnail databases. Either MAY BE NULL if the database could | 766 // The history/thumbnail databases. Either may be null if the database could |
769 // not be opened, all users must first check for NULL and return immediately | 767 // not be opened, all users must first check for null and return immediately |
770 // if it is. The thumbnail DB may be NULL when the history one isn't, but not | 768 // if it is. The thumbnail DB may be null when the history one isn't, but not |
771 // vice-versa. | 769 // vice-versa. |
772 scoped_ptr<HistoryDatabase> db_; | 770 scoped_ptr<HistoryDatabase> db_; |
773 bool scheduled_kill_db_; // Database is being killed due to error. | 771 bool scheduled_kill_db_; // Database is being killed due to error. |
774 scoped_ptr<ThumbnailDatabase> thumbnail_db_; | 772 scoped_ptr<ThumbnailDatabase> thumbnail_db_; |
775 | 773 |
776 // Manages expiration between the various databases. | 774 // Manages expiration between the various databases. |
777 ExpireHistoryBackend expirer_; | 775 ExpireHistoryBackend expirer_; |
778 | 776 |
779 // A commit has been scheduled to occur sometime in the future. We can check | 777 // A commit has been scheduled to occur sometime in the future. We can check |
780 // non-null-ness to see if there is a commit scheduled in the future, and we | 778 // non-null-ness to see if there is a commit scheduled in the future, and we |
(...skipping 23 matching lines...) Expand all Loading... | |
804 // Tracks page transition types. | 802 // Tracks page transition types. |
805 VisitTracker tracker_; | 803 VisitTracker tracker_; |
806 | 804 |
807 // A boolean variable to track whether we have already purged obsolete segment | 805 // A boolean variable to track whether we have already purged obsolete segment |
808 // data. | 806 // data. |
809 bool segment_queried_; | 807 bool segment_queried_; |
810 | 808 |
811 // List of QueuedHistoryDBTasks to run; | 809 // List of QueuedHistoryDBTasks to run; |
812 std::list<QueuedHistoryDBTask*> queued_history_db_tasks_; | 810 std::list<QueuedHistoryDBTask*> queued_history_db_tasks_; |
813 | 811 |
814 // Used to determine if a URL is bookmarked; may be NULL. | 812 // Used to determine if a URL is bookmarked; may be null. |
815 // | 813 // |
816 // Use GetHistoryClient to access this, which makes sure the bookmarks are | 814 // Use GetHistoryClient to access this, which makes sure the bookmarks are |
817 // loaded before returning. | 815 // loaded before returning. |
818 HistoryClient* history_client_; | 816 HistoryClient* history_client_; |
819 | 817 |
820 #if defined(OS_ANDROID) | 818 #if defined(OS_ANDROID) |
821 // Used to provide the Android ContentProvider APIs. | 819 // Used to provide the Android ContentProvider APIs. |
822 scoped_ptr<AndroidProviderBackend> android_provider_backend_; | 820 scoped_ptr<AndroidProviderBackend> android_provider_backend_; |
823 #endif | 821 #endif |
824 | 822 |
825 // Used to manage syncing of the typed urls datatype. This will be NULL | 823 // Used to manage syncing of the typed urls datatype. This will be null before |
826 // before Init is called. | 824 // Init is called. |
noyau (Ping after 24h)
2015/02/20 18:57:31
you removed the todo without removing the instance
sdefresne
2015/02/23 10:27:17
Yes, The interface of TypedUrlSyncableService is s
| |
827 // TODO(sdefresne): turn TypedUrlSyncableService into a HistoryBackendObserver | |
828 // and remove this field since it is only used for forwarding notifications | |
829 // about URL visited, modified, deleted. | |
830 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; | 825 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; |
831 | 826 |
832 // Listens for the system being under memory pressure. | 827 // Listens for the system being under memory pressure. |
833 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 828 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
834 | 829 |
835 // List of observers | 830 // List of observers |
836 ObserverList<HistoryBackendObserver> observers_; | 831 ObserverList<HistoryBackendObserver> observers_; |
837 | 832 |
838 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 833 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
839 }; | 834 }; |
840 | 835 |
841 } // namespace history | 836 } // namespace history |
842 | 837 |
843 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 838 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |