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" | |
19 #include "chrome/browser/history/expire_history_backend.h" | 18 #include "chrome/browser/history/expire_history_backend.h" |
20 #include "chrome/browser/history/history_database.h" | 19 #include "chrome/browser/history/history_database.h" |
21 #include "chrome/browser/history/history_marshaling.h" | 20 #include "chrome/browser/history/history_marshaling.h" |
22 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.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 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 // Update the visit_duration information in visits table. | 596 // Update the visit_duration information in visits table. |
598 void UpdateVisitDuration(VisitID visit_id, const base::Time end_ts); | 597 void UpdateVisitDuration(VisitID visit_id, const base::Time end_ts); |
599 | 598 |
600 // Querying ------------------------------------------------------------------ | 599 // Querying ------------------------------------------------------------------ |
601 | 600 |
602 // Backends for QueryHistory. *Basic() handles queries that are not | 601 // Backends for QueryHistory. *Basic() handles queries that are not |
603 // text search queries and can just be given directly to the history DB. | 602 // text search queries and can just be given directly to the history DB. |
604 // The *Text() version performs a brute force query of the history DB to | 603 // The *Text() version performs a brute force query of the history DB to |
605 // search for results which match the given text query. | 604 // search for results which match the given text query. |
606 // Both functions assume QueryHistory already checked the DB for validity. | 605 // Both functions assume QueryHistory already checked the DB for validity. |
607 void QueryHistoryBasic(URLDatabase* url_db, VisitDatabase* visit_db, | 606 void QueryHistoryBasic(const QueryOptions& options, QueryResults* result); |
608 const QueryOptions& options, QueryResults* result); | 607 void QueryHistoryText(const base::string16& text_query, |
609 void QueryHistoryText(URLDatabase* url_db, | |
610 VisitDatabase* visit_db, | |
611 const base::string16& text_query, | |
612 const QueryOptions& options, | 608 const QueryOptions& options, |
613 QueryResults* result); | 609 QueryResults* result); |
614 | 610 |
615 // Committing ---------------------------------------------------------------- | 611 // Committing ---------------------------------------------------------------- |
616 | 612 |
617 // We always keep a transaction open on the history database so that multiple | 613 // We always keep a transaction open on the history database so that multiple |
618 // transactions can be batched. Periodically, these are flushed (use | 614 // transactions can be batched. Periodically, these are flushed (use |
619 // ScheduleCommit). This function does the commit to write any new changes to | 615 // ScheduleCommit). This function does the commit to write any new changes to |
620 // disk and opens a new transaction. This will be called automatically by | 616 // disk and opens a new transaction. This will be called automatically by |
621 // ScheduleCommit, or it can be called explicitly if a caller really wants | 617 // ScheduleCommit, or it can be called explicitly if a caller really wants |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 755 |
760 // Release all tasks in history_db_tasks_ and clears it. | 756 // Release all tasks in history_db_tasks_ and clears it. |
761 void ReleaseDBTasks(); | 757 void ReleaseDBTasks(); |
762 | 758 |
763 // Schedules a broadcast of the given notification on the main thread. | 759 // Schedules a broadcast of the given notification on the main thread. |
764 virtual void BroadcastNotifications( | 760 virtual void BroadcastNotifications( |
765 int type, | 761 int type, |
766 scoped_ptr<HistoryDetails> details) OVERRIDE; | 762 scoped_ptr<HistoryDetails> details) OVERRIDE; |
767 | 763 |
768 virtual void NotifySyncURLsDeleted(bool all_history, | 764 virtual void NotifySyncURLsDeleted(bool all_history, |
769 bool archived, | 765 bool expired, |
770 URLRows* rows) OVERRIDE; | 766 URLRows* rows) OVERRIDE; |
771 | 767 |
772 // Deleting all history ------------------------------------------------------ | 768 // Deleting all history ------------------------------------------------------ |
773 | 769 |
774 // Deletes all history. This is a special case of deleting that is separated | 770 // Deletes all history. This is a special case of deleting that is separated |
775 // from our normal dependency-following method for performance reasons. The | 771 // from our normal dependency-following method for performance reasons. The |
776 // logic lives here instead of ExpireHistoryBackend since it will cause | 772 // logic lives here instead of ExpireHistoryBackend since it will cause |
777 // re-initialization of some databases such as Thumbnails or Archived that | 773 // re-initialization of some databases (e.g. Thumbnails) that could fail. |
778 // could fail. When these databases are not valid, our pointers must be NULL, | 774 // When these databases are not valid, our pointers must be NULL, so we need |
779 // so we need to handle this type of operation to keep the pointers in sync. | 775 // to handle this type of operation to keep the pointers in sync. |
780 void DeleteAllHistory(); | 776 void DeleteAllHistory(); |
781 | 777 |
782 // Given a vector of all URLs that we will keep, removes all thumbnails | 778 // Given a vector of all URLs that we will keep, removes all thumbnails |
783 // referenced by any URL, and also all favicons that aren't used by those | 779 // referenced by any URL, and also all favicons that aren't used by those |
784 // URLs. | 780 // URLs. |
785 bool ClearAllThumbnailHistory(const URLRows& kept_urls); | 781 bool ClearAllThumbnailHistory(const URLRows& kept_urls); |
786 | 782 |
787 // Deletes all information in the history database, except for the supplied | 783 // Deletes all information in the history database, except for the supplied |
788 // set of URLs in the URL table (these should correspond to the bookmarked | 784 // set of URLs in the URL table (these should correspond to the bookmarked |
789 // URLs). | 785 // URLs). |
(...skipping 22 matching lines...) Expand all Loading... |
812 base::FilePath history_dir_; | 808 base::FilePath history_dir_; |
813 | 809 |
814 // The history/thumbnail databases. Either MAY BE NULL if the database could | 810 // The history/thumbnail databases. Either MAY BE NULL if the database could |
815 // not be opened, all users must first check for NULL and return immediately | 811 // not be opened, all users must first check for NULL and return immediately |
816 // if it is. The thumbnail DB may be NULL when the history one isn't, but not | 812 // if it is. The thumbnail DB may be NULL when the history one isn't, but not |
817 // vice-versa. | 813 // vice-versa. |
818 scoped_ptr<HistoryDatabase> db_; | 814 scoped_ptr<HistoryDatabase> db_; |
819 bool scheduled_kill_db_; // Database is being killed due to error. | 815 bool scheduled_kill_db_; // Database is being killed due to error. |
820 scoped_ptr<ThumbnailDatabase> thumbnail_db_; | 816 scoped_ptr<ThumbnailDatabase> thumbnail_db_; |
821 | 817 |
822 // Stores old history in a larger, slower database. | |
823 scoped_ptr<ArchivedDatabase> archived_db_; | |
824 | |
825 // Manages expiration between the various databases. | 818 // Manages expiration between the various databases. |
826 ExpireHistoryBackend expirer_; | 819 ExpireHistoryBackend expirer_; |
827 | 820 |
828 // A commit has been scheduled to occur sometime in the future. We can check | 821 // A commit has been scheduled to occur sometime in the future. We can check |
829 // non-null-ness to see if there is a commit scheduled in the future, and we | 822 // non-null-ness to see if there is a commit scheduled in the future, and we |
830 // can use the pointer to cancel the scheduled commit. There can be only one | 823 // can use the pointer to cancel the scheduled commit. There can be only one |
831 // scheduled commit at a time (see ScheduleCommit). | 824 // scheduled commit at a time (see ScheduleCommit). |
832 scoped_refptr<CommitLaterTask> scheduled_commit_; | 825 scoped_refptr<CommitLaterTask> scheduled_commit_; |
833 | 826 |
834 // Maps recent redirect destination pages to the chain of redirects that | 827 // Maps recent redirect destination pages to the chain of redirects that |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 | 878 |
886 // Listens for the system being under memory pressure. | 879 // Listens for the system being under memory pressure. |
887 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 880 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
888 | 881 |
889 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 882 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
890 }; | 883 }; |
891 | 884 |
892 } // namespace history | 885 } // namespace history |
893 | 886 |
894 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 887 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |