Chromium Code Reviews| 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 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/cancelable_callback.h" | |
| 17 #include "base/containers/hash_tables.h" | 18 #include "base/containers/hash_tables.h" |
| 18 #include "base/containers/mru_cache.h" | 19 #include "base/containers/mru_cache.h" |
| 19 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
| 20 #include "base/gtest_prod_util.h" | 21 #include "base/gtest_prod_util.h" |
| 21 #include "base/macros.h" | 22 #include "base/macros.h" |
| 22 #include "base/memory/memory_pressure_listener.h" | 23 #include "base/memory/memory_pressure_listener.h" |
| 24 #include "base/memory/weak_ptr.h" | |
| 23 #include "base/observer_list.h" | 25 #include "base/observer_list.h" |
| 24 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
| 25 #include "base/supports_user_data.h" | 27 #include "base/supports_user_data.h" |
| 26 #include "base/task/cancelable_task_tracker.h" | 28 #include "base/task/cancelable_task_tracker.h" |
| 27 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 28 #include "components/favicon_base/favicon_usage_data.h" | 30 #include "components/favicon_base/favicon_usage_data.h" |
| 29 #include "components/history/core/browser/expire_history_backend.h" | 31 #include "components/history/core/browser/expire_history_backend.h" |
| 30 #include "components/history/core/browser/history_backend_notifier.h" | 32 #include "components/history/core/browser/history_backend_notifier.h" |
| 31 #include "components/history/core/browser/history_types.h" | 33 #include "components/history/core/browser/history_types.h" |
| 32 #include "components/history/core/browser/keyword_id.h" | 34 #include "components/history/core/browser/keyword_id.h" |
| 33 #include "components/history/core/browser/thumbnail_database.h" | 35 #include "components/history/core/browser/thumbnail_database.h" |
| 34 #include "components/history/core/browser/visit_tracker.h" | 36 #include "components/history/core/browser/visit_tracker.h" |
| 35 #include "sql/init_status.h" | 37 #include "sql/init_status.h" |
| 36 | 38 |
| 37 class SkBitmap; | 39 class SkBitmap; |
| 38 class TestingProfile; | 40 class TestingProfile; |
| 39 | 41 |
| 40 namespace base { | 42 namespace base { |
| 41 class SingleThreadTaskRunner; | 43 class SingleThreadTaskRunner; |
| 42 } | 44 } |
| 43 | 45 |
| 44 namespace history { | 46 namespace history { |
| 45 class CommitLaterTask; | |
| 46 struct DownloadRow; | 47 struct DownloadRow; |
| 47 class HistoryBackendClient; | 48 class HistoryBackendClient; |
| 48 class HistoryBackendDBBaseTest; | 49 class HistoryBackendDBBaseTest; |
| 49 class HistoryBackendObserver; | 50 class HistoryBackendObserver; |
| 50 class HistoryBackendTest; | 51 class HistoryBackendTest; |
| 51 class HistoryDatabase; | 52 class HistoryDatabase; |
| 52 struct HistoryDatabaseParams; | 53 struct HistoryDatabaseParams; |
| 53 class HistoryDBTask; | 54 class HistoryDBTask; |
| 54 class InMemoryHistoryBackend; | 55 class InMemoryHistoryBackend; |
| 55 class TypedUrlSyncableService; | 56 class TypedUrlSyncableService; |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 // code to avoid syncing visits that would immediately be expired). | 474 // code to avoid syncing visits that would immediately be expired). |
| 474 virtual bool IsExpiredVisitTime(const base::Time& time); | 475 virtual bool IsExpiredVisitTime(const base::Time& time); |
| 475 | 476 |
| 476 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; } | 477 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; } |
| 477 | 478 |
| 478 protected: | 479 protected: |
| 479 ~HistoryBackend() override; | 480 ~HistoryBackend() override; |
| 480 | 481 |
| 481 private: | 482 private: |
| 482 friend class base::RefCountedThreadSafe<HistoryBackend>; | 483 friend class base::RefCountedThreadSafe<HistoryBackend>; |
| 483 friend class CommitLaterTask; // The commit task needs to call Commit(). | |
| 484 friend class HistoryBackendTest; | 484 friend class HistoryBackendTest; |
| 485 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our | 485 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our |
| 486 // innards. | 486 // innards. |
| 487 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); | 487 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); |
| 488 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllURLPreviouslyDeleted); | 488 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllURLPreviouslyDeleted); |
| 489 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllThenAddData); | 489 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllThenAddData); |
| 490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPagesWithDetails); | 490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPagesWithDetails); |
| 491 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateURLs); | 491 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateURLs); |
| 492 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ImportedFaviconsTest); | 492 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ImportedFaviconsTest); |
| 493 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked); | 493 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 // if it is. The thumbnail DB may be null when the history one isn't, but not | 821 // if it is. The thumbnail DB may be null when the history one isn't, but not |
| 822 // vice-versa. | 822 // vice-versa. |
| 823 std::unique_ptr<HistoryDatabase> db_; | 823 std::unique_ptr<HistoryDatabase> db_; |
| 824 bool scheduled_kill_db_; // Database is being killed due to error. | 824 bool scheduled_kill_db_; // Database is being killed due to error. |
| 825 std::unique_ptr<ThumbnailDatabase> thumbnail_db_; | 825 std::unique_ptr<ThumbnailDatabase> thumbnail_db_; |
| 826 | 826 |
| 827 // Manages expiration between the various databases. | 827 // Manages expiration between the various databases. |
| 828 ExpireHistoryBackend expirer_; | 828 ExpireHistoryBackend expirer_; |
| 829 | 829 |
| 830 // A commit has been scheduled to occur sometime in the future. We can check | 830 // 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 | 831 // !IsCancelled() to see if there is a commit scheduled in the future, and we |
|
Marc Treib
2017/02/02 12:59:24
So IsCancelled()==true is the default state for an
| |
| 832 // can use the pointer to cancel the scheduled commit. There can be only one | 832 // can use Cancel() to cancel the scheduled commit. There can be only one |
| 833 // scheduled commit at a time (see ScheduleCommit). | 833 // scheduled commit at a time (see ScheduleCommit). |
| 834 scoped_refptr<CommitLaterTask> scheduled_commit_; | 834 base::CancelableClosure scheduled_commit_; |
| 835 | 835 |
| 836 // Maps recent redirect destination pages to the chain of redirects that | 836 // Maps recent redirect destination pages to the chain of redirects that |
| 837 // brought us to there. Pages that did not have redirects or were not the | 837 // brought us to there. Pages that did not have redirects or were not the |
| 838 // final redirect in a chain will not be in this list, as well as pages that | 838 // final redirect in a chain will not be in this list, as well as pages that |
| 839 // redirected "too long" ago (as determined by ExpireOldRedirects above). | 839 // redirected "too long" ago (as determined by ExpireOldRedirects above). |
| 840 // It is used to set titles & favicons for redirects to that of the | 840 // It is used to set titles & favicons for redirects to that of the |
| 841 // destination. | 841 // destination. |
| 842 // | 842 // |
| 843 // As with AddPage, the last item in the redirect chain will be the | 843 // As with AddPage, the last item in the redirect chain will be the |
| 844 // destination of the redirect (i.e., the key into recent_redirects_); | 844 // destination of the redirect (i.e., the key into recent_redirects_); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 883 // when a catastrophic error occurs. | 883 // when a catastrophic error occurs. |
| 884 std::string db_diagnostics_; | 884 std::string db_diagnostics_; |
| 885 | 885 |
| 886 // Map from host to index in the TopHosts list. It is updated only by | 886 // Map from host to index in the TopHosts list. It is updated only by |
| 887 // TopHosts(), so it's usually stale. | 887 // TopHosts(), so it's usually stale. |
| 888 mutable base::hash_map<std::string, int> host_ranks_; | 888 mutable base::hash_map<std::string, int> host_ranks_; |
| 889 | 889 |
| 890 // List of observers | 890 // List of observers |
| 891 base::ObserverList<HistoryBackendObserver> observers_; | 891 base::ObserverList<HistoryBackendObserver> observers_; |
| 892 | 892 |
| 893 base::WeakPtrFactory<HistoryBackend> weak_ptr_factory_; | |
| 894 | |
| 893 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 895 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
| 894 }; | 896 }; |
| 895 | 897 |
| 896 } // namespace history | 898 } // namespace history |
| 897 | 899 |
| 898 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 900 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| OLD | NEW |