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/memory_pressure_listener.h" | 16 #include "base/memory/memory_pressure_listener.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "chrome/browser/history/archived_database.h" | 18 #include "chrome/browser/history/archived_database.h" |
19 #include "chrome/browser/history/expire_history_backend.h" | 19 #include "chrome/browser/history/expire_history_backend.h" |
20 #include "chrome/browser/history/history_database.h" | 20 #include "chrome/browser/history/history_database.h" |
21 #include "chrome/browser/history/history_marshaling.h" | 21 #include "chrome/browser/history/history_marshaling.h" |
22 #include "chrome/browser/history/history_types.h" | 22 #include "chrome/browser/history/history_types.h" |
23 #include "chrome/browser/history/text_database_manager.h" | |
24 #include "chrome/browser/history/thumbnail_database.h" | 23 #include "chrome/browser/history/thumbnail_database.h" |
25 #include "chrome/browser/history/visit_tracker.h" | 24 #include "chrome/browser/history/visit_tracker.h" |
26 #include "chrome/browser/search_engines/template_url_id.h" | 25 #include "chrome/browser/search_engines/template_url_id.h" |
27 #include "sql/init_status.h" | 26 #include "sql/init_status.h" |
28 #include "ui/base/layout.h" | 27 #include "ui/base/layout.h" |
29 | 28 |
30 class BookmarkService; | 29 class BookmarkService; |
31 class TestingProfile; | 30 class TestingProfile; |
32 class TypedUrlSyncableService; | 31 class TypedUrlSyncableService; |
33 struct ThumbnailScore; | 32 struct ThumbnailScore; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // The page can be identified by the combination of the pointer to | 154 // The page can be identified by the combination of the pointer to |
156 // a RenderProcessHost, the page id and the url. | 155 // a RenderProcessHost, the page id and the url. |
157 // | 156 // |
158 // The given pointer will not be dereferenced, it is only used for | 157 // The given pointer will not be dereferenced, it is only used for |
159 // identification purposes, hence it is a void*. | 158 // identification purposes, hence it is a void*. |
160 void UpdateWithPageEndTime(const void* host, | 159 void UpdateWithPageEndTime(const void* host, |
161 int32 page_id, | 160 int32 page_id, |
162 const GURL& url, | 161 const GURL& url, |
163 base::Time end_ts); | 162 base::Time end_ts); |
164 | 163 |
165 | |
166 // Indexing ------------------------------------------------------------------ | |
167 | |
168 void SetPageContents(const GURL& url, const string16& contents); | |
169 | |
170 // Querying ------------------------------------------------------------------ | 164 // Querying ------------------------------------------------------------------ |
171 | 165 |
172 // ScheduleAutocomplete() never frees |provider| (which is globally live). | 166 // ScheduleAutocomplete() never frees |provider| (which is globally live). |
173 // It passes |params| on to the autocomplete system which will eventually | 167 // It passes |params| on to the autocomplete system which will eventually |
174 // free it. | 168 // free it. |
175 void ScheduleAutocomplete(HistoryURLProvider* provider, | 169 void ScheduleAutocomplete(HistoryURLProvider* provider, |
176 HistoryURLProviderParams* params); | 170 HistoryURLProviderParams* params); |
177 | 171 |
178 void IterateURLs( | 172 void IterateURLs( |
179 const scoped_refptr<visitedlink::VisitedLinkDelegate::URLEnumerator>& | 173 const scoped_refptr<visitedlink::VisitedLinkDelegate::URLEnumerator>& |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBSingleIconURL); | 551 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBSingleIconURL); |
558 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType); | 552 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType); |
559 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); | 553 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); |
560 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 554 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
561 UpdateFaviconMappingsAndFetchNoDB); | 555 UpdateFaviconMappingsAndFetchNoDB); |
562 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 556 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
563 CloneFaviconIsRestrictedToSameDomain); | 557 CloneFaviconIsRestrictedToSameDomain); |
564 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); | 558 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); |
565 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); | 559 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); |
566 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes); | 560 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes); |
| 561 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases); |
567 | 562 |
568 friend class ::TestingProfile; | 563 friend class ::TestingProfile; |
569 | 564 |
570 // Computes the name of the specified database on disk. | 565 // Computes the name of the specified database on disk. |
571 base::FilePath GetThumbnailFileName() const; | 566 base::FilePath GetThumbnailFileName() const; |
572 | 567 |
573 // Returns the name of the Favicons database. This is the new name | 568 // Returns the name of the Favicons database. This is the new name |
574 // of the Thumbnails database. | 569 // of the Thumbnails database. |
575 // See ThumbnailDatabase::RenameAndDropThumbnails. | 570 // See ThumbnailDatabase::RenameAndDropThumbnails. |
576 base::FilePath GetFaviconsFileName() const; | 571 base::FilePath GetFaviconsFileName() const; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 // The *Text() version performs a brute force query of the history DB to | 646 // The *Text() version performs a brute force query of the history DB to |
652 // search for results which match the given text query. | 647 // search for results which match the given text query. |
653 // Both functions assume QueryHistory already checked the DB for validity. | 648 // Both functions assume QueryHistory already checked the DB for validity. |
654 void QueryHistoryBasic(URLDatabase* url_db, VisitDatabase* visit_db, | 649 void QueryHistoryBasic(URLDatabase* url_db, VisitDatabase* visit_db, |
655 const QueryOptions& options, QueryResults* result); | 650 const QueryOptions& options, QueryResults* result); |
656 void QueryHistoryText(URLDatabase* url_db, | 651 void QueryHistoryText(URLDatabase* url_db, |
657 VisitDatabase* visit_db, | 652 VisitDatabase* visit_db, |
658 const string16& text_query, | 653 const string16& text_query, |
659 const QueryOptions& options, | 654 const QueryOptions& options, |
660 QueryResults* result); | 655 QueryResults* result); |
661 void QueryHistoryFTS(const string16& text_query, | |
662 const QueryOptions& options, | |
663 QueryResults* result); | |
664 | 656 |
665 // Committing ---------------------------------------------------------------- | 657 // Committing ---------------------------------------------------------------- |
666 | 658 |
667 // We always keep a transaction open on the history database so that multiple | 659 // We always keep a transaction open on the history database so that multiple |
668 // transactions can be batched. Periodically, these are flushed (use | 660 // transactions can be batched. Periodically, these are flushed (use |
669 // ScheduleCommit). This function does the commit to write any new changes to | 661 // ScheduleCommit). This function does the commit to write any new changes to |
670 // disk and opens a new transaction. This will be called automatically by | 662 // disk and opens a new transaction. This will be called automatically by |
671 // ScheduleCommit, or it can be called explicitly if a caller really wants | 663 // ScheduleCommit, or it can be called explicitly if a caller really wants |
672 // to write something to disk. | 664 // to write something to disk. |
673 void Commit(); | 665 void Commit(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 // vector to reference the new IDs. | 828 // vector to reference the new IDs. |
837 bool ClearAllThumbnailHistory(URLRows* kept_urls); | 829 bool ClearAllThumbnailHistory(URLRows* kept_urls); |
838 | 830 |
839 // Deletes all information in the history database, except for the supplied | 831 // Deletes all information in the history database, except for the supplied |
840 // set of URLs in the URL table (these should correspond to the bookmarked | 832 // set of URLs in the URL table (these should correspond to the bookmarked |
841 // URLs). | 833 // URLs). |
842 // | 834 // |
843 // The IDs of the URLs may change. | 835 // The IDs of the URLs may change. |
844 bool ClearAllMainHistory(const URLRows& kept_urls); | 836 bool ClearAllMainHistory(const URLRows& kept_urls); |
845 | 837 |
| 838 // Deletes the FTS index database files, which are no longer used. |
| 839 void DeleteFTSIndexDatabases(); |
| 840 |
846 // Returns the BookmarkService, blocking until it is loaded. This may return | 841 // Returns the BookmarkService, blocking until it is loaded. This may return |
847 // NULL during testing. | 842 // NULL during testing. |
848 BookmarkService* GetBookmarkService(); | 843 BookmarkService* GetBookmarkService(); |
849 | 844 |
850 // Notify any observers of an addition to the visit database. | 845 // Notify any observers of an addition to the visit database. |
851 void NotifyVisitObservers(const VisitRow& visit); | 846 void NotifyVisitObservers(const VisitRow& visit); |
852 | 847 |
853 // Data ---------------------------------------------------------------------- | 848 // Data ---------------------------------------------------------------------- |
854 | 849 |
855 // Delegate. See the class definition above for more information. This will | 850 // Delegate. See the class definition above for more information. This will |
(...skipping 12 matching lines...) Expand all Loading... |
868 // not be opened, all users must first check for NULL and return immediately | 863 // not be opened, all users must first check for NULL and return immediately |
869 // if it is. The thumbnail DB may be NULL when the history one isn't, but not | 864 // if it is. The thumbnail DB may be NULL when the history one isn't, but not |
870 // vice-versa. | 865 // vice-versa. |
871 scoped_ptr<HistoryDatabase> db_; | 866 scoped_ptr<HistoryDatabase> db_; |
872 bool scheduled_kill_db_; // Database is being killed due to error. | 867 bool scheduled_kill_db_; // Database is being killed due to error. |
873 scoped_ptr<ThumbnailDatabase> thumbnail_db_; | 868 scoped_ptr<ThumbnailDatabase> thumbnail_db_; |
874 | 869 |
875 // Stores old history in a larger, slower database. | 870 // Stores old history in a larger, slower database. |
876 scoped_ptr<ArchivedDatabase> archived_db_; | 871 scoped_ptr<ArchivedDatabase> archived_db_; |
877 | 872 |
878 // Full text database manager, possibly NULL if the database could not be | |
879 // created. | |
880 scoped_ptr<TextDatabaseManager> text_database_; | |
881 | |
882 // Manages expiration between the various databases. | 873 // Manages expiration between the various databases. |
883 ExpireHistoryBackend expirer_; | 874 ExpireHistoryBackend expirer_; |
884 | 875 |
885 // A commit has been scheduled to occur sometime in the future. We can check | 876 // A commit has been scheduled to occur sometime in the future. We can check |
886 // non-null-ness to see if there is a commit scheduled in the future, and we | 877 // non-null-ness to see if there is a commit scheduled in the future, and we |
887 // can use the pointer to cancel the scheduled commit. There can be only one | 878 // can use the pointer to cancel the scheduled commit. There can be only one |
888 // scheduled commit at a time (see ScheduleCommit). | 879 // scheduled commit at a time (see ScheduleCommit). |
889 scoped_refptr<CommitLaterTask> scheduled_commit_; | 880 scoped_refptr<CommitLaterTask> scheduled_commit_; |
890 | 881 |
891 // Maps recent redirect destination pages to the chain of redirects that | 882 // Maps recent redirect destination pages to the chain of redirects that |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 | 937 |
947 // Listens for the system being under memory pressure. | 938 // Listens for the system being under memory pressure. |
948 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 939 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
949 | 940 |
950 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 941 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
951 }; | 942 }; |
952 | 943 |
953 } // namespace history | 944 } // namespace history |
954 | 945 |
955 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 946 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |