diff options
author | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-18 00:27:29 +0000 |
---|---|---|
committer | zork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-18 00:27:29 +0000 |
commit | 5315025a1176b7f077b4bf8d2a963e63ea87f988 (patch) | |
tree | 32383a62a01d8609f0be2e01fd3be5fd4b9895cf /chrome/browser/history | |
parent | 7a1c45fe4cb3c4abdd85aa09fa12886ca2fc7be8 (diff) | |
download | chromium_src-5315025a1176b7f077b4bf8d2a963e63ea87f988.zip chromium_src-5315025a1176b7f077b4bf8d2a963e63ea87f988.tar.gz chromium_src-5315025a1176b7f077b4bf8d2a963e63ea87f988.tar.bz2 |
Update sync to support syncing of typed urls
Review URL: http://codereview.chromium.org/896001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r-- | chrome/browser/history/history.cc | 7 | ||||
-rw-r--r-- | chrome/browser/history/history.h | 30 | ||||
-rw-r--r-- | chrome/browser/history/history_backend.cc | 31 | ||||
-rw-r--r-- | chrome/browser/history/history_backend.h | 18 | ||||
-rw-r--r-- | chrome/browser/history/url_database.cc | 14 | ||||
-rw-r--r-- | chrome/browser/history/url_database.h | 4 |
6 files changed, 86 insertions, 18 deletions
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index b1b9d09..fe85e5f 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -86,6 +86,13 @@ class HistoryService::BackendDelegate : public HistoryBackend::Delegate { virtual void BroadcastNotifications(NotificationType type, history::HistoryDetails* details) { + // Send the notification on the history thread. + if (NotificationService::current()) { + Details<history::HistoryDetails> det(details); + NotificationService::current()->Notify(type, + NotificationService::AllSources(), + det); + } // Send the notification to the history service on the main thread. message_loop_->PostTask(FROM_HERE, NewRunnableMethod(history_service_.get(), &HistoryService::BroadcastNotifications, type, details)); diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h index 8f7c68c..2326f8b 100644 --- a/chrome/browser/history/history.h +++ b/chrome/browser/history/history.h @@ -41,6 +41,11 @@ class Thread; class Time; } +namespace browser_sync { +class HistoryModelWorker; +class TypedUrlDataTypeController; +} + namespace history { class InMemoryHistoryBackend; @@ -492,8 +497,8 @@ class HistoryService : public CancelableRequestProvider, // Schedules a HistoryDBTask for running on the history backend thread. See // HistoryDBTask for details on what this does. - Handle ScheduleDBTask(HistoryDBTask* task, - CancelableRequestConsumerBase* consumer); + virtual Handle ScheduleDBTask(HistoryDBTask* task, + CancelableRequestConsumerBase* consumer); // Testing ------------------------------------------------------------------- @@ -525,6 +530,17 @@ class HistoryService : public CancelableRequestProvider, // The same as AddPageWithDetails() but takes a vector. void AddPagesWithDetails(const std::vector<history::URLRow>& info); + protected: + ~HistoryService(); + + // These are not currently used, hopefully we can do something in the future + // to ensure that the most important things happen first. + enum SchedulePriority { + PRIORITY_UI, // The highest priority (must respond to UI events). + PRIORITY_NORMAL, // Normal stuff like adding a page. + PRIORITY_LOW, // Low priority things like indexing or expiration. + }; + private: class BackendDelegate; friend class base::RefCountedThreadSafe<HistoryService>; @@ -541,16 +557,6 @@ class HistoryService : public CancelableRequestProvider, friend class FavIconRequest; friend class TestingProfile; - ~HistoryService(); - - // These are not currently used, hopefully we can do something in the future - // to ensure that the most important things happen first. - enum SchedulePriority { - PRIORITY_UI, // The highest priority (must respond to UI events). - PRIORITY_NORMAL, // Normal stuff like adding a page. - PRIORITY_LOW, // Low priority things like indexing or expiration. - }; - // Implementation of NotificationObserver. virtual void Observe(NotificationType type, const NotificationSource& source, diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc index 420095e..58fa489 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -689,7 +689,6 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( return std::make_pair(url_id, visit_id); } -// Note: this method is only for testing purposes. void HistoryBackend::AddPagesWithDetails(const std::vector<URLRow>& urls) { if (!db_.get()) return; @@ -850,6 +849,24 @@ void HistoryBackend::IterateURLs(HistoryService::URLEnumerator* iterator) { iterator->OnComplete(false); // Failure. } +bool HistoryBackend::GetAllTypedURLs(std::vector<history::URLRow>* urls) { + if (db_.get()) + return db_->GetAllTypedUrls(urls); + return false; +} + +bool HistoryBackend::UpdateURL(const URLID id, const history::URLRow& url) { + if (db_.get()) + return db_->UpdateURLRow(id, url); + return false; +} + +bool HistoryBackend::GetURL(const GURL& url, history::URLRow* url_row) { + if (db_.get()) + return db_->GetRowForURL(url, url_row) != 0; + return false; +} + void HistoryBackend::QueryURL(scoped_refptr<QueryURLRequest> request, const GURL& url, bool want_visits) { @@ -1730,6 +1747,18 @@ void HistoryBackend::ReleaseDBTasks() { // //////////////////////////////////////////////////////////////////////////////// +void HistoryBackend::DeleteURLs(const std::vector<GURL>& urls) { + for (std::vector<GURL>::const_iterator url = urls.begin(); url != urls.end(); + ++url) { + expirer_.DeleteURL(*url); + } + + db_->GetStartDate(&first_recorded_time_); + // Force a commit, if the user is deleting something for privacy reasons, we + // want to get it on disk ASAP. + Commit(); +} + void HistoryBackend::DeleteURL(const GURL& url) { expirer_.DeleteURL(url); diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index cfd1637..7d230c6 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -112,8 +112,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // Navigation ---------------------------------------------------------------- void AddPage(scoped_refptr<HistoryAddPageArgs> request); - void SetPageTitle(const GURL& url, const std::wstring& title); - void AddPageWithDetails(const URLRow& info); + virtual void SetPageTitle(const GURL& url, const std::wstring& title); // Indexing ------------------------------------------------------------------ @@ -239,9 +238,17 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, void ProcessDBTask(scoped_refptr<HistoryDBTaskRequest> request); + virtual bool GetAllTypedURLs(std::vector<history::URLRow>* urls); + + virtual bool UpdateURL(const URLID id, const history::URLRow& url); + + virtual bool GetURL(const GURL& url, history::URLRow* url_row); + // Deleting ------------------------------------------------------------------ - void DeleteURL(const GURL& url); + virtual void DeleteURLs(const std::vector<GURL>& urls); + + virtual void DeleteURL(const GURL& url); // Calls ExpireHistoryBackend::ExpireHistoryBetween and commits the change. void ExpireHistoryBetween(scoped_refptr<ExpireHistoryRequest> request, @@ -272,6 +279,9 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, ExpireHistoryBackend* expire_backend() { return &expirer_; } #endif + protected: + virtual ~HistoryBackend(); + private: friend class base::RefCountedThreadSafe<HistoryBackend>; friend class CommitLaterTask; // The commit task needs to call Commit(). @@ -282,8 +292,6 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, FRIEND_TEST(HistoryBackendTest, StripUsernamePasswordTest); friend class ::TestingProfile; - ~HistoryBackend(); - // Computes the name of the specified database on disk. FilePath GetThumbnailFileName() const; FilePath GetArchivedFileName() const; diff --git a/chrome/browser/history/url_database.cc b/chrome/browser/history/url_database.cc index c5c6199..e1c8106 100644 --- a/chrome/browser/history/url_database.cc +++ b/chrome/browser/history/url_database.cc @@ -79,6 +79,20 @@ bool URLDatabase::GetURLRow(URLID url_id, URLRow* info) { return false; } +bool URLDatabase::GetAllTypedUrls(std::vector<history::URLRow>* urls) { + sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, + "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE typed_count > 0")); + if (!statement) + return false; + + while (statement.Step()) { + URLRow info; + FillURLRow(statement, &info); + urls->push_back(info); + } + return true; +} + URLID URLDatabase::GetRowForURL(const GURL& url, history::URLRow* info) { sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE url=?")); diff --git a/chrome/browser/history/url_database.h b/chrome/browser/history/url_database.h index 6e2eca1..9fb67b4 100644 --- a/chrome/browser/history/url_database.h +++ b/chrome/browser/history/url_database.h @@ -54,6 +54,10 @@ class URLDatabase { // success and false otherwise. bool GetURLRow(URLID url_id, URLRow* info); + // Looks up all urls that were typed in manually. Fills info with the data. + // Returns true on success and false otherwise. + bool GetAllTypedUrls(std::vector<history::URLRow>* urls); + // Looks up the given URL and if it exists, fills the given pointers with the // associated info and returns the ID of that URL. If the info pointer is // NULL, no information about the URL will be filled in, only the ID will be |