| 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 10 matching lines...) Expand all Loading... |
| 21 #include "base/task/cancelable_task_tracker.h" | 21 #include "base/task/cancelable_task_tracker.h" |
| 22 #include "base/threading/thread_checker.h" | 22 #include "base/threading/thread_checker.h" |
| 23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
| 24 #include "chrome/browser/common/cancelable_request.h" | 24 #include "chrome/browser/common/cancelable_request.h" |
| 25 #include "chrome/browser/history/delete_directive_handler.h" | 25 #include "chrome/browser/history/delete_directive_handler.h" |
| 26 #include "chrome/browser/history/history_types.h" | 26 #include "chrome/browser/history/history_types.h" |
| 27 #include "chrome/browser/history/typed_url_syncable_service.h" | 27 #include "chrome/browser/history/typed_url_syncable_service.h" |
| 28 #include "chrome/browser/search_engines/template_url_id.h" | 28 #include "chrome/browser/search_engines/template_url_id.h" |
| 29 #include "chrome/common/ref_counted_util.h" | 29 #include "chrome/common/ref_counted_util.h" |
| 30 #include "components/favicon_base/favicon_callback.h" | 30 #include "components/favicon_base/favicon_callback.h" |
| 31 #include "components/history/core/browser/history_client.h" |
| 31 #include "components/keyed_service/core/keyed_service.h" | 32 #include "components/keyed_service/core/keyed_service.h" |
| 32 #include "components/visitedlink/browser/visitedlink_delegate.h" | 33 #include "components/visitedlink/browser/visitedlink_delegate.h" |
| 33 #include "content/public/browser/download_manager_delegate.h" | 34 #include "content/public/browser/download_manager_delegate.h" |
| 34 #include "content/public/browser/notification_observer.h" | 35 #include "content/public/browser/notification_observer.h" |
| 35 #include "content/public/browser/notification_registrar.h" | 36 #include "content/public/browser/notification_registrar.h" |
| 36 #include "content/public/common/page_transition_types.h" | 37 #include "content/public/common/page_transition_types.h" |
| 37 #include "sql/init_status.h" | 38 #include "sql/init_status.h" |
| 38 #include "sync/api/syncable_service.h" | 39 #include "sync/api/syncable_service.h" |
| 39 #include "ui/base/layout.h" | 40 #include "ui/base/layout.h" |
| 40 | 41 |
| 41 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| 42 class AndroidHistoryProviderService; | 43 class AndroidHistoryProviderService; |
| 43 #endif | 44 #endif |
| 44 | 45 |
| 45 class BookmarkService; | |
| 46 class GURL; | 46 class GURL; |
| 47 class HistoryURLProvider; | 47 class HistoryURLProvider; |
| 48 class PageUsageData; | 48 class PageUsageData; |
| 49 class PageUsageRequest; | 49 class PageUsageRequest; |
| 50 class Profile; | 50 class Profile; |
| 51 struct HistoryURLProviderParams; | 51 struct HistoryURLProviderParams; |
| 52 struct ImportedFaviconUsage; | 52 struct ImportedFaviconUsage; |
| 53 | 53 |
| 54 namespace base { | 54 namespace base { |
| 55 class FilePath; | 55 class FilePath; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Must call Init after construction. The |history::HistoryClient| object | 96 // Must call Init after construction. The |history::HistoryClient| object |
| 97 // must be valid for the whole lifetime of |HistoryService|. | 97 // must be valid for the whole lifetime of |HistoryService|. |
| 98 explicit HistoryService(history::HistoryClient* client, Profile* profile); | 98 explicit HistoryService(history::HistoryClient* client, Profile* profile); |
| 99 // The empty constructor is provided only for testing. | 99 // The empty constructor is provided only for testing. |
| 100 HistoryService(); | 100 HistoryService(); |
| 101 | 101 |
| 102 virtual ~HistoryService(); | 102 virtual ~HistoryService(); |
| 103 | 103 |
| 104 // Initializes the history service, returning true on success. On false, do | 104 // Initializes the history service, returning true on success. On false, do |
| 105 // not call any other functions. The given directory will be used for storing | 105 // not call any other functions. The given directory will be used for storing |
| 106 // the history files. The BookmarkService is used when deleting URLs to | 106 // the history files. |
| 107 // test if a URL is bookmarked; it may be NULL during testing. | 107 bool Init(const base::FilePath& history_dir) { |
| 108 bool Init(const base::FilePath& history_dir, BookmarkService* bookmark_service
) { | 108 return Init(history_dir, false); |
| 109 return Init(history_dir, bookmark_service, false); | |
| 110 } | 109 } |
| 111 | 110 |
| 112 // Triggers the backend to load if it hasn't already, and then returns whether | 111 // Triggers the backend to load if it hasn't already, and then returns whether |
| 113 // it's finished loading. | 112 // it's finished loading. |
| 114 // Note: Virtual needed for mocking. | 113 // Note: Virtual needed for mocking. |
| 115 virtual bool BackendLoaded(); | 114 virtual bool BackendLoaded(); |
| 116 | 115 |
| 117 // Returns true if the backend has finished loading. | 116 // Returns true if the backend has finished loading. |
| 118 bool backend_loaded() const { return backend_loaded_; } | 117 bool backend_loaded() const { return backend_loaded_; } |
| 119 | 118 |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 virtual void Observe(int type, | 615 virtual void Observe(int type, |
| 617 const content::NotificationSource& source, | 616 const content::NotificationSource& source, |
| 618 const content::NotificationDetails& details) OVERRIDE; | 617 const content::NotificationDetails& details) OVERRIDE; |
| 619 | 618 |
| 620 // Implementation of visitedlink::VisitedLinkDelegate. | 619 // Implementation of visitedlink::VisitedLinkDelegate. |
| 621 virtual void RebuildTable( | 620 virtual void RebuildTable( |
| 622 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; | 621 const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE; |
| 623 | 622 |
| 624 // Low-level Init(). Same as the public version, but adds a |no_db| parameter | 623 // Low-level Init(). Same as the public version, but adds a |no_db| parameter |
| 625 // that is only set by unittests which causes the backend to not init its DB. | 624 // that is only set by unittests which causes the backend to not init its DB. |
| 626 bool Init(const base::FilePath& history_dir, | 625 bool Init(const base::FilePath& history_dir, bool no_db); |
| 627 BookmarkService* bookmark_service, | |
| 628 bool no_db); | |
| 629 | 626 |
| 630 // Called by the HistoryURLProvider class to schedule an autocomplete, it | 627 // Called by the HistoryURLProvider class to schedule an autocomplete, it |
| 631 // will be called back on the internal history thread with the history | 628 // will be called back on the internal history thread with the history |
| 632 // database so it can query. See history_autocomplete.cc for a diagram. | 629 // database so it can query. See history_autocomplete.cc for a diagram. |
| 633 void ScheduleAutocomplete(HistoryURLProvider* provider, | 630 void ScheduleAutocomplete(HistoryURLProvider* provider, |
| 634 HistoryURLProviderParams* params); | 631 HistoryURLProviderParams* params); |
| 635 | 632 |
| 636 // Broadcasts the given notification. This is called by the backend so that | 633 // Broadcasts the given notification. This is called by the backend so that |
| 637 // the notification will be broadcast on the main thread. | 634 // the notification will be broadcast on the main thread. |
| 638 void BroadcastNotificationsHelper( | 635 void BroadcastNotificationsHelper( |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 // Used for propagating link highlighting data across renderers. May be null | 1032 // Used for propagating link highlighting data across renderers. May be null |
| 1036 // in tests. | 1033 // in tests. |
| 1037 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; | 1034 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; |
| 1038 | 1035 |
| 1039 // Has the backend finished loading? The backend is loaded once Init has | 1036 // Has the backend finished loading? The backend is loaded once Init has |
| 1040 // completed. | 1037 // completed. |
| 1041 bool backend_loaded_; | 1038 bool backend_loaded_; |
| 1042 | 1039 |
| 1043 // Cached values from Init(), used whenever we need to reload the backend. | 1040 // Cached values from Init(), used whenever we need to reload the backend. |
| 1044 base::FilePath history_dir_; | 1041 base::FilePath history_dir_; |
| 1045 BookmarkService* bookmark_service_; | |
| 1046 bool no_db_; | 1042 bool no_db_; |
| 1047 | 1043 |
| 1048 // The index used for quick history lookups. | 1044 // The index used for quick history lookups. |
| 1049 // TODO(mrossetti): Move in_memory_url_index out of history_service. | 1045 // TODO(mrossetti): Move in_memory_url_index out of history_service. |
| 1050 // See http://crbug.com/138321 | 1046 // See http://crbug.com/138321 |
| 1051 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; | 1047 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; |
| 1052 | 1048 |
| 1053 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; | 1049 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; |
| 1054 | 1050 |
| 1055 history::DeleteDirectiveHandler delete_directive_handler_; | 1051 history::DeleteDirectiveHandler delete_directive_handler_; |
| 1056 | 1052 |
| 1057 DISALLOW_COPY_AND_ASSIGN(HistoryService); | 1053 DISALLOW_COPY_AND_ASSIGN(HistoryService); |
| 1058 }; | 1054 }; |
| 1059 | 1055 |
| 1060 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ | 1056 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ |
| OLD | NEW |