Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1063)

Unified Diff: sync/internal_api/sync_manager.cc

Issue 10702074: Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor cleanup Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f51af228451f651a065eab56718c5ca0ccdb41b3 100644
--- a/sync/internal_api/sync_manager.cc
+++ b/sync/internal_api/sync_manager.cc
@@ -45,6 +45,7 @@
#include "sync/js/js_event_details.h"
#include "sync/js/js_event_handler.h"
#include "sync/js/js_reply_handler.h"
+#include "sync/notifier/invalidation_util.h"
#include "sync/notifier/notifications_disabled_reason.h"
#include "sync/notifier/sync_notifier.h"
#include "sync/notifier/sync_notifier_observer.h"
@@ -299,11 +300,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 +550,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 +961,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 +1184,8 @@ void SyncManager::SyncInternal::UpdateCredentials(
void SyncManager::SyncInternal::UpdateEnabledTypes(
const ModelTypeSet& enabled_types) {
DCHECK(thread_checker_.CalledOnValidThread());
- sync_notifier_->UpdateEnabledTypes(enabled_types);
+ enabled_sync_types_ = ModelTypeSetToObjectIdSet(enabled_types);
+ sync_notifier_->ReloadHandlers();
}
void SyncManager::SyncInternal::SetEncryptionPassphrase(
@@ -1664,7 +1671,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 +2254,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 +2297,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 +2423,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) {

Powered by Google App Engine
This is Rietveld 408576698