Index: sync/internal_api/sync_manager.cc |
diff --git a/sync/internal_api/sync_manager.cc b/sync/internal_api/sync_manager.cc |
index c8a293ea85f3ffc7e861d42891072d6535ca265d..4af7f045548067199e913b9dab765eeb679be906 100644 |
--- a/sync/internal_api/sync_manager.cc |
+++ b/sync/internal_api/sync_manager.cc |
@@ -299,11 +299,12 @@ class SyncManager::SyncInternal |
bool encrypt_everything) OVERRIDE; |
// SyncNotifierObserver implementation. |
+ virtual ObjectIdSet GetHandledIds() OVERRIDE; |
virtual void OnNotificationsEnabled() OVERRIDE; |
virtual void OnNotificationsDisabled( |
syncer::NotificationsDisabledReason reason) OVERRIDE; |
virtual void OnIncomingNotification( |
- const syncer::ModelTypePayloadMap& type_payloads, |
+ const ObjectIdPayloadMap& id_payloads, |
syncer::IncomingNotificationSource source) OVERRIDE; |
void AddObserver(SyncManager::Observer* observer); |
@@ -548,6 +549,10 @@ class SyncManager::SyncInternal |
// The SyncNotifier which notifies us when updates need to be downloaded. |
scoped_ptr<syncer::SyncNotifier> sync_notifier_; |
+ // The model types we want to register for notifications on represented as |
+ // invalidation::ObjectIds. |
+ ObjectIdSet enabled_sync_types_; |
+ |
// A multi-purpose status watch object that aggregates stats from various |
// sync components. |
AllStatus allstatus_; |
@@ -955,7 +960,7 @@ bool SyncManager::SyncInternal::Init( |
if (!signed_in && testing_mode_ == NON_TEST) |
return false; |
- sync_notifier_->AddObserver(this); |
+ sync_notifier_->AddHandler(this); |
return signed_in; |
} |
@@ -1178,7 +1183,18 @@ void SyncManager::SyncInternal::UpdateCredentials( |
void SyncManager::SyncInternal::UpdateEnabledTypes( |
const ModelTypeSet& enabled_types) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- sync_notifier_->UpdateEnabledTypes(enabled_types); |
+ // TODO(dcheng): Should this be a helper? |
+ enabled_sync_types_.clear(); |
+ for (ModelTypeSet::Iterator iter = enabled_types.First(); iter.Good(); |
+ iter.Inc()) { |
+ invalidation::ObjectId model_type_as_id; |
+ if (!RealModelTypeToObjectId(iter.Get(), &model_type_as_id)) { |
+ DLOG(WARNING) << "Invalid model type " << iter.Get(); |
+ continue; |
+ } |
+ enabled_sync_types_.insert(model_type_as_id); |
+ } |
+ sync_notifier_->ReloadHandlers(); |
} |
void SyncManager::SyncInternal::SetEncryptionPassphrase( |
@@ -1664,7 +1680,7 @@ void SyncManager::SyncInternal::ShutdownOnSyncThread() { |
RemoveObserver(&debug_info_event_listener_); |
if (sync_notifier_.get()) { |
- sync_notifier_->RemoveObserver(this); |
+ sync_notifier_->RemoveHandler(this); |
} |
sync_notifier_.reset(); |
@@ -2247,6 +2263,10 @@ void SyncManager::SyncInternal::UpdateNotificationInfo( |
} |
} |
+ObjectIdSet SyncManager::SyncInternal::GetHandledIds() { |
+ return enabled_sync_types_; |
+} |
+ |
void SyncManager::SyncInternal::OnNotificationsEnabled() { |
DVLOG(1) << "Notifications enabled"; |
allstatus_.SetNotificationsEnabled(true); |
@@ -2286,9 +2306,11 @@ void SyncManager::SyncInternal::OnNotificationsDisabled( |
} |
void SyncManager::SyncInternal::OnIncomingNotification( |
- const syncer::ModelTypePayloadMap& type_payloads, |
+ const ObjectIdPayloadMap& id_payloads, |
syncer::IncomingNotificationSource source) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ ModelTypePayloadMap type_payloads = |
+ ObjectIdPayloadMapToModelTypePayloadMap(id_payloads); |
if (source == syncer::LOCAL_NOTIFICATION) { |
if (scheduler()) { |
scheduler()->ScheduleNudgeWithPayloadsAsync( |
@@ -2410,12 +2432,11 @@ void SyncManager::SimulateDisableNotificationsForTest(int reason) { |
void SyncManager::TriggerOnIncomingNotificationForTest( |
ModelTypeSet model_types) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- syncer::ModelTypePayloadMap model_types_with_payloads = |
- syncer::ModelTypePayloadMapFromEnumSet(model_types, |
- std::string()); |
- |
- data_->OnIncomingNotification(model_types_with_payloads, |
- syncer::REMOTE_NOTIFICATION); |
+ ModelTypePayloadMap type_payloads = |
+ ModelTypePayloadMapFromEnumSet(model_types, std::string()); |
+ data_->OnIncomingNotification( |
+ ModelTypePayloadMapToObjectIdPayloadMap(type_payloads), |
+ REMOTE_NOTIFICATION); |
} |
const char* ConnectionStatusToString(ConnectionStatus status) { |