| 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 <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/hash_tables.h" |
| 13 #include "base/containers/mru_cache.h" | 14 #include "base/containers/mru_cache.h" |
| 14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/memory_pressure_listener.h" | 17 #include "base/memory/memory_pressure_listener.h" |
| 17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 20 #include "base/supports_user_data.h" | 21 #include "base/supports_user_data.h" |
| 21 #include "base/task/cancelable_task_tracker.h" | 22 #include "base/task/cancelable_task_tracker.h" |
| 22 #include "components/favicon_base/favicon_usage_data.h" | 23 #include "components/favicon_base/favicon_usage_data.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // Persists any in-flight state, without actually shutting down the history | 196 // Persists any in-flight state, without actually shutting down the history |
| 196 // system. This is intended for use when the application is backgrounded. | 197 // system. This is intended for use when the application is backgrounded. |
| 197 void PersistState(); | 198 void PersistState(); |
| 198 #endif | 199 #endif |
| 199 | 200 |
| 200 void ClearCachedDataForContextID(ContextID context_id); | 201 void ClearCachedDataForContextID(ContextID context_id); |
| 201 | 202 |
| 202 // Computes the |num_hosts| most-visited hostnames in the past 30 days. See | 203 // Computes the |num_hosts| most-visited hostnames in the past 30 days. See |
| 203 // history_service.h for details. Returns an empty list if db_ is not | 204 // history_service.h for details. Returns an empty list if db_ is not |
| 204 // initialized. | 205 // initialized. |
| 206 // |
| 207 // As a side effect, caches the list of top hosts for the purposes of |
| 208 // generating internal metrics. |
| 205 TopHostsList TopHosts(int num_hosts) const; | 209 TopHostsList TopHosts(int num_hosts) const; |
| 206 | 210 |
| 207 // Navigation ---------------------------------------------------------------- | 211 // Navigation ---------------------------------------------------------------- |
| 208 | 212 |
| 209 // |request.time| must be unique with high probability. | 213 // |request.time| must be unique with high probability. |
| 210 void AddPage(const HistoryAddPageArgs& request); | 214 void AddPage(const HistoryAddPageArgs& request); |
| 211 virtual void SetPageTitle(const GURL& url, const base::string16& title); | 215 virtual void SetPageTitle(const GURL& url, const base::string16& title); |
| 212 void AddPageNoVisitForBookmark(const GURL& url, const base::string16& title); | 216 void AddPageNoVisitForBookmark(const GURL& url, const base::string16& title); |
| 213 void UpdateWithPageEndTime(ContextID context_id, | 217 void UpdateWithPageEndTime(ContextID context_id, |
| 214 int nav_entry_id, | 218 int nav_entry_id, |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); | 518 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); |
| 515 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, | 519 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, |
| 516 UpdateFaviconMappingsAndFetchNoDB); | 520 UpdateFaviconMappingsAndFetchNoDB); |
| 517 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); | 521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); |
| 518 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts); | 522 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts); |
| 519 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElidePortAndScheme); | 523 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElidePortAndScheme); |
| 520 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElideWWW); | 524 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_ElideWWW); |
| 521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_OnlyLast30Days); | 525 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_OnlyLast30Days); |
| 522 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_MaxNumHosts); | 526 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_MaxNumHosts); |
| 523 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_IgnoreUnusualURLs); | 527 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, TopHosts_IgnoreUnusualURLs); |
| 528 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RecordTopHostsMetrics); |
| 524 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); | 529 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateVisitDuration); |
| 525 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes); | 530 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ExpireHistoryForTimes); |
| 526 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases); | 531 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteFTSIndexDatabases); |
| 527 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTypedUrlTest, | 532 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTypedUrlTest, |
| 528 ProcessUserChangeRemove); | 533 ProcessUserChangeRemove); |
| 529 friend class ::TestingProfile; | 534 friend class ::TestingProfile; |
| 530 | 535 |
| 531 // Computes the name of the specified database on disk. | 536 // Computes the name of the specified database on disk. |
| 532 base::FilePath GetArchivedFileName() const; | 537 base::FilePath GetArchivedFileName() const; |
| 533 base::FilePath GetThumbnailFileName() const; | 538 base::FilePath GetThumbnailFileName() const; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 void NotifyURLVisited(ui::PageTransition transition, | 736 void NotifyURLVisited(ui::PageTransition transition, |
| 732 const URLRow& row, | 737 const URLRow& row, |
| 733 const RedirectList& redirects, | 738 const RedirectList& redirects, |
| 734 base::Time visit_time) override; | 739 base::Time visit_time) override; |
| 735 void NotifyURLsModified(const URLRows& rows) override; | 740 void NotifyURLsModified(const URLRows& rows) override; |
| 736 void NotifyURLsDeleted(bool all_history, | 741 void NotifyURLsDeleted(bool all_history, |
| 737 bool expired, | 742 bool expired, |
| 738 const URLRows& rows, | 743 const URLRows& rows, |
| 739 const std::set<GURL>& favicon_urls) override; | 744 const std::set<GURL>& favicon_urls) override; |
| 740 | 745 |
| 746 void RecordTopHostsMetrics(const GURL& url); |
| 747 |
| 741 // Deleting all history ------------------------------------------------------ | 748 // Deleting all history ------------------------------------------------------ |
| 742 | 749 |
| 743 // Deletes all history. This is a special case of deleting that is separated | 750 // Deletes all history. This is a special case of deleting that is separated |
| 744 // from our normal dependency-following method for performance reasons. The | 751 // from our normal dependency-following method for performance reasons. The |
| 745 // logic lives here instead of ExpireHistoryBackend since it will cause | 752 // logic lives here instead of ExpireHistoryBackend since it will cause |
| 746 // re-initialization of some databases (e.g. Thumbnails) that could fail. | 753 // re-initialization of some databases (e.g. Thumbnails) that could fail. |
| 747 // When these databases are not valid, our pointers must be null, so we need | 754 // When these databases are not valid, our pointers must be null, so we need |
| 748 // to handle this type of operation to keep the pointers in sync. | 755 // to handle this type of operation to keep the pointers in sync. |
| 749 void DeleteAllHistory(); | 756 void DeleteAllHistory(); |
| 750 | 757 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 // of inheritance from base::SupportsUserData). | 836 // of inheritance from base::SupportsUserData). |
| 830 scoped_ptr<HistoryBackendHelper> supports_user_data_helper_; | 837 scoped_ptr<HistoryBackendHelper> supports_user_data_helper_; |
| 831 | 838 |
| 832 // Used to manage syncing of the typed urls datatype. This will be null before | 839 // Used to manage syncing of the typed urls datatype. This will be null before |
| 833 // Init is called. | 840 // Init is called. |
| 834 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; | 841 scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; |
| 835 | 842 |
| 836 // Listens for the system being under memory pressure. | 843 // Listens for the system being under memory pressure. |
| 837 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 844 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
| 838 | 845 |
| 846 // Map from host to index in the TopHosts list. It is updated only by |
| 847 // TopHosts(), so it's usually stale. |
| 848 mutable base::hash_map<std::string, int> host_ranks_; |
| 849 |
| 839 // List of observers | 850 // List of observers |
| 840 base::ObserverList<HistoryBackendObserver> observers_; | 851 base::ObserverList<HistoryBackendObserver> observers_; |
| 841 | 852 |
| 842 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 853 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
| 843 }; | 854 }; |
| 844 | 855 |
| 845 } // namespace history | 856 } // namespace history |
| 846 | 857 |
| 847 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 858 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| OLD | NEW |