Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5974)

Unified Diff: chrome/browser/history/history_backend.cc

Issue 12703036: [Sync] Add interface and backend impl for typed URL syncable service (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor backend change handling and style cleanup Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/history_backend.cc
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index 327896b44682c53e6ce3694ddcd1d2473361bc52..2e1a931fcae8eca63137ec67a4b5847288346aa3 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/history/page_usage_data.h"
#include "chrome/browser/history/select_favicon_frames.h"
#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/history/typed_url_syncable_service.h"
#include "chrome/browser/history/visit_filter.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
@@ -296,6 +297,7 @@ void HistoryBackend::Init(const std::string& languages, bool force_fail) {
if (!force_fail)
InitImpl(languages);
delegate_->DBLoaded(id_);
+ typed_url_syncable_service_.reset(new TypedUrlSyncableService(this));
}
void HistoryBackend::SetOnBackendDestroyTask(MessageLoop* message_loop,
@@ -886,6 +888,10 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
// Broadcast a notification of the visit.
if (visit_id) {
+ if (typed_url_syncable_service_.get()) {
brettw 2013/04/30 22:15:34 No {} for single-line conditionals (match surround
Nicolas Zea 2013/05/06 19:22:43 Done.
+ typed_url_syncable_service_->OnUrlVisited(transition, &url_info);
+ }
+
URLVisitedDetails* details = new URLVisitedDetails;
details->transition = transition;
details->row = url_info;
@@ -980,6 +986,10 @@ void HistoryBackend::AddPagesWithDetails(const URLRows& urls,
}
}
+ if (typed_url_syncable_service_.get()) {
+ typed_url_syncable_service_->OnUrlsModified(&modified->changed_urls);
+ }
+
// Broadcast a notification for typed URLs that have been modified. This
// will be picked up by the in-memory URL database on the main thread.
//
@@ -1037,6 +1047,9 @@ void HistoryBackend::SetPageTitle(const GURL& url,
// Broadcast notifications for any URLs that have changed. This will
// update the in-memory database and the InMemoryURLIndex.
if (!details->changed_urls.empty()) {
+ if (typed_url_syncable_service_.get()) {
+ typed_url_syncable_service_->OnUrlsModified(&details->changed_urls);
+ }
BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
details.release());
ScheduleCommit();
@@ -1174,6 +1187,10 @@ void HistoryBackend::QueryURL(scoped_refptr<QueryURLRequest> request,
request->ForwardResult(request->handle(), success, row, visits);
}
+TypedUrlSyncableService* HistoryBackend::GetTypedUrlSyncableService() const {
+ return typed_url_syncable_service_.get();
+}
+
// Segment usage ---------------------------------------------------------------
void HistoryBackend::DeleteOldSegmentData() {
@@ -2860,13 +2877,23 @@ void HistoryBackend::BroadcastNotifications(
int type,
HistoryDetails* details_deleted) {
// |delegate_| may be NULL if |this| is in the process of closing (closed by
- // HistoryService -> HistroyBackend::Closing().
+ // HistoryService -> HistoryBackend::Closing().
if (delegate_.get())
delegate_->BroadcastNotifications(type, details_deleted);
else
delete details_deleted;
}
+void HistoryBackend::NotifySyncURLsDeleted(bool all_history,
+ bool archived,
+ URLRows* rows) {
+ if (typed_url_syncable_service_.get()) {
+ typed_url_syncable_service_->OnUrlsDeleted(all_history,
brettw 2013/04/30 22:15:34 Doesn't this fit on one line?
Nicolas Zea 2013/05/06 19:22:43 Done.
+ archived,
+ rows);
+ }
+}
+
// Deleting --------------------------------------------------------------------
void HistoryBackend::DeleteAllHistory() {
@@ -2947,6 +2974,7 @@ void HistoryBackend::DeleteAllHistory() {
// will pick this up and clear itself.
URLsDeletedDetails* details = new URLsDeletedDetails;
details->all_history = true;
+ NotifySyncURLsDeleted(true, false, NULL);
BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_DELETED, details);
}

Powered by Google App Engine
This is Rietveld 408576698