Index: chrome/browser/history/visit_database.h |
=================================================================== |
--- chrome/browser/history/visit_database.h (revision 131579) |
+++ chrome/browser/history/visit_database.h (working copy) |
@@ -6,6 +6,7 @@ |
#define CHROME_BROWSER_HISTORY_VISIT_DATABASE_H_ |
#pragma once |
+#include "base/observer_list_threadsafe.h" |
#include "chrome/browser/history/history_types.h" |
namespace sql { |
@@ -17,6 +18,20 @@ |
class VisitFilter; |
+// Abbreviated information about a visit. |
+struct BriefVisitInfo { |
+ URLID url_id; |
+ base::Time time; |
+ content::PageTransition transition; |
+}; |
+ |
+// An observer of VisitDatabase. |
+class VisitDatabaseObserver { |
cbentzel
2012/04/17 20:28:16
Should this handle DeleteVisit and UpdateVisit as
tburkard
2012/04/17 20:51:36
I'm not concerned about these for now, the majorit
|
+ public: |
+ virtual ~VisitDatabaseObserver() {} |
+ virtual void OnAddVisit(BriefVisitInfo info) = 0; |
cbentzel
2012/04/17 20:28:16
Why doesn't this take a const VisitRow& as an argu
tburkard
2012/04/17 20:51:36
Either would work. I figured I'd use BriefVisitIn
cbentzel
2012/04/17 20:57:51
Brett should make the call here - and OWNERS requi
|
+}; |
+ |
// A visit database is one which stores visits for URLs, that is, times and |
// linking information. A visit database must also be a URLDatabase, as this |
// modifies tables used by URLs directly and could be thought of as inheriting |
@@ -172,6 +187,17 @@ |
void GetVisitsSource(const VisitVector& visits, |
VisitSourceMap* sources); |
+ // Adds or removes observers for the VisitDatabase. Should be run on |
+ // the thread in which the observer would like to be notified. |
+ void AddVisitDatabaseObserver(VisitDatabaseObserver* observer); |
+ void RemoveVisitDatabaseObserver(VisitDatabaseObserver* observer); |
+ |
+ // Obtains BriefVisitInfo for the specified number of most recent visits |
+ // from the visit database. |
+ void GetBriefVisitInfoOfMostRecentVisits( |
+ int max_visits, |
+ std::vector<BriefVisitInfo>* result_vector); |
+ |
protected: |
// Returns the database for the functions in this interface. |
virtual sql::Connection& GetDB() = 0; |
@@ -193,6 +219,7 @@ |
bool MigrateVisitsWithoutDuration(); |
private: |
+ scoped_refptr<ObserverListThreadSafe<VisitDatabaseObserver> > observers_; |
DISALLOW_COPY_AND_ASSIGN(VisitDatabase); |
}; |