| 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 COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/supports_user_data.h" | 25 #include "base/supports_user_data.h" |
| 26 #include "base/task/cancelable_task_tracker.h" | 26 #include "base/task/cancelable_task_tracker.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "components/favicon_base/favicon_usage_data.h" | 28 #include "components/favicon_base/favicon_usage_data.h" |
| 29 #include "components/history/core/browser/expire_history_backend.h" | 29 #include "components/history/core/browser/expire_history_backend.h" |
| 30 #include "components/history/core/browser/history_backend_notifier.h" | 30 #include "components/history/core/browser/history_backend_notifier.h" |
| 31 #include "components/history/core/browser/history_types.h" | 31 #include "components/history/core/browser/history_types.h" |
| 32 #include "components/history/core/browser/keyword_id.h" | 32 #include "components/history/core/browser/keyword_id.h" |
| 33 #include "components/history/core/browser/thumbnail_database.h" | 33 #include "components/history/core/browser/thumbnail_database.h" |
| 34 #include "components/history/core/browser/visit_tracker.h" | 34 #include "components/history/core/browser/visit_tracker.h" |
| 35 #include "sql/db_diagnostic_map.h" |
| 35 #include "sql/init_status.h" | 36 #include "sql/init_status.h" |
| 36 | 37 |
| 37 class HistoryURLProvider; | 38 class HistoryURLProvider; |
| 38 struct HistoryURLProviderParams; | 39 struct HistoryURLProviderParams; |
| 39 class SkBitmap; | 40 class SkBitmap; |
| 40 class TestingProfile; | 41 class TestingProfile; |
| 41 struct ThumbnailScore; | 42 struct ThumbnailScore; |
| 42 | 43 |
| 43 namespace base { | 44 namespace base { |
| 44 class MessageLoop; | 45 class MessageLoop; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 public: | 107 public: |
| 107 // Interface implemented by the owner of the HistoryBackend object. Normally, | 108 // Interface implemented by the owner of the HistoryBackend object. Normally, |
| 108 // the history service implements this to send stuff back to the main thread. | 109 // the history service implements this to send stuff back to the main thread. |
| 109 // The unit tests can provide a different implementation if they don't have | 110 // The unit tests can provide a different implementation if they don't have |
| 110 // a history service object. | 111 // a history service object. |
| 111 class Delegate { | 112 class Delegate { |
| 112 public: | 113 public: |
| 113 virtual ~Delegate() {} | 114 virtual ~Delegate() {} |
| 114 | 115 |
| 115 // Called when the database cannot be read correctly for some reason. | 116 // Called when the database cannot be read correctly for some reason. |
| 116 virtual void NotifyProfileError(sql::InitStatus init_status) = 0; | 117 virtual void NotifyProfileError( |
| 118 sql::InitStatus init_status, |
| 119 const sql::DatabaseDiagnosticMap& diagnostics) = 0; |
| 117 | 120 |
| 118 // Sets the in-memory history backend. The in-memory backend is created by | 121 // Sets the in-memory history backend. The in-memory backend is created by |
| 119 // the main backend. For non-unit tests, this happens on the background | 122 // the main backend. For non-unit tests, this happens on the background |
| 120 // thread. It is to be used on the main thread, so this would transfer | 123 // thread. It is to be used on the main thread, so this would transfer |
| 121 // it to the history service. Unit tests can override this behavior. | 124 // it to the history service. Unit tests can override this behavior. |
| 122 // | 125 // |
| 123 // This function is NOT guaranteed to be called. If there is an error, | 126 // This function is NOT guaranteed to be called. If there is an error, |
| 124 // there may be no in-memory database. | 127 // there may be no in-memory database. |
| 125 virtual void SetInMemoryBackend( | 128 virtual void SetInMemoryBackend( |
| 126 std::unique_ptr<InMemoryHistoryBackend> backend) = 0; | 129 std::unique_ptr<InMemoryHistoryBackend> backend) = 0; |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 base::FilePath history_dir_; | 820 base::FilePath history_dir_; |
| 818 | 821 |
| 819 // The history/thumbnail databases. Either may be null if the database could | 822 // The history/thumbnail databases. Either may be null if the database could |
| 820 // not be opened, all users must first check for null and return immediately | 823 // not be opened, all users must first check for null and return immediately |
| 821 // if it is. The thumbnail DB may be null when the history one isn't, but not | 824 // if it is. The thumbnail DB may be null when the history one isn't, but not |
| 822 // vice-versa. | 825 // vice-versa. |
| 823 std::unique_ptr<HistoryDatabase> db_; | 826 std::unique_ptr<HistoryDatabase> db_; |
| 824 bool scheduled_kill_db_; // Database is being killed due to error. | 827 bool scheduled_kill_db_; // Database is being killed due to error. |
| 825 std::unique_ptr<ThumbnailDatabase> thumbnail_db_; | 828 std::unique_ptr<ThumbnailDatabase> thumbnail_db_; |
| 826 | 829 |
| 830 // Invoked when an error occurs on the database connection. |
| 831 sql::Connection::ErrorCallback error_callback_; |
| 832 |
| 827 // Manages expiration between the various databases. | 833 // Manages expiration between the various databases. |
| 828 ExpireHistoryBackend expirer_; | 834 ExpireHistoryBackend expirer_; |
| 829 | 835 |
| 830 // A commit has been scheduled to occur sometime in the future. We can check | 836 // 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 | 837 // 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 | 838 // can use the pointer to cancel the scheduled commit. There can be only one |
| 833 // scheduled commit at a time (see ScheduleCommit). | 839 // scheduled commit at a time (see ScheduleCommit). |
| 834 scoped_refptr<CommitLaterTask> scheduled_commit_; | 840 scoped_refptr<CommitLaterTask> scheduled_commit_; |
| 835 | 841 |
| 836 // Maps recent redirect destination pages to the chain of redirects that | 842 // Maps recent redirect destination pages to the chain of redirects that |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 // of inheritance from base::SupportsUserData). | 878 // of inheritance from base::SupportsUserData). |
| 873 std::unique_ptr<HistoryBackendHelper> supports_user_data_helper_; | 879 std::unique_ptr<HistoryBackendHelper> supports_user_data_helper_; |
| 874 | 880 |
| 875 // Used to manage syncing of the typed urls datatype. This will be null before | 881 // Used to manage syncing of the typed urls datatype. This will be null before |
| 876 // Init is called. | 882 // Init is called. |
| 877 std::unique_ptr<TypedUrlSyncableService> typed_url_syncable_service_; | 883 std::unique_ptr<TypedUrlSyncableService> typed_url_syncable_service_; |
| 878 | 884 |
| 879 // Listens for the system being under memory pressure. | 885 // Listens for the system being under memory pressure. |
| 880 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 886 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
| 881 | 887 |
| 888 // Contains diagnostic information about the sql database that will be filled |
| 889 // when a catastrophic error occurs. |
| 890 sql::DatabaseDiagnosticMap db_diagnostics_; |
| 891 |
| 882 // Map from host to index in the TopHosts list. It is updated only by | 892 // Map from host to index in the TopHosts list. It is updated only by |
| 883 // TopHosts(), so it's usually stale. | 893 // TopHosts(), so it's usually stale. |
| 884 mutable base::hash_map<std::string, int> host_ranks_; | 894 mutable base::hash_map<std::string, int> host_ranks_; |
| 885 | 895 |
| 886 // List of observers | 896 // List of observers |
| 887 base::ObserverList<HistoryBackendObserver> observers_; | 897 base::ObserverList<HistoryBackendObserver> observers_; |
| 888 | 898 |
| 889 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 899 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
| 890 }; | 900 }; |
| 891 | 901 |
| 892 } // namespace history | 902 } // namespace history |
| 893 | 903 |
| 894 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 904 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| OLD | NEW |