diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 19:40:33 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 19:40:33 +0000 |
commit | 877197584abc8883cbccc3bd83240a9be6c2e16e (patch) | |
tree | 36da6824a41c80c87f1b95dc1c8cf1f4a9e4571c /sync/notifier/invalidation_notifier.cc | |
parent | 8e2dd2741c41e5090aee5f8bc31349ff6d9c0fed (diff) | |
download | chromium_src-877197584abc8883cbccc3bd83240a9be6c2e16e.zip chromium_src-877197584abc8883cbccc3bd83240a9be6c2e16e.tar.gz chromium_src-877197584abc8883cbccc3bd83240a9be6c2e16e.tar.bz2 |
Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver
Sort of. SendNotification() is still there. Perhaps we want to split the interfaces completely.
BUG=124149
TEST=tests should still pass, no observable behavior change
Review URL: https://chromiumcodereview.appspot.com/10702074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147801 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/notifier/invalidation_notifier.cc')
-rw-r--r-- | sync/notifier/invalidation_notifier.cc | 47 |
1 files changed, 6 insertions, 41 deletions
diff --git a/sync/notifier/invalidation_notifier.cc b/sync/notifier/invalidation_notifier.cc index 0c629c6..3a72f32 100644 --- a/sync/notifier/invalidation_notifier.cc +++ b/sync/notifier/invalidation_notifier.cc @@ -34,14 +34,10 @@ InvalidationNotifier::~InvalidationNotifier() { DCHECK(CalledOnValidThread()); } -void InvalidationNotifier::AddObserver(SyncNotifierObserver* observer) { +void InvalidationNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, + const ObjectIdSet& ids) { DCHECK(CalledOnValidThread()); - observers_.AddObserver(observer); -} - -void InvalidationNotifier::RemoveObserver(SyncNotifierObserver* observer) { - DCHECK(CalledOnValidThread()); - observers_.RemoveObserver(observer); + invalidation_client_.RegisterIds(helper_.UpdateRegisteredIds(handler, ids)); } void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { @@ -85,22 +81,6 @@ void InvalidationNotifier::UpdateCredentials( invalidation_client_.UpdateCredentials(email, token); } -void InvalidationNotifier::UpdateEnabledTypes(ModelTypeSet enabled_types) { - DCHECK(CalledOnValidThread()); - CHECK(!invalidation_client_id_.empty()); - ObjectIdSet ids; - for (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(ModelTypeSet changed_types) { DCHECK(CalledOnValidThread()); // Do nothing. @@ -108,33 +88,18 @@ void InvalidationNotifier::SendNotification(ModelTypeSet changed_types) { void InvalidationNotifier::OnInvalidate(const ObjectIdPayloadMap& id_payloads) { DCHECK(CalledOnValidThread()); - // TODO(dcheng): This should probably be a utility function somewhere... - ModelTypePayloadMap type_payloads; - for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin(); - it != id_payloads.end(); ++it) { - 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, REMOTE_NOTIFICATION)); + helper_.DispatchInvalidationsToHandlers(id_payloads, REMOTE_NOTIFICATION); } void InvalidationNotifier::OnNotificationsEnabled() { DCHECK(CalledOnValidThread()); - FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, - OnNotificationsEnabled()); + helper_.EmitOnNotificationsEnabled(); } void InvalidationNotifier::OnNotificationsDisabled( NotificationsDisabledReason reason) { DCHECK(CalledOnValidThread()); - FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, - OnNotificationsDisabled(reason)); + helper_.EmitOnNotificationsDisabled(reason); } } // namespace syncer |