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

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

Issue 10702074: Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to HEAD Created 8 years, 5 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/chrome_sync_notification_bridge.cc
diff --git a/chrome/browser/sync/glue/chrome_sync_notification_bridge.cc b/chrome/browser/sync/glue/chrome_sync_notification_bridge.cc
index 76b62bf4755e72e2aaa8fe8d45fbeff07700514d..31db8e2da4443d733b4e32e7b0ea16017d908219 100644
--- a/chrome/browser/sync/glue/chrome_sync_notification_bridge.cc
+++ b/chrome/browser/sync/glue/chrome_sync_notification_bridge.cc
@@ -6,10 +6,10 @@
#include "base/bind.h"
#include "base/location.h"
-#include "base/observer_list.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
+#include "sync/notifier/sync_notifier_helper.h"
#include "sync/notifier/sync_notifier_observer.h"
using content::BrowserThread;
@@ -26,8 +26,8 @@ class ChromeSyncNotificationBridge::Core
// All member functions below must be called on the sync task runner.
void UpdateEnabledTypes(syncer::ModelTypeSet enabled_types);
- void AddObserver(syncer::SyncNotifierObserver* observer);
- void RemoveObserver(syncer::SyncNotifierObserver* observer);
+ void UpdateRegisteredIds(syncer::SyncNotifierObserver* handler,
+ const syncer::ObjectIdSet& ids);
void EmitNotification(
const syncer::ModelTypePayloadMap& payload_map,
@@ -43,7 +43,7 @@ class ChromeSyncNotificationBridge::Core
// Used only on |sync_task_runner_|.
syncer::ModelTypeSet enabled_types_;
- ObserverList<syncer::SyncNotifierObserver> observers_;
+ syncer::SyncNotifierHelper helper_;
};
ChromeSyncNotificationBridge::Core::Core(
@@ -64,16 +64,11 @@ void ChromeSyncNotificationBridge::Core::UpdateEnabledTypes(
enabled_types_ = types;
}
-void ChromeSyncNotificationBridge::Core::AddObserver(
- syncer::SyncNotifierObserver* observer) {
+void ChromeSyncNotificationBridge::Core::UpdateRegisteredIds(
+ syncer::SyncNotifierObserver* handler,
+ const syncer::ObjectIdSet& ids) {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- observers_.AddObserver(observer);
-}
-
-void ChromeSyncNotificationBridge::Core::RemoveObserver(
- syncer::SyncNotifierObserver* observer) {
- DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- observers_.RemoveObserver(observer);
+ helper_.UpdateRegisteredIds(handler, ids);
}
void ChromeSyncNotificationBridge::Core::EmitNotification(
@@ -85,9 +80,9 @@ void ChromeSyncNotificationBridge::Core::EmitNotification(
syncer::ModelTypePayloadMapFromEnumSet(enabled_types_, std::string()) :
payload_map;
- FOR_EACH_OBSERVER(
- syncer::SyncNotifierObserver, observers_,
- OnIncomingNotification(effective_payload_map, notification_source));
+ helper_.DispatchInvalidationsToHandlers(
+ ModelTypePayloadMapToObjectIdPayloadMap(effective_payload_map),
+ notification_source);
}
ChromeSyncNotificationBridge::ChromeSyncNotificationBridge(
@@ -111,16 +106,11 @@ void ChromeSyncNotificationBridge::UpdateEnabledTypes(
core_->UpdateEnabledTypes(types);
}
-void ChromeSyncNotificationBridge::AddObserver(
- syncer::SyncNotifierObserver* observer) {
- DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- core_->AddObserver(observer);
-}
-
-void ChromeSyncNotificationBridge::RemoveObserver(
- syncer::SyncNotifierObserver* observer) {
+void ChromeSyncNotificationBridge::UpdateRegisteredIds(
+ syncer::SyncNotifierObserver* handler,
+ const syncer::ObjectIdSet& ids) {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- core_->RemoveObserver(observer);
+ core_->UpdateRegisteredIds(handler, ids);
}
void ChromeSyncNotificationBridge::Observe(

Powered by Google App Engine
This is Rietveld 408576698