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

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

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up bookmark_data_type_controller Created 6 years, 1 month 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 9e9da929d0b0829a95c485f6dff5812b09d52234..4cbd35c46e91de53ccb2fab54ede0752acddce46 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
@@ -33,58 +33,35 @@ BookmarkDataTypeController::BookmarkDataTypeController(
profile,
sync_service),
bookmark_model_(NULL),
- installed_bookmark_observer_(false) {
+ installed_bookmark_observer_(false),
sdefresne 2014/11/05 14:51:52 You can remove installed_bookmark_observer_ everyw
nshaik 2014/11/06 02:05:12 Took care of this, but I had to listen to NOTIFICA
+ history_service_observer_(this),
+ bookmark_model_observer_(this) {
}
syncer::ModelType BookmarkDataTypeController::type() const {
return syncer::BOOKMARKS;
}
-void BookmarkDataTypeController::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK_EQ(state_, MODEL_STARTING);
- DCHECK_EQ(chrome::NOTIFICATION_HISTORY_LOADED, type);
-
- if (!DependentsLoaded())
- return;
-
- bookmark_model_->RemoveObserver(this);
- installed_bookmark_observer_ = false;
-
- registrar_.RemoveAll();
- OnModelLoaded();
-}
-
BookmarkDataTypeController::~BookmarkDataTypeController() {
- if (installed_bookmark_observer_ && bookmark_model_) {
- DCHECK(profile_);
- bookmark_model_->RemoveObserver(this);
- }
}
bool BookmarkDataTypeController::StartModels() {
bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_);
if (!DependentsLoaded()) {
- bookmark_model_->AddObserver(this);
+ bookmark_model_observer_.Add(bookmark_model_);
installed_bookmark_observer_ = true;
-
- registrar_.Add(this, chrome::NOTIFICATION_HISTORY_LOADED,
- content::Source<Profile>(sync_service_->profile()));
+ HistoryService* history_service = HistoryServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ history_service_observer_.Add(history_service);
return false;
}
return true;
}
-// Cleanup for our extra registrar usage.
void BookmarkDataTypeController::CleanUpState() {
- registrar_.RemoveAll();
- if (bookmark_model_ && installed_bookmark_observer_) {
- bookmark_model_->RemoveObserver(this);
- installed_bookmark_observer_ = false;
- }
+ history_service_observer_.RemoveAll();
+ bookmark_model_observer_.RemoveAll();
+ installed_bookmark_observer_ = false;
}
void BookmarkDataTypeController::CreateSyncComponents() {
@@ -101,13 +78,13 @@ void BookmarkDataTypeController::BookmarkModelChanged() {
void BookmarkDataTypeController::BookmarkModelLoaded(BookmarkModel* model,
bool ids_reassigned) {
DCHECK(model->loaded());
- model->RemoveObserver(this);
+ bookmark_model_observer_.RemoveAll();
installed_bookmark_observer_ = false;
if (!DependentsLoaded())
return;
- registrar_.RemoveAll();
+ history_service_observer_.RemoveAll();
OnModelLoaded();
}
@@ -131,4 +108,18 @@ bool BookmarkDataTypeController::DependentsLoaded() {
return true;
}
+void BookmarkDataTypeController::OnHistoryServiceLoaded(
+ HistoryService* service) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_EQ(state_, MODEL_STARTING);
+ history_service_observer_.RemoveAll();
+
+ if (!DependentsLoaded())
+ return;
+
+ bookmark_model_observer_.RemoveAll();
+ installed_bookmark_observer_ = false;
+ OnModelLoaded();
+}
+
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698