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

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: 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..5019c140a7d213f937947f70fffdea567edf45f1 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,
@@ -889,6 +891,11 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
URLVisitedDetails* details = new URLVisitedDetails;
details->transition = transition;
details->row = url_info;
+
+ // Notify typed url sync
Andrew T Wilson (Slow) 2013/04/09 12:48:30 nit: use sentence punctuation.
+ if (typed_url_syncable_service_.get()) {
Andrew T Wilson (Slow) 2013/04/09 12:48:30 nit: omit braces on single-line if statements, bec
+ typed_url_syncable_service_->OnUrlVisited(details);
+ }
// TODO(meelapshah) Disabled due to potential PageCycler regression.
// Re-enable this.
// GetMostRecentRedirectsTo(url, &details->redirects);
@@ -980,6 +987,11 @@ void HistoryBackend::AddPagesWithDetails(const URLRows& urls,
}
}
+ // Notify typed url sync
Andrew T Wilson (Slow) 2013/04/09 12:48:30 Nit: use sentence punctuation (here and below).
+ if (typed_url_syncable_service_.get()) {
+ typed_url_syncable_service_->OnUrlsModified(modified.get());
+ }
+
// 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.
//
@@ -1034,6 +1046,11 @@ void HistoryBackend::SetPageTitle(const GURL& url,
}
}
+ // Notify typed url sync
+ if (typed_url_syncable_service_.get()) {
+ typed_url_syncable_service_->OnUrlsModified(details.get());
+ }
+
// Broadcast notifications for any URLs that have changed. This will
// update the in-memory database and the InMemoryURLIndex.
if (!details->changed_urls.empty()) {
@@ -1174,6 +1191,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,11 +2881,20 @@ 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().
- if (delegate_.get())
+ // HistoryService -> HistoryBackend::Closing().
+ if (delegate_.get()) {
+ // Typed urls sync service is called here to handle deleted urls, including
+ // expirations from ExpireHistoryBackend. New and visited url handling is
+ // called separately.
+ if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED &&
Andrew T Wilson (Slow) 2013/04/09 12:48:30 It seems weird that we're doing deletions via Broa
+ typed_url_syncable_service_.get()) {
+ typed_url_syncable_service_->OnUrlsDeleted(
+ static_cast<history::URLsDeletedDetails*>(details_deleted));
+ }
delegate_->BroadcastNotifications(type, details_deleted);
- else
+ } else {
delete details_deleted;
+ }
}
// Deleting --------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698