Commit 840f3541 authored by akalin@chromium.org's avatar akalin@chromium.org

[Sync] Address msw's comments for r149747

See http://codereview.chromium.org/10805002/.

BUG=137087


Review URL: https://chromiumcodereview.appspot.com/10828158

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150008 0039d316-1c4b-4281-b951-d872f2087c98
parent f9eda276
......@@ -552,10 +552,9 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// been cleared yet. Virtual for testing purposes.
virtual bool waiting_for_auth() const;
// Updates the set of ObjectIds associated with a given
// |handler|. Passing an empty ObjectIdSet will unregister
// |handler|. There should be at most one handler registered per
// object id.
// Updates the set of ObjectIds associated with a given |handler|.
// Passing an empty ObjectIdSet will unregister |handler|.
// There should be at most one handler registered per object id.
//
// The handler -> registered ids map is persisted across restarts of
// sync.
......
......@@ -384,10 +384,10 @@ TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIds) {
StrictMock<syncer::MockSyncNotifierObserver> observer;
EXPECT_CALL(observer, OnNotificationsEnabled());
EXPECT_CALL(observer, OnNotificationsDisabled(
syncer::TRANSIENT_NOTIFICATION_ERROR));
EXPECT_CALL(observer, OnIncomingNotification(
payloads, syncer::REMOTE_NOTIFICATION));
EXPECT_CALL(observer, OnNotificationsDisabled(
syncer::TRANSIENT_NOTIFICATION_ERROR));
service_->UpdateRegisteredInvalidationIds(&observer, ids);
......@@ -395,16 +395,16 @@ TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIds) {
service_->GetBackendForTest();
backend->EmitOnNotificationsEnabled();
backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
Mock::VerifyAndClearExpectations(&observer);
service_->UpdateRegisteredInvalidationIds(&observer, syncer::ObjectIdSet());
backend->EmitOnNotificationsEnabled();
backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
}
// Register for some IDs with the ProfileSyncService, restart sync,
......@@ -413,17 +413,29 @@ TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIds) {
TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) {
StartSyncService();
syncer::ObjectIdSet ids;
ids.insert(invalidation::ObjectId(3, "id3"));
const syncer::ObjectIdPayloadMap& payloads =
syncer::ObjectIdSetToPayloadMap(ids, "payload");
StrictMock<syncer::MockSyncNotifierObserver> observer;
EXPECT_CALL(observer, OnNotificationsEnabled());
EXPECT_CALL(observer, OnIncomingNotification(
payloads, syncer::REMOTE_NOTIFICATION));
EXPECT_CALL(observer, OnNotificationsDisabled(
syncer::TRANSIENT_NOTIFICATION_ERROR));
syncer::ObjectIdSet ids;
ids.insert(invalidation::ObjectId(3, "id3"));
service_->UpdateRegisteredInvalidationIds(&observer, ids);
service_->StopAndSuppress();
service_->UnsuppressAndStart();
service_->GetBackendForTest()->EmitOnNotificationsEnabled();
SyncBackendHostForProfileSyncTest* const backend =
service_->GetBackendForTest();
backend->EmitOnNotificationsEnabled();
backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
}
} // namespace
......
......@@ -30,6 +30,7 @@ class EncryptedData;
} // namespace sync_pb
namespace syncer {
class BaseTransaction;
class Encryptor;
struct Experiments;
......@@ -409,7 +410,8 @@ class SyncManager {
// Forwards to the underlying notifier (see
// SyncNotifier::UpdateRegisteredIds()).
virtual void UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler, const ObjectIdSet& ids) = 0;
SyncNotifierObserver* handler,
const ObjectIdSet& ids) = 0;
// Put the syncer in normal mode ready to perform nudges and polls.
virtual void StartSyncingNormally(
......
......@@ -54,8 +54,7 @@ class FakeSyncManager : public SyncManager {
ModelTypeSet GetAndResetEnabledTypes();
// Posts a method to invalidate the given IDs on the sync thread.
void Invalidate(
const ObjectIdPayloadMap& id_payloads,
void Invalidate(const ObjectIdPayloadMap& id_payloads,
IncomingNotificationSource source);
// Posts a method to enable notifications on the sync thread.
......@@ -96,7 +95,8 @@ class FakeSyncManager : public SyncManager {
virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE;
virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE;
virtual void UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler, const ObjectIdSet& ids) OVERRIDE;
SyncNotifierObserver* handler,
const ObjectIdSet& ids) OVERRIDE;
virtual void StartSyncingNormally(
const ModelSafeRoutingInfo& routing_info) OVERRIDE;
virtual void SetEncryptionPassphrase(const std::string& passphrase,
......
......@@ -739,7 +739,8 @@ void SyncManagerImpl::UpdateEnabledTypes(
}
void SyncManagerImpl::UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler, const ObjectIdSet& ids) {
SyncNotifierObserver* handler,
const ObjectIdSet& ids) {
DCHECK(thread_checker_.CalledOnValidThread());
sync_notifier_->UpdateRegisteredIds(handler, ids);
}
......
......@@ -87,7 +87,8 @@ class SyncManagerImpl : public SyncManager,
virtual void UpdateEnabledTypes(
const ModelTypeSet& enabled_types) OVERRIDE;
virtual void UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler, const ObjectIdSet& ids) OVERRIDE;
SyncNotifierObserver* handler,
const ObjectIdSet& ids) OVERRIDE;
virtual void StartSyncingNormally(
const ModelSafeRoutingInfo& routing_info) OVERRIDE;
virtual void SetEncryptionPassphrase(const std::string& passphrase,
......
......@@ -55,8 +55,7 @@ ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() {
return enabled_types;
}
void FakeSyncManager::Invalidate(
const ObjectIdPayloadMap& id_payloads,
void FakeSyncManager::Invalidate(const ObjectIdPayloadMap& id_payloads,
IncomingNotificationSource source) {
if (!sync_task_runner_->PostTask(
FROM_HERE,
......@@ -151,7 +150,8 @@ void FakeSyncManager::UpdateEnabledTypes(const ModelTypeSet& types) {
}
void FakeSyncManager::UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler, const ObjectIdSet& ids) {
SyncNotifierObserver* handler,
const ObjectIdSet& ids) {
notifier_helper_.UpdateRegisteredIds(handler, ids);
}
......
......@@ -16,8 +16,8 @@ ObjectIdSet ObjectIdPayloadMapToSet(
return ids;
}
ObjectIdPayloadMap ObjectIdSetToPayloadMap(
ObjectIdSet ids, const std::string& payload) {
ObjectIdPayloadMap ObjectIdSetToPayloadMap(ObjectIdSet ids,
const std::string& payload) {
ObjectIdPayloadMap id_payloads;
for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
id_payloads[*it] = payload;
......
......@@ -20,8 +20,8 @@ typedef std::map<invalidation::ObjectId,
// Converts between ObjectIdPayloadMaps and ObjectIdSets.
ObjectIdSet ObjectIdPayloadMapToSet(const ObjectIdPayloadMap& id_payloads);
ObjectIdPayloadMap ObjectIdSetToPayloadMap(
ObjectIdSet ids, const std::string& payload);
ObjectIdPayloadMap ObjectIdSetToPayloadMap(ObjectIdSet ids,
const std::string& payload);
// Converts between ObjectIdPayloadMaps and ModelTypePayloadMaps.
ModelTypePayloadMap ObjectIdPayloadMapToModelTypePayloadMap(
......
......@@ -22,10 +22,9 @@ class SyncNotifier {
SyncNotifier() {}
virtual ~SyncNotifier() {}
// Updates the set of ObjectIds associated with a given
// |handler|. Passing an empty ObjectIdSet will unregister
// |handler|. There should be at most one handler registered per
// object id.
// Updates the set of ObjectIds associated with a given |handler|.
// Passing an empty ObjectIdSet will unregister |handler|.
// There should be at most one handler registered per object id.
virtual void UpdateRegisteredIds(SyncNotifierObserver* handler,
const ObjectIdSet& ids) = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment