Index: sync/notifier/non_blocking_invalidation_notifier.cc |
diff --git a/sync/notifier/non_blocking_invalidation_notifier.cc b/sync/notifier/non_blocking_invalidation_notifier.cc |
index cf5e51ab7c221038c6cbefa3e9fda7ce3efad6f7..07105374a31362fe48738876b9f037f2c21c16ed 100644 |
--- a/sync/notifier/non_blocking_invalidation_notifier.cc |
+++ b/sync/notifier/non_blocking_invalidation_notifier.cc |
@@ -35,10 +35,10 @@ class NonBlockingInvalidationNotifier::Core |
invalidation_state_tracker, |
const std::string& client_info); |
void Teardown(); |
+ void UpdateRegisteredIds(const ObjectIdSet& ids); |
void SetUniqueId(const std::string& unique_id); |
void SetStateDeprecated(const std::string& state); |
void UpdateCredentials(const std::string& email, const std::string& token); |
- void UpdateEnabledTypes(syncer::ModelTypeSet enabled_types); |
// SyncNotifierObserver implementation (all called on I/O thread by |
// InvalidationNotifier). |
@@ -46,7 +46,7 @@ class NonBlockingInvalidationNotifier::Core |
virtual void OnNotificationsDisabled( |
NotificationsDisabledReason reason) OVERRIDE; |
virtual void OnIncomingNotification( |
- const syncer::ModelTypePayloadMap& type_payloads, |
+ const ObjectIdPayloadMap& id_payloads, |
IncomingNotificationSource source) OVERRIDE; |
private: |
@@ -93,17 +93,22 @@ void NonBlockingInvalidationNotifier::Core::Initialize( |
initial_invalidation_state, |
invalidation_state_tracker, |
client_info)); |
- invalidation_notifier_->AddObserver(this); |
} |
void NonBlockingInvalidationNotifier::Core::Teardown() { |
DCHECK(network_task_runner_->BelongsToCurrentThread()); |
- invalidation_notifier_->RemoveObserver(this); |
+ invalidation_notifier_->UpdateRegisteredIds(this, ObjectIdSet()); |
invalidation_notifier_.reset(); |
network_task_runner_ = NULL; |
} |
+void NonBlockingInvalidationNotifier::Core::UpdateRegisteredIds( |
+ const ObjectIdSet& ids) { |
+ DCHECK(network_task_runner_->BelongsToCurrentThread()); |
+ invalidation_notifier_->UpdateRegisteredIds(this, ids); |
akalin
2012/07/19 00:42:06
don't we need to union ids with the set of all reg
dcheng
2012/07/19 18:31:05
SyncNotifierHelper::UpdateRegisteredIds() convenie
akalin
2012/07/19 23:07:26
Oh, I missed that. That's easy to miss. Maybe ad
dcheng
2012/07/20 00:57:04
Done. Not sure my comment is helpful though...
|
+} |
+ |
void NonBlockingInvalidationNotifier::Core::SetUniqueId( |
const std::string& unique_id) { |
DCHECK(network_task_runner_->BelongsToCurrentThread()); |
@@ -122,12 +127,6 @@ void NonBlockingInvalidationNotifier::Core::UpdateCredentials( |
invalidation_notifier_->UpdateCredentials(email, token); |
} |
-void NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes( |
- syncer::ModelTypeSet enabled_types) { |
- DCHECK(network_task_runner_->BelongsToCurrentThread()); |
- invalidation_notifier_->UpdateEnabledTypes(enabled_types); |
-} |
- |
void NonBlockingInvalidationNotifier::Core::OnNotificationsEnabled() { |
DCHECK(network_task_runner_->BelongsToCurrentThread()); |
delegate_observer_.Call(FROM_HERE, |
@@ -142,12 +141,11 @@ void NonBlockingInvalidationNotifier::Core::OnNotificationsDisabled( |
} |
void NonBlockingInvalidationNotifier::Core::OnIncomingNotification( |
- const syncer::ModelTypePayloadMap& type_payloads, |
- IncomingNotificationSource source) { |
+ const ObjectIdPayloadMap& id_payloads, IncomingNotificationSource source) { |
DCHECK(network_task_runner_->BelongsToCurrentThread()); |
delegate_observer_.Call(FROM_HERE, |
&SyncNotifierObserver::OnIncomingNotification, |
- type_payloads, |
+ id_payloads, |
source); |
} |
@@ -190,16 +188,17 @@ NonBlockingInvalidationNotifier::~NonBlockingInvalidationNotifier() { |
} |
} |
-void NonBlockingInvalidationNotifier::AddObserver( |
- SyncNotifierObserver* observer) { |
+void NonBlockingInvalidationNotifier::UpdateRegisteredIds( |
+ SyncNotifierObserver* handler, const ObjectIdSet& ids) { |
DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
- observers_.AddObserver(observer); |
-} |
- |
-void NonBlockingInvalidationNotifier::RemoveObserver( |
- SyncNotifierObserver* observer) { |
- DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
- observers_.RemoveObserver(observer); |
+ if (!network_task_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind( |
+ &NonBlockingInvalidationNotifier::Core::UpdateRegisteredIds, |
+ core_.get(), |
+ helper_.UpdateRegisteredIds(handler, ids)))) { |
+ NOTREACHED(); |
+ } |
} |
void NonBlockingInvalidationNotifier::SetUniqueId( |
@@ -236,17 +235,6 @@ void NonBlockingInvalidationNotifier::UpdateCredentials( |
} |
} |
-void NonBlockingInvalidationNotifier::UpdateEnabledTypes( |
- syncer::ModelTypeSet enabled_types) { |
- DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
- if (!network_task_runner_->PostTask( |
- FROM_HERE, |
- base::Bind(&NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes, |
- core_.get(), enabled_types))) { |
- NOTREACHED(); |
- } |
-} |
- |
void NonBlockingInvalidationNotifier::SendNotification( |
syncer::ModelTypeSet changed_types) { |
DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
@@ -256,23 +244,22 @@ void NonBlockingInvalidationNotifier::SendNotification( |
void NonBlockingInvalidationNotifier::OnNotificationsEnabled() { |
DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
- FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, |
+ FOR_EACH_OBSERVER(SyncNotifierObserver, *helper_.handlers(), |
OnNotificationsEnabled()); |
} |
void NonBlockingInvalidationNotifier::OnNotificationsDisabled( |
NotificationsDisabledReason reason) { |
DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
- FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, |
+ FOR_EACH_OBSERVER(SyncNotifierObserver, *helper_.handlers(), |
OnNotificationsDisabled(reason)); |
} |
void NonBlockingInvalidationNotifier::OnIncomingNotification( |
- const syncer::ModelTypePayloadMap& type_payloads, |
+ const ObjectIdPayloadMap& id_payloads, |
IncomingNotificationSource source) { |
DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
- FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, |
- OnIncomingNotification(type_payloads, source)); |
+ helper_.DispatchInvalidationsToHandlers(id_payloads, source); |
} |
} // namespace syncer |