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

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 of code in ResourcePrefetchPredictor 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..2182b6b00d49e2a2f08d53eec1c7ea4f595cc892 100644
--- a/chrome/browser/sync/glue/bookmark_data_type_controller.cc
+++ b/chrome/browser/sync/glue/bookmark_data_type_controller.cc
@@ -40,24 +40,6 @@ 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_);
@@ -70,17 +52,18 @@ bool BookmarkDataTypeController::StartModels() {
if (!DependentsLoaded()) {
bookmark_model_->AddObserver(this);
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->AddObserver(this);
return false;
}
return true;
}
-// Cleanup for our extra registrar usage.
void BookmarkDataTypeController::CleanUpState() {
- registrar_.RemoveAll();
+ HistoryService* history_service =
+ HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ history_service->RemoveObserver(this);
if (bookmark_model_ && installed_bookmark_observer_) {
bookmark_model_->RemoveObserver(this);
installed_bookmark_observer_ = false;
@@ -107,7 +90,6 @@ void BookmarkDataTypeController::BookmarkModelLoaded(BookmarkModel* model,
if (!DependentsLoaded())
return;
- registrar_.RemoveAll();
OnModelLoaded();
}
@@ -131,4 +113,18 @@ bool BookmarkDataTypeController::DependentsLoaded() {
return true;
}
+void BookmarkDataTypeController::OnHistoryServiceLoaded(
+ HistoryService* service) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_EQ(state_, MODEL_STARTING);
+ service->RemoveObserver(this);
+
+ if (!DependentsLoaded())
+ return;
+
+ bookmark_model_->RemoveObserver(this);
+ installed_bookmark_observer_ = false;
+ OnModelLoaded();
+}
+
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698