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 CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 #include "content/public/browser/notification_observer.h" | 34 #include "content/public/browser/notification_observer.h" |
| 35 #include "content/public/browser/notification_registrar.h" | 35 #include "content/public/browser/notification_registrar.h" |
| 36 #include "content/public/common/page_transition_types.h" | 36 #include "content/public/common/page_transition_types.h" |
| 37 #include "sql/init_status.h" | 37 #include "sql/init_status.h" |
| 38 #include "sync/api/syncable_service.h" | 38 #include "sync/api/syncable_service.h" |
| 39 #include "ui/base/layout.h" | 39 #include "ui/base/layout.h" |
| 40 | 40 |
| 41 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 42 class AndroidHistoryProviderService; | 42 class AndroidHistoryProviderService; |
| 43 #endif | 43 #endif |
| 44 | |
| 44 class BookmarkService; | 45 class BookmarkService; |
| 45 class GURL; | 46 class GURL; |
| 46 class HistoryURLProvider; | 47 class HistoryURLProvider; |
| 47 class PageUsageData; | 48 class PageUsageData; |
| 48 class PageUsageRequest; | 49 class PageUsageRequest; |
| 49 class Profile; | 50 class Profile; |
| 50 struct HistoryURLProviderParams; | 51 struct HistoryURLProviderParams; |
| 51 struct ImportedFaviconUsage; | 52 struct ImportedFaviconUsage; |
| 52 | 53 |
| 53 namespace base { | 54 namespace base { |
| 54 class FilePath; | 55 class FilePath; |
| 55 class Thread; | 56 class Thread; |
| 56 } | 57 } |
| 57 | 58 |
| 58 namespace visitedlink { | 59 namespace visitedlink { |
| 59 class VisitedLinkMaster; | 60 class VisitedLinkMaster; |
| 60 } | 61 } |
| 61 | 62 |
| 62 namespace history { | 63 namespace history { |
| 63 | 64 |
| 64 class HistoryBackend; | 65 class HistoryBackend; |
| 66 class HistoryClient; | |
| 65 class HistoryDatabase; | 67 class HistoryDatabase; |
| 66 class HistoryDBTask; | 68 class HistoryDBTask; |
| 67 class HistoryQueryTest; | 69 class HistoryQueryTest; |
| 68 class InMemoryHistoryBackend; | 70 class InMemoryHistoryBackend; |
| 69 class InMemoryURLIndex; | 71 class InMemoryURLIndex; |
| 70 class InMemoryURLIndexTest; | 72 class InMemoryURLIndexTest; |
| 71 class URLDatabase; | 73 class URLDatabase; |
| 72 class VisitDatabaseObserver; | 74 class VisitDatabaseObserver; |
| 73 class VisitFilter; | 75 class VisitFilter; |
| 74 struct DownloadRow; | 76 struct DownloadRow; |
| 75 struct HistoryAddPageArgs; | 77 struct HistoryAddPageArgs; |
| 76 struct HistoryDetails; | 78 struct HistoryDetails; |
| 77 | 79 |
| 78 } // namespace history | 80 } // namespace history |
| 79 | 81 |
| 80 // The history service records page titles, and visit times, as well as | 82 // The history service records page titles, and visit times, as well as |
| 81 // (eventually) information about autocomplete. | 83 // (eventually) information about autocomplete. |
| 82 // | 84 // |
| 83 // This service is thread safe. Each request callback is invoked in the | 85 // This service is thread safe. Each request callback is invoked in the |
| 84 // thread that made the request. | 86 // thread that made the request. |
| 85 class HistoryService : public CancelableRequestProvider, | 87 class HistoryService : public CancelableRequestProvider, |
| 86 public content::NotificationObserver, | 88 public content::NotificationObserver, |
| 87 public syncer::SyncableService, | 89 public syncer::SyncableService, |
| 88 public KeyedService, | |
| 89 public visitedlink::VisitedLinkDelegate { | 90 public visitedlink::VisitedLinkDelegate { |
| 90 public: | 91 public: |
| 91 // Miscellaneous commonly-used types. | 92 // Miscellaneous commonly-used types. |
| 92 typedef std::vector<PageUsageData*> PageUsageDataList; | 93 typedef std::vector<PageUsageData*> PageUsageDataList; |
| 93 | 94 |
| 94 // Must call Init after construction. | 95 // Must call Init after construction. |
|
blundell
2014/05/27 09:56:38
add a comment about expected lifetime.
sdefresne
2014/05/28 17:10:42
Done.
| |
| 95 explicit HistoryService(Profile* profile); | 96 explicit HistoryService(history::HistoryClient* client, Profile* profile); |
| 96 // The empty constructor is provided only for testing. | 97 // The empty constructor is provided only for testing. |
| 97 HistoryService(); | 98 HistoryService(); |
| 98 | 99 |
| 99 virtual ~HistoryService(); | 100 virtual ~HistoryService(); |
| 100 | 101 |
| 101 // Initializes the history service, returning true on success. On false, do | 102 // Initializes the history service, returning true on success. On false, do |
| 102 // not call any other functions. The given directory will be used for storing | 103 // not call any other functions. The given directory will be used for storing |
| 103 // the history files. The BookmarkService is used when deleting URLs to | 104 // the history files. The BookmarkService is used when deleting URLs to |
| 104 // test if a URL is bookmarked; it may be NULL during testing. | 105 // test if a URL is bookmarked; it may be NULL during testing. |
| 105 bool Init(const base::FilePath& history_dir, BookmarkService* bookmark_service ) { | 106 bool Init(const base::FilePath& history_dir, BookmarkService* bookmark_service ) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 // Returns a pointer to the TypedUrlSyncableService owned by HistoryBackend. | 158 // Returns a pointer to the TypedUrlSyncableService owned by HistoryBackend. |
| 158 // This method should only be called from the history thread, because the | 159 // This method should only be called from the history thread, because the |
| 159 // returned service is intended to be accessed only via the history thread. | 160 // returned service is intended to be accessed only via the history thread. |
| 160 history::TypedUrlSyncableService* GetTypedUrlSyncableService() const; | 161 history::TypedUrlSyncableService* GetTypedUrlSyncableService() const; |
| 161 | 162 |
| 162 // Return the quick history index. | 163 // Return the quick history index. |
| 163 history::InMemoryURLIndex* InMemoryIndex() const { | 164 history::InMemoryURLIndex* InMemoryIndex() const { |
| 164 return in_memory_url_index_.get(); | 165 return in_memory_url_index_.get(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 // KeyedService: | 168 void Shutdown(); |
| 168 virtual void Shutdown() OVERRIDE; | |
| 169 | 169 |
| 170 // Navigation ---------------------------------------------------------------- | 170 // Navigation ---------------------------------------------------------------- |
| 171 | 171 |
| 172 // Adds the given canonical URL to history with the given time as the visit | 172 // Adds the given canonical URL to history with the given time as the visit |
| 173 // time. Referrer may be the empty string. | 173 // time. Referrer may be the empty string. |
| 174 // | 174 // |
| 175 // The supplied render process host is used to scope the given page ID. Page | 175 // The supplied render process host is used to scope the given page ID. Page |
| 176 // IDs are only unique inside a given render process, so we need that to | 176 // IDs are only unique inside a given render process, so we need that to |
| 177 // differentiate them. This pointer should not be dereferenced by the history | 177 // differentiate them. This pointer should not be dereferenced by the history |
| 178 // system. | 178 // system. |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 history::VisitSource visit_source); | 555 history::VisitSource visit_source); |
| 556 | 556 |
| 557 // The same as AddPageWithDetails() but takes a vector. | 557 // The same as AddPageWithDetails() but takes a vector. |
| 558 void AddPagesWithDetails(const history::URLRows& info, | 558 void AddPagesWithDetails(const history::URLRows& info, |
| 559 history::VisitSource visit_source); | 559 history::VisitSource visit_source); |
| 560 | 560 |
| 561 // Returns true if this looks like the type of URL we want to add to the | 561 // Returns true if this looks like the type of URL we want to add to the |
| 562 // history. We filter out some URLs such as JavaScript. | 562 // history. We filter out some URLs such as JavaScript. |
| 563 static bool CanAddURL(const GURL& url); | 563 static bool CanAddURL(const GURL& url); |
| 564 | 564 |
| 565 // Returns the HistoryClient. | |
| 566 history::HistoryClient* history_client() const { return history_client_; } | |
|
blundell
2014/05/27 09:56:38
same comment about const.
sdefresne
2014/05/28 17:10:42
Done.
| |
| 567 | |
| 565 base::WeakPtr<HistoryService> AsWeakPtr(); | 568 base::WeakPtr<HistoryService> AsWeakPtr(); |
| 566 | 569 |
| 567 // syncer::SyncableService implementation. | 570 // syncer::SyncableService implementation. |
| 568 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( | 571 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( |
| 569 syncer::ModelType type, | 572 syncer::ModelType type, |
| 570 const syncer::SyncDataList& initial_sync_data, | 573 const syncer::SyncDataList& initial_sync_data, |
| 571 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 574 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 572 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; | 575 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; |
| 573 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; | 576 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; |
| 574 virtual syncer::SyncDataList GetAllSyncData( | 577 virtual syncer::SyncDataList GetAllSyncData( |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 // This pointer will be NULL once Cleanup() has been called, meaning no | 1015 // This pointer will be NULL once Cleanup() has been called, meaning no |
| 1013 // more calls should be made to the history thread. | 1016 // more calls should be made to the history thread. |
| 1014 scoped_refptr<history::HistoryBackend> history_backend_; | 1017 scoped_refptr<history::HistoryBackend> history_backend_; |
| 1015 | 1018 |
| 1016 // A cache of the user-typed URLs kept in memory that is used by the | 1019 // A cache of the user-typed URLs kept in memory that is used by the |
| 1017 // autocomplete system. This will be NULL until the database has been created | 1020 // autocomplete system. This will be NULL until the database has been created |
| 1018 // on the background thread. | 1021 // on the background thread. |
| 1019 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321 | 1022 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321 |
| 1020 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; | 1023 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; |
| 1021 | 1024 |
| 1025 // The HistoryClient; may be NULL in tests. | |
|
blundell
2014/05/27 09:56:38
add a comment about expected lifetime.
sdefresne
2014/05/28 17:10:42
Done.
| |
| 1026 history::HistoryClient* history_client_; | |
| 1027 | |
| 1022 // The profile, may be null when testing. | 1028 // The profile, may be null when testing. |
| 1023 Profile* profile_; | 1029 Profile* profile_; |
| 1024 | 1030 |
| 1025 // Used for propagating link highlighting data across renderers. May be null | 1031 // Used for propagating link highlighting data across renderers. May be null |
| 1026 // in tests. | 1032 // in tests. |
| 1027 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; | 1033 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; |
| 1028 | 1034 |
| 1029 // Has the backend finished loading? The backend is loaded once Init has | 1035 // Has the backend finished loading? The backend is loaded once Init has |
| 1030 // completed. | 1036 // completed. |
| 1031 bool backend_loaded_; | 1037 bool backend_loaded_; |
| 1032 | 1038 |
| 1033 // Cached values from Init(), used whenever we need to reload the backend. | 1039 // Cached values from Init(), used whenever we need to reload the backend. |
| 1034 base::FilePath history_dir_; | 1040 base::FilePath history_dir_; |
| 1035 BookmarkService* bookmark_service_; | 1041 BookmarkService* bookmark_service_; |
| 1036 bool no_db_; | 1042 bool no_db_; |
| 1037 | 1043 |
| 1038 // The index used for quick history lookups. | 1044 // The index used for quick history lookups. |
| 1039 // TODO(mrossetti): Move in_memory_url_index out of history_service. | 1045 // TODO(mrossetti): Move in_memory_url_index out of history_service. |
| 1040 // See http://crbug.com/138321 | 1046 // See http://crbug.com/138321 |
| 1041 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | 1047 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
| 1042 | 1048 |
| 1043 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; | 1049 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; |
| 1044 | 1050 |
| 1045 history::DeleteDirectiveHandler delete_directive_handler_; | 1051 history::DeleteDirectiveHandler delete_directive_handler_; |
| 1046 | 1052 |
| 1047 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 1053 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
| 1048 }; | 1054 }; |
| 1049 | 1055 |
| 1050 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 1056 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| OLD | NEW |