| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/containers/mru_cache.h" | 13 #include "base/containers/mru_cache.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "chrome/browser/history/archived_database.h" | 17 #include "chrome/browser/history/archived_database.h" |
| 18 #include "chrome/browser/history/expire_history_backend.h" | 18 #include "chrome/browser/history/expire_history_backend.h" |
| 19 #include "chrome/browser/history/history_database.h" | 19 #include "chrome/browser/history/history_database.h" |
| 20 #include "chrome/browser/history/history_marshaling.h" | 20 #include "chrome/browser/history/history_marshaling.h" |
| 21 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.h" |
| 22 #include "chrome/browser/history/text_database_manager.h" | |
| 23 #include "chrome/browser/history/thumbnail_database.h" | 22 #include "chrome/browser/history/thumbnail_database.h" |
| 24 #include "chrome/browser/history/visit_tracker.h" | 23 #include "chrome/browser/history/visit_tracker.h" |
| 25 #include "chrome/browser/search_engines/template_url_id.h" | 24 #include "chrome/browser/search_engines/template_url_id.h" |
| 26 #include "sql/init_status.h" | 25 #include "sql/init_status.h" |
| 27 #include "ui/base/layout.h" | 26 #include "ui/base/layout.h" |
| 28 | 27 |
| 29 class BookmarkService; | 28 class BookmarkService; |
| 30 class TestingProfile; | 29 class TestingProfile; |
| 31 class TypedUrlSyncableService; | 30 class TypedUrlSyncableService; |
| 32 struct ThumbnailScore; | 31 struct ThumbnailScore; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // The page can be identified by the combination of the pointer to | 153 // The page can be identified by the combination of the pointer to |
| 155 // a RenderProcessHost, the page id and the url. | 154 // a RenderProcessHost, the page id and the url. |
| 156 // | 155 // |
| 157 // The given pointer will not be dereferenced, it is only used for | 156 // The given pointer will not be dereferenced, it is only used for |
| 158 // identification purposes, hence it is a void*. | 157 // identification purposes, hence it is a void*. |
| 159 void UpdateWithPageEndTime(const void* host, | 158 void UpdateWithPageEndTime(const void* host, |
| 160 int32 page_id, | 159 int32 page_id, |
| 161 const GURL& url, | 160 const GURL& url, |
| 162 base::Time end_ts); | 161 base::Time end_ts); |
| 163 | 162 |
| 164 | |
| 165 // Indexing ------------------------------------------------------------------ | |
| 166 | |
| 167 void SetPageContents(const GURL& url, const string16& contents); | |
| 168 | |
| 169 // Querying ------------------------------------------------------------------ | 163 // Querying ------------------------------------------------------------------ |
| 170 | 164 |
| 171 // ScheduleAutocomplete() never frees |provider| (which is globally live). | 165 // ScheduleAutocomplete() never frees |provider| (which is globally live). |
| 172 // It passes |params| on to the autocomplete system which will eventually | 166 // It passes |params| on to the autocomplete system which will eventually |
| 173 // free it. | 167 // free it. |
| 174 void ScheduleAutocomplete(HistoryURLProvider* provider, | 168 void ScheduleAutocomplete(HistoryURLProvider* provider, |
| 175 HistoryURLProviderParams* params); | 169 HistoryURLProviderParams* params); |
| 176 | 170 |
| 177 void IterateURLs( | 171 void IterateURLs( |
| 178 const scoped_refptr<visitedlink::VisitedLinkDelegate::URLEnumerator>& | 172 const scoped_refptr<visitedlink::VisitedLinkDelegate::URLEnumerator>& |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 // The *Text() version performs a brute force query of the history DB to | 628 // The *Text() version performs a brute force query of the history DB to |
| 635 // search for results which match the given text query. | 629 // search for results which match the given text query. |
| 636 // Both functions assume QueryHistory already checked the DB for validity. | 630 // Both functions assume QueryHistory already checked the DB for validity. |
| 637 void QueryHistoryBasic(URLDatabase* url_db, VisitDatabase* visit_db, | 631 void QueryHistoryBasic(URLDatabase* url_db, VisitDatabase* visit_db, |
| 638 const QueryOptions& options, QueryResults* result); | 632 const QueryOptions& options, QueryResults* result); |
| 639 void QueryHistoryText(URLDatabase* url_db, | 633 void QueryHistoryText(URLDatabase* url_db, |
| 640 VisitDatabase* visit_db, | 634 VisitDatabase* visit_db, |
| 641 const string16& text_query, | 635 const string16& text_query, |
| 642 const QueryOptions& options, | 636 const QueryOptions& options, |
| 643 QueryResults* result); | 637 QueryResults* result); |
| 644 void QueryHistoryFTS(const string16& text_query, | |
| 645 const QueryOptions& options, | |
| 646 QueryResults* result); | |
| 647 | 638 |
| 648 // Committing ---------------------------------------------------------------- | 639 // Committing ---------------------------------------------------------------- |
| 649 | 640 |
| 650 // We always keep a transaction open on the history database so that multiple | 641 // We always keep a transaction open on the history database so that multiple |
| 651 // transactions can be batched. Periodically, these are flushed (use | 642 // transactions can be batched. Periodically, these are flushed (use |
| 652 // ScheduleCommit). This function does the commit to write any new changes to | 643 // ScheduleCommit). This function does the commit to write any new changes to |
| 653 // disk and opens a new transaction. This will be called automatically by | 644 // disk and opens a new transaction. This will be called automatically by |
| 654 // ScheduleCommit, or it can be called explicitly if a caller really wants | 645 // ScheduleCommit, or it can be called explicitly if a caller really wants |
| 655 // to write something to disk. | 646 // to write something to disk. |
| 656 void Commit(); | 647 void Commit(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 // vector to reference the new IDs. | 810 // vector to reference the new IDs. |
| 820 bool ClearAllThumbnailHistory(URLRows* kept_urls); | 811 bool ClearAllThumbnailHistory(URLRows* kept_urls); |
| 821 | 812 |
| 822 // Deletes all information in the history database, except for the supplied | 813 // Deletes all information in the history database, except for the supplied |
| 823 // set of URLs in the URL table (these should correspond to the bookmarked | 814 // set of URLs in the URL table (these should correspond to the bookmarked |
| 824 // URLs). | 815 // URLs). |
| 825 // | 816 // |
| 826 // The IDs of the URLs may change. | 817 // The IDs of the URLs may change. |
| 827 bool ClearAllMainHistory(const URLRows& kept_urls); | 818 bool ClearAllMainHistory(const URLRows& kept_urls); |
| 828 | 819 |
| 820 // Deletes the FTS index database files, which are no longer used. |
| 821 void DeleteFTSIndexDatabases(); |
| 822 |
| 829 // Returns the BookmarkService, blocking until it is loaded. This may return | 823 // Returns the BookmarkService, blocking until it is loaded. This may return |
| 830 // NULL during testing. | 824 // NULL during testing. |
| 831 BookmarkService* GetBookmarkService(); | 825 BookmarkService* GetBookmarkService(); |
| 832 | 826 |
| 833 // Notify any observers of an addition to the visit database. | 827 // Notify any observers of an addition to the visit database. |
| 834 void NotifyVisitObservers(const VisitRow& visit); | 828 void NotifyVisitObservers(const VisitRow& visit); |
| 835 | 829 |
| 836 // Data ---------------------------------------------------------------------- | 830 // Data ---------------------------------------------------------------------- |
| 837 | 831 |
| 838 // Delegate. See the class definition above for more information. This will | 832 // Delegate. See the class definition above for more information. This will |
| (...skipping 11 matching lines...) Expand all Loading... |
| 850 // The history/thumbnail databases. Either MAY BE NULL if the database could | 844 // The history/thumbnail databases. Either MAY BE NULL if the database could |
| 851 // not be opened, all users must first check for NULL and return immediately | 845 // not be opened, all users must first check for NULL and return immediately |
| 852 // if it is. The thumbnail DB may be NULL when the history one isn't, but not | 846 // if it is. The thumbnail DB may be NULL when the history one isn't, but not |
| 853 // vice-versa. | 847 // vice-versa. |
| 854 scoped_ptr<HistoryDatabase> db_; | 848 scoped_ptr<HistoryDatabase> db_; |
| 855 scoped_ptr<ThumbnailDatabase> thumbnail_db_; | 849 scoped_ptr<ThumbnailDatabase> thumbnail_db_; |
| 856 | 850 |
| 857 // Stores old history in a larger, slower database. | 851 // Stores old history in a larger, slower database. |
| 858 scoped_ptr<ArchivedDatabase> archived_db_; | 852 scoped_ptr<ArchivedDatabase> archived_db_; |
| 859 | 853 |
| 860 // Full text database manager, possibly NULL if the database could not be | |
| 861 // created. | |
| 862 scoped_ptr<TextDatabaseManager> text_database_; | |
| 863 | |
| 864 // Manages expiration between the various databases. | 854 // Manages expiration between the various databases. |
| 865 ExpireHistoryBackend expirer_; | 855 ExpireHistoryBackend expirer_; |
| 866 | 856 |
| 867 // A commit has been scheduled to occur sometime in the future. We can check | 857 // A commit has been scheduled to occur sometime in the future. We can check |
| 868 // non-null-ness to see if there is a commit scheduled in the future, and we | 858 // non-null-ness to see if there is a commit scheduled in the future, and we |
| 869 // can use the pointer to cancel the scheduled commit. There can be only one | 859 // can use the pointer to cancel the scheduled commit. There can be only one |
| 870 // scheduled commit at a time (see ScheduleCommit). | 860 // scheduled commit at a time (see ScheduleCommit). |
| 871 scoped_refptr<CommitLaterTask> scheduled_commit_; | 861 scoped_refptr<CommitLaterTask> scheduled_commit_; |
| 872 | 862 |
| 873 // Maps recent redirect destination pages to the chain of redirects that | 863 // Maps recent redirect destination pages to the chain of redirects that |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 // Used to manage syncing of the typed urls datatype. This will be NULL | 909 // Used to manage syncing of the typed urls datatype. This will be NULL |
| 920 // before Init is called. | 910 // before Init is called. |
| 921 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; | 911 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; |
| 922 | 912 |
| 923 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 913 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
| 924 }; | 914 }; |
| 925 | 915 |
| 926 } // namespace history | 916 } // namespace history |
| 927 | 917 |
| 928 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 918 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
| OLD | NEW |