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