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 31db8e2da4443d733b4e32e7b0ea16017d908219..76b62bf4755e72e2aaa8fe8d45fbeff07700514d 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 UpdateRegisteredIds(syncer::SyncNotifierObserver* handler, |
- const syncer::ObjectIdSet& ids); |
+ void AddObserver(syncer::SyncNotifierObserver* observer); |
+ void RemoveObserver(syncer::SyncNotifierObserver* observer); |
void EmitNotification( |
const syncer::ModelTypePayloadMap& payload_map, |
@@ -43,7 +43,7 @@ class ChromeSyncNotificationBridge::Core |
// Used only on |sync_task_runner_|. |
syncer::ModelTypeSet enabled_types_; |
- syncer::SyncNotifierHelper helper_; |
+ ObserverList<syncer::SyncNotifierObserver> observers_; |
}; |
ChromeSyncNotificationBridge::Core::Core( |
@@ -64,11 +64,16 @@ void ChromeSyncNotificationBridge::Core::UpdateEnabledTypes( |
enabled_types_ = types; |
} |
-void ChromeSyncNotificationBridge::Core::UpdateRegisteredIds( |
- syncer::SyncNotifierObserver* handler, |
- const syncer::ObjectIdSet& ids) { |
+void ChromeSyncNotificationBridge::Core::AddObserver( |
+ syncer::SyncNotifierObserver* observer) { |
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
- helper_.UpdateRegisteredIds(handler, ids); |
+ observers_.AddObserver(observer); |
+} |
+ |
+void ChromeSyncNotificationBridge::Core::RemoveObserver( |
+ syncer::SyncNotifierObserver* observer) { |
+ DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
+ observers_.RemoveObserver(observer); |
} |
void ChromeSyncNotificationBridge::Core::EmitNotification( |
@@ -80,9 +85,9 @@ void ChromeSyncNotificationBridge::Core::EmitNotification( |
syncer::ModelTypePayloadMapFromEnumSet(enabled_types_, std::string()) : |
payload_map; |
- helper_.DispatchInvalidationsToHandlers( |
- ModelTypePayloadMapToObjectIdPayloadMap(effective_payload_map), |
- notification_source); |
+ FOR_EACH_OBSERVER( |
+ syncer::SyncNotifierObserver, observers_, |
+ OnIncomingNotification(effective_payload_map, notification_source)); |
} |
ChromeSyncNotificationBridge::ChromeSyncNotificationBridge( |
@@ -106,11 +111,16 @@ void ChromeSyncNotificationBridge::UpdateEnabledTypes( |
core_->UpdateEnabledTypes(types); |
} |
-void ChromeSyncNotificationBridge::UpdateRegisteredIds( |
- syncer::SyncNotifierObserver* handler, |
- const syncer::ObjectIdSet& ids) { |
+void ChromeSyncNotificationBridge::AddObserver( |
+ syncer::SyncNotifierObserver* observer) { |
+ DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
+ core_->AddObserver(observer); |
+} |
+ |
+void ChromeSyncNotificationBridge::RemoveObserver( |
+ syncer::SyncNotifierObserver* observer) { |
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
- core_->UpdateRegisteredIds(handler, ids); |
+ core_->RemoveObserver(observer); |
} |
void ChromeSyncNotificationBridge::Observe( |