Index: sync/notifier/invalidation_notifier.cc |
diff --git a/sync/notifier/invalidation_notifier.cc b/sync/notifier/invalidation_notifier.cc |
index 58ef89a0b7f14a123902675e16e1e26005eb4bc8..2c3749e3b5a04b2790529cc2abd455faebdb9cdb 100644 |
--- a/sync/notifier/invalidation_notifier.cc |
+++ b/sync/notifier/invalidation_notifier.cc |
@@ -35,14 +35,19 @@ InvalidationNotifier::~InvalidationNotifier() { |
DCHECK(CalledOnValidThread()); |
} |
-void InvalidationNotifier::AddObserver(SyncNotifierObserver* observer) { |
+void InvalidationNotifier::AddHandler(SyncNotifierObserver* observer) { |
DCHECK(CalledOnValidThread()); |
- observers_.AddObserver(observer); |
+ InvalidationNotifierBase::AddHandler(observer); |
} |
-void InvalidationNotifier::RemoveObserver(SyncNotifierObserver* observer) { |
+void InvalidationNotifier::RemoveHandler(SyncNotifierObserver* observer) { |
DCHECK(CalledOnValidThread()); |
- observers_.RemoveObserver(observer); |
+ InvalidationNotifierBase::RemoveHandler(observer); |
+} |
+ |
+void InvalidationNotifier::ReloadHandlers() { |
+ const ObjectIdSet& ids_to_register = UpdateObjectIdObserverMap(); |
+ invalidation_client_.RegisterIds(ids_to_register); |
} |
void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { |
@@ -86,23 +91,6 @@ void InvalidationNotifier::UpdateCredentials( |
invalidation_client_.UpdateCredentials(email, token); |
} |
-void InvalidationNotifier::UpdateEnabledTypes( |
- syncer::ModelTypeSet enabled_types) { |
- DCHECK(CalledOnValidThread()); |
- CHECK(!invalidation_client_id_.empty()); |
- ObjectIdSet ids; |
- for (syncer::ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); |
- it.Inc()) { |
- invalidation::ObjectId id; |
- if (!RealModelTypeToObjectId(it.Get(), &id)) { |
- DLOG(WARNING) << "Invalid model type " << it.Get(); |
- continue; |
- } |
- ids.insert(id); |
- } |
- invalidation_client_.RegisterIds(ids); |
-} |
- |
void InvalidationNotifier::SendNotification( |
syncer::ModelTypeSet changed_types) { |
DCHECK(CalledOnValidThread()); |
@@ -111,33 +99,19 @@ void InvalidationNotifier::SendNotification( |
void InvalidationNotifier::OnInvalidate(const ObjectIdPayloadMap& id_payloads) { |
DCHECK(CalledOnValidThread()); |
- // TODO(dcheng): This should probably be a utility function somewhere... |
- syncer::ModelTypePayloadMap type_payloads; |
- for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin(); |
- it != id_payloads.end(); ++it) { |
- syncer::ModelType model_type; |
- if (!ObjectIdToRealModelType(it->first, &model_type)) { |
- DLOG(WARNING) << "Invalid object ID: " << ObjectIdToString(it->first); |
- continue; |
- } |
- type_payloads[model_type] = it->second; |
- } |
- FOR_EACH_OBSERVER( |
- SyncNotifierObserver, observers_, |
- OnIncomingNotification(type_payloads, |
- syncer::REMOTE_NOTIFICATION)); |
+ DispatchInvalidationsToObservers(id_payloads, syncer::REMOTE_NOTIFICATION); |
} |
void InvalidationNotifier::OnNotificationsEnabled() { |
DCHECK(CalledOnValidThread()); |
- FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, |
+ FOR_EACH_OBSERVER(SyncNotifierObserver, observers(), |
OnNotificationsEnabled()); |
} |
void InvalidationNotifier::OnNotificationsDisabled( |
NotificationsDisabledReason reason) { |
DCHECK(CalledOnValidThread()); |
- FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, |
+ FOR_EACH_OBSERVER(SyncNotifierObserver, observers(), |
OnNotificationsDisabled(reason)); |
} |