Index: chrome/browser/history/history_backend.h |
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h |
index 819f9df23ac95562c13bf15b6ad70defa82b15b9..fbf0ff32bac9daf64b156f4a4162785a56b3533e 100644 |
--- a/chrome/browser/history/history_backend.h |
+++ b/chrome/browser/history/history_backend.h |
@@ -15,6 +15,7 @@ |
#include "base/gtest_prod_util.h" |
#include "base/memory/memory_pressure_listener.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/observer_list.h" |
#include "base/single_thread_task_runner.h" |
#include "base/task/cancelable_task_tracker.h" |
#include "chrome/browser/history/expire_history_backend.h" |
@@ -49,6 +50,7 @@ class AndroidProviderBackend; |
class CommitLaterTask; |
struct DownloadRow; |
+class HistoryBackendObserver; |
class HistoryClient; |
class HistoryDBTask; |
class InMemoryHistoryBackend; |
@@ -122,12 +124,19 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
// Notify HistoryService that VisitDatabase was changed. The event will be |
// forwarded to the history::HistoryServiceObservers in the UI thread. |
- virtual void NotifyAddVisit(const history::BriefVisitInfo& info) = 0; |
+ virtual void NotifyAddVisit(const BriefVisitInfo& info) = 0; |
// Notify HistoryService that some URLs favicon changed that will forward |
// the events to the FaviconChangedObservers in the correct thread. |
virtual void NotifyFaviconChanged(const std::set<GURL>& urls) = 0; |
+ // Notify HistoryService that the user is visiting an URL. The event will |
+ // be forwarded to the HistoryServiceObservers in the correct thread. |
+ virtual void NotifyURLVisited(ui::PageTransition transition, |
+ const URLRow& row, |
+ const RedirectList& redirects, |
+ base::Time visit_time) = 0; |
+ |
// Broadcasts the specified notification to the notification service. |
// This is implemented here because notifications must only be sent from |
// the main thread. This is the only method that doesn't identify the |
@@ -303,6 +312,11 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
void DeleteMatchingURLsForKeyword(KeywordID keyword_id, |
const base::string16& term); |
+ // Observers ----------------------------------------------------------------- |
+ |
+ void AddObserver(HistoryBackendObserver* observer); |
+ void RemoveObserver(HistoryBackendObserver* observer); |
+ |
#if defined(OS_ANDROID) |
// Android Provider --------------------------------------------------------- |
@@ -505,6 +519,13 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
protected: |
virtual ~HistoryBackend(); |
+ // Notify HistoryBackendObserver that |transition| to |row| occurred at |
+ // |visit_time| following |redirects| (empty if there is no redirects). |
+ void NotifyAddVisit(ui::PageTransition transition, |
+ const URLRow& row, |
+ const RedirectList& redirects, |
+ base::Time visit_time); |
+ |
private: |
friend class base::RefCountedThreadSafe<HistoryBackend>; |
friend class CommitLaterTask; // The commit task needs to call Commit(). |
@@ -889,11 +910,17 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
// Used to manage syncing of the typed urls datatype. This will be NULL |
// before Init is called. |
+ // TODO(sdefresne): turn TypedUrlSyncableService into a HistoryBackendObserver |
+ // and remove this field since it is only used for forwarding notifications |
+ // about URL visited, modified, deleted. |
scoped_ptr<TypedUrlSyncableService> typed_url_syncable_service_; |
// Listens for the system being under memory pressure. |
scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
+ // List of observers |
+ ObserverList<HistoryBackendObserver> observers_; |
+ |
DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
}; |