Index: sync/notifier/p2p_notifier.cc |
diff --git a/sync/notifier/p2p_notifier.cc b/sync/notifier/p2p_notifier.cc |
index 5d5aeffc04bd33bdd50a1251e96620ff928d4794..dab7221955afd7fce5c002cc45f74069af895e92 100644 |
--- a/sync/notifier/p2p_notifier.cc |
+++ b/sync/notifier/p2p_notifier.cc |
@@ -157,10 +157,18 @@ P2PNotifier::~P2PNotifier() { |
push_client_->RemoveObserver(this); |
} |
+void P2PNotifier::RegisterHandler(SyncNotifierObserver* handler) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ registrar_.RegisterHandler(handler); |
+} |
+ |
void P2PNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, |
const ObjectIdSet& ids) { |
- const ModelTypeSet enabled_types = ObjectIdSetToModelTypeSet( |
- helper_.UpdateRegisteredIds(handler, ids)); |
+ // TODO(akalin): Handle arbitrary object IDs (http://crbug.com/140411). |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ registrar_.UpdateRegisteredIds(handler, ids); |
+ const ModelTypeSet enabled_types = |
+ ObjectIdSetToModelTypeSet(registrar_.GetAllRegisteredIds()); |
const ModelTypeSet new_enabled_types = |
Difference(enabled_types, enabled_types_); |
const P2PNotificationData notification_data( |
@@ -169,6 +177,11 @@ void P2PNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, |
enabled_types_ = enabled_types; |
} |
+void P2PNotifier::UnregisterHandler(SyncNotifierObserver* handler) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ registrar_.UnregisterHandler(handler); |
+} |
+ |
void P2PNotifier::SetUniqueId(const std::string& unique_id) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
unique_id_ = unique_id; |
@@ -207,7 +220,7 @@ void P2PNotifier::OnNotificationsEnabled() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
bool just_turned_on = (notifications_enabled_ == false); |
notifications_enabled_ = true; |
- helper_.EmitOnNotificationsEnabled(); |
+ registrar_.EmitOnNotificationsEnabled(); |
if (just_turned_on) { |
const P2PNotificationData notification_data( |
unique_id_, NOTIFY_SELF, enabled_types_); |
@@ -218,7 +231,7 @@ void P2PNotifier::OnNotificationsEnabled() { |
void P2PNotifier::OnNotificationsDisabled( |
notifier::NotificationsDisabledReason reason) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- helper_.EmitOnNotificationsDisabled(FromNotifierReason(reason)); |
+ registrar_.EmitOnNotificationsDisabled(FromNotifierReason(reason)); |
} |
void P2PNotifier::OnIncomingNotification( |
@@ -257,7 +270,7 @@ void P2PNotifier::OnIncomingNotification( |
} |
const ModelTypePayloadMap& type_payloads = ModelTypePayloadMapFromEnumSet( |
notification_data.GetChangedTypes(), std::string()); |
- helper_.DispatchInvalidationsToHandlers( |
+ registrar_.DispatchInvalidationsToHandlers( |
ModelTypePayloadMapToObjectIdPayloadMap(type_payloads), |
REMOTE_NOTIFICATION); |
} |