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

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

Issue 10823037: Revert r148496 "Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 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(

Powered by Google App Engine
This is Rietveld 408576698