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

Unified Diff: chrome/browser/sync/glue/bookmark_data_type_controller.cc

Issue 12084058: sync/glue: Convert BookmarkDataTypeController to BaseBookmarkModelObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: BookmarkModelPolicy Created 7 years, 10 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/sync/glue/bookmark_data_type_controller.cc
diff --git a/chrome/browser/sync/glue/bookmark_data_type_controller.cc b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
index 14116abc9a1b3549ec55cacfa2ff920ec191c7c7..bfbb061a5e0db26430690e2c9d47a783a625b009 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
@@ -40,12 +40,14 @@ void BookmarkDataTypeController::Observe(
const content::NotificationDetails& details) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(state_, MODEL_STARTING);
- if (type != chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED &&
- type != chrome::NOTIFICATION_HISTORY_LOADED) {
- return;
- }
+ DCHECK_EQ(chrome::NOTIFICATION_HISTORY_LOADED, type);
+
if (!DependentsLoaded())
return;
+
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_);
+ model->RemoveObserver(this);
+
registrar_.RemoveAll();
OnModelLoaded();
}
@@ -54,8 +56,9 @@ BookmarkDataTypeController::~BookmarkDataTypeController() {}
bool BookmarkDataTypeController::StartModels() {
if (!DependentsLoaded()) {
- registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
- content::Source<Profile>(sync_service_->profile()));
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_);
+ model->AddObserver(this);
+
registrar_.Add(this, chrome::NOTIFICATION_HISTORY_LOADED,
content::Source<Profile>(sync_service_->profile()));
return false;
@@ -76,6 +79,20 @@ void BookmarkDataTypeController::CreateSyncComponents() {
set_change_processor(sync_components.change_processor);
}
+void BookmarkDataTypeController::BookmarkModelChanged() {
+}
+
+void BookmarkDataTypeController::Loaded(BookmarkModel* model,
+ bool ids_reassigned) {
+ model->RemoveObserver(this);
+
+ if (!DependentsLoaded())
+ return;
+
+ registrar_.RemoveAll();
+ OnModelLoaded();
+}
+
// Check that both the bookmark model and the history service (for favicons)
// are loaded.
bool BookmarkDataTypeController::DependentsLoaded() {

Powered by Google App Engine
This is Rietveld 408576698