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_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_H_ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/string16.h" | 20 #include "base/string16.h" |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "base/threading/thread_checker.h" | 22 #include "base/threading/thread_checker.h" |
23 #include "chrome/browser/common/cancelable_request.h" | 23 #include "chrome/browser/common/cancelable_request.h" |
24 #include "chrome/browser/favicon/favicon_service.h" | 24 #include "chrome/browser/favicon/favicon_service.h" |
25 #include "chrome/browser/history/history_types.h" | 25 #include "chrome/browser/history/history_types.h" |
26 #include "chrome/browser/profiles/profile_keyed_service.h" | 26 #include "chrome/browser/profiles/profile_keyed_service.h" |
27 #include "chrome/browser/search_engines/template_url_id.h" | 27 #include "chrome/browser/search_engines/template_url_id.h" |
28 #include "chrome/browser/visitedlink/visitedlink_delegate.h" | |
29 #include "chrome/common/cancelable_task_tracker.h" | 28 #include "chrome/common/cancelable_task_tracker.h" |
30 #include "chrome/common/ref_counted_util.h" | 29 #include "chrome/common/ref_counted_util.h" |
| 30 #include "components/visitedlink/browser/visitedlink_delegate.h" |
31 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
32 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
33 #include "content/public/common/page_transition_types.h" | 33 #include "content/public/common/page_transition_types.h" |
34 #include "sql/init_status.h" | 34 #include "sql/init_status.h" |
35 #include "sync/api/syncable_service.h" | 35 #include "sync/api/syncable_service.h" |
36 #include "ui/base/layout.h" | 36 #include "ui/base/layout.h" |
37 | 37 |
38 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
39 #include "chrome/browser/history/android/android_history_provider_service.h" | 39 #include "chrome/browser/history/android/android_history_provider_service.h" |
40 #endif | 40 #endif |
41 | 41 |
42 class BookmarkService; | 42 class BookmarkService; |
43 class FilePath; | 43 class FilePath; |
44 class GURL; | 44 class GURL; |
45 class HistoryURLProvider; | 45 class HistoryURLProvider; |
46 class PageUsageData; | 46 class PageUsageData; |
47 class PageUsageRequest; | 47 class PageUsageRequest; |
48 class Profile; | 48 class Profile; |
49 class VisitedLinkMaster; | |
50 struct HistoryURLProviderParams; | 49 struct HistoryURLProviderParams; |
51 | 50 |
52 namespace base { | 51 namespace base { |
53 class Thread; | 52 class Thread; |
54 } | 53 } |
55 | 54 |
| 55 namespace components { |
| 56 class VisitedLinkMaster; |
| 57 } // namespace components |
| 58 |
56 | 59 |
57 namespace history { | 60 namespace history { |
58 | 61 |
59 class HistoryBackend; | 62 class HistoryBackend; |
60 class HistoryDatabase; | 63 class HistoryDatabase; |
61 class HistoryQueryTest; | 64 class HistoryQueryTest; |
62 class InMemoryHistoryBackend; | 65 class InMemoryHistoryBackend; |
63 class InMemoryURLIndex; | 66 class InMemoryURLIndex; |
64 class InMemoryURLIndexTest; | 67 class InMemoryURLIndexTest; |
65 class URLDatabase; | 68 class URLDatabase; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 106 |
104 // The history service records page titles, and visit times, as well as | 107 // The history service records page titles, and visit times, as well as |
105 // (eventually) information about autocomplete. | 108 // (eventually) information about autocomplete. |
106 // | 109 // |
107 // This service is thread safe. Each request callback is invoked in the | 110 // This service is thread safe. Each request callback is invoked in the |
108 // thread that made the request. | 111 // thread that made the request. |
109 class HistoryService : public CancelableRequestProvider, | 112 class HistoryService : public CancelableRequestProvider, |
110 public content::NotificationObserver, | 113 public content::NotificationObserver, |
111 public syncer::SyncableService, | 114 public syncer::SyncableService, |
112 public ProfileKeyedService, | 115 public ProfileKeyedService, |
113 public VisitedLinkDelegate { | 116 public components::VisitedLinkDelegate { |
114 public: | 117 public: |
115 // Miscellaneous commonly-used types. | 118 // Miscellaneous commonly-used types. |
116 typedef std::vector<PageUsageData*> PageUsageDataList; | 119 typedef std::vector<PageUsageData*> PageUsageDataList; |
117 | 120 |
118 // Must call Init after construction. | 121 // Must call Init after construction. |
119 explicit HistoryService(Profile* profile); | 122 explicit HistoryService(Profile* profile); |
120 // The empty constructor is provided only for testing. | 123 // The empty constructor is provided only for testing. |
121 HistoryService(); | 124 HistoryService(); |
122 | 125 |
123 virtual ~HistoryService(); | 126 virtual ~HistoryService(); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 template<typename Info, typename Callback> friend class DownloadRequest; | 653 template<typename Info, typename Callback> friend class DownloadRequest; |
651 friend class PageUsageRequest; | 654 friend class PageUsageRequest; |
652 friend class RedirectRequest; | 655 friend class RedirectRequest; |
653 friend class TestingProfile; | 656 friend class TestingProfile; |
654 | 657 |
655 // Implementation of content::NotificationObserver. | 658 // Implementation of content::NotificationObserver. |
656 virtual void Observe(int type, | 659 virtual void Observe(int type, |
657 const content::NotificationSource& source, | 660 const content::NotificationSource& source, |
658 const content::NotificationDetails& details) OVERRIDE; | 661 const content::NotificationDetails& details) OVERRIDE; |
659 | 662 |
660 // Implementation of VisitedLinkDelegate. | 663 // Implementation of components::VisitedLinkDelegate. |
661 virtual bool AreEquivalentContexts( | 664 virtual bool AreEquivalentContexts( |
662 content::BrowserContext* context1, | 665 content::BrowserContext* context1, |
663 content::BrowserContext* context2) OVERRIDE; | 666 content::BrowserContext* context2) OVERRIDE; |
664 virtual void RebuildTable( | 667 virtual void RebuildTable( |
665 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; | 668 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; |
666 | 669 |
667 // Low-level Init(). Same as the public version, but adds a |no_db| parameter | 670 // Low-level Init(). Same as the public version, but adds a |no_db| parameter |
668 // that is only set by unittests which causes the backend to not init its DB. | 671 // that is only set by unittests which causes the backend to not init its DB. |
669 bool Init(const FilePath& history_dir, | 672 bool Init(const FilePath& history_dir, |
670 BookmarkService* bookmark_service, | 673 BookmarkService* bookmark_service, |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; | 1086 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; |
1084 | 1087 |
1085 // Used to propagate local delete directives to sync. | 1088 // Used to propagate local delete directives to sync. |
1086 scoped_ptr<syncer::SyncChangeProcessor> sync_change_processor_; | 1089 scoped_ptr<syncer::SyncChangeProcessor> sync_change_processor_; |
1087 | 1090 |
1088 // The profile, may be null when testing. | 1091 // The profile, may be null when testing. |
1089 Profile* profile_; | 1092 Profile* profile_; |
1090 | 1093 |
1091 // Used for propagating link highlighting data across renderers. May be null | 1094 // Used for propagating link highlighting data across renderers. May be null |
1092 // in tests. | 1095 // in tests. |
1093 scoped_ptr<VisitedLinkMaster> visitedlink_master_; | 1096 scoped_ptr<components::VisitedLinkMaster> visitedlink_master_; |
1094 | 1097 |
1095 // Has the backend finished loading? The backend is loaded once Init has | 1098 // Has the backend finished loading? The backend is loaded once Init has |
1096 // completed. | 1099 // completed. |
1097 bool backend_loaded_; | 1100 bool backend_loaded_; |
1098 | 1101 |
1099 // The id of the current backend. This is only valid when history_backend_ | 1102 // The id of the current backend. This is only valid when history_backend_ |
1100 // is not NULL. | 1103 // is not NULL. |
1101 int current_backend_id_; | 1104 int current_backend_id_; |
1102 | 1105 |
1103 // Cached values from Init(), used whenever we need to reload the backend. | 1106 // Cached values from Init(), used whenever we need to reload the backend. |
1104 FilePath history_dir_; | 1107 FilePath history_dir_; |
1105 BookmarkService* bookmark_service_; | 1108 BookmarkService* bookmark_service_; |
1106 bool no_db_; | 1109 bool no_db_; |
1107 | 1110 |
1108 // True if needs top site migration. | 1111 // True if needs top site migration. |
1109 bool needs_top_sites_migration_; | 1112 bool needs_top_sites_migration_; |
1110 | 1113 |
1111 // The index used for quick history lookups. | 1114 // The index used for quick history lookups. |
1112 // TODO(mrossetti): Move in_memory_url_index out of history_service. | 1115 // TODO(mrossetti): Move in_memory_url_index out of history_service. |
1113 // See http://crbug.com/138321 | 1116 // See http://crbug.com/138321 |
1114 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | 1117 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
1115 | 1118 |
1116 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; | 1119 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; |
1117 | 1120 |
1118 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 1121 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
1119 }; | 1122 }; |
1120 | 1123 |
1121 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ | 1124 #endif // CHROME_BROWSER_HISTORY_HISTORY_H_ |
OLD | NEW |