Index: chrome/browser/history/history.cc |
=================================================================== |
--- chrome/browser/history/history.cc (revision 133528) |
+++ chrome/browser/history/history.cc (working copy) |
@@ -40,6 +40,7 @@ |
#include "chrome/browser/history/in_memory_history_backend.h" |
#include "chrome/browser/history/in_memory_url_index.h" |
#include "chrome/browser/history/top_sites.h" |
+#include "chrome/browser/history/visit_database.h" |
#include "chrome/browser/history/visit_filter.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
@@ -127,6 +128,13 @@ |
history_service_.get(), backend_id)); |
} |
+ virtual void NotifyVisitDBObserversOnAddVisit( |
+ const history::BriefVisitInfo& info) OVERRIDE { |
+ // Since the notification method can be run on any thread, we can |
+ // call it right away. |
+ history_service_->NotifyVisitDBObserversOnAddVisit(info); |
+ } |
+ |
private: |
scoped_refptr<HistoryService> history_service_; |
MessageLoop* message_loop_; |
@@ -143,7 +151,9 @@ |
current_backend_id_(-1), |
bookmark_service_(NULL), |
no_db_(false), |
- needs_top_sites_migration_(false) { |
+ needs_top_sites_migration_(false), |
+ visit_database_observers_( |
+ new ObserverListThreadSafe<history::VisitDatabaseObserver>()) { |
} |
HistoryService::HistoryService(Profile* profile) |
@@ -153,7 +163,9 @@ |
current_backend_id_(-1), |
bookmark_service_(NULL), |
no_db_(false), |
- needs_top_sites_migration_(false) { |
+ needs_top_sites_migration_(false), |
+ visit_database_observers_( |
+ new ObserverListThreadSafe<history::VisitDatabaseObserver>()) { |
DCHECK(profile_); |
registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
content::Source<Profile>(profile_)); |
@@ -892,3 +904,19 @@ |
ScheduleAndForget(PRIORITY_NORMAL, |
&HistoryBackend::MigrateThumbnailsDatabase); |
} |
+ |
+void HistoryService::AddVisitDatabaseObserver( |
+ history::VisitDatabaseObserver* observer) { |
+ visit_database_observers_->AddObserver(observer); |
+} |
+ |
+void HistoryService::RemoveVisitDatabaseObserver( |
+ history::VisitDatabaseObserver* observer) { |
+ visit_database_observers_->RemoveObserver(observer); |
+} |
+ |
+void HistoryService::NotifyVisitDBObserversOnAddVisit( |
+ const history::BriefVisitInfo& info) { |
+ visit_database_observers_->Notify( |
+ &history::VisitDatabaseObserver::OnAddVisit, info); |
+} |