diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-05 03:51:44 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-05 03:51:44 +0000 |
commit | ce2e906005c7d6664518ff9b1e541733ed251ace (patch) | |
tree | f34377f83975fcc5d289491ba7d2828eebedf52b /sync/internal_api | |
parent | b86d3ec7994792d30c1a54d8b25579ad8eded24f (diff) | |
download | chromium_src-ce2e906005c7d6664518ff9b1e541733ed251ace.zip chromium_src-ce2e906005c7d6664518ff9b1e541733ed251ace.tar.gz chromium_src-ce2e906005c7d6664518ff9b1e541733ed251ace.tar.bz2 |
Implement Invalidator::Acknowledge.
We implement this by creating a local queue of entries we've received invalidations for and then immediately acknowledging to Tango. When InvalidationHandlers acknowledge that they've finished processing for an id, we erase their entry from the queue; otherwise, we send reminder invalidations on an exponentially increasing delay.
BUG=124149
Review URL: https://chromiumcodereview.appspot.com/10911084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api')
-rw-r--r-- | sync/internal_api/public/sync_manager.h | 5 | ||||
-rw-r--r-- | sync/internal_api/public/test/fake_sync_manager.h | 3 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl.cc | 17 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl.h | 3 | ||||
-rw-r--r-- | sync/internal_api/test/fake_sync_manager.cc | 5 |
5 files changed, 33 insertions, 0 deletions
diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h index 6e23ba8..acd5394 100644 --- a/sync/internal_api/public/sync_manager.h +++ b/sync/internal_api/public/sync_manager.h @@ -354,6 +354,11 @@ class SYNC_EXPORT SyncManager { virtual void UnregisterInvalidationHandler( InvalidationHandler* handler) = 0; + // Forwards to the underlying notifier (see comments in invalidator.h). + virtual void AcknowledgeInvalidation( + const invalidation::ObjectId& id, + const syncer::AckHandle& ack_handle) = 0; + // Put the syncer in normal mode ready to perform nudges and polls. virtual void StartSyncingNormally( const ModelSafeRoutingInfo& routing_info) = 0; diff --git a/sync/internal_api/public/test/fake_sync_manager.h b/sync/internal_api/public/test/fake_sync_manager.h index 49c443f..2d0f9de 100644 --- a/sync/internal_api/public/test/fake_sync_manager.h +++ b/sync/internal_api/public/test/fake_sync_manager.h @@ -102,6 +102,9 @@ class FakeSyncManager : public SyncManager { const ObjectIdSet& ids) OVERRIDE; virtual void UnregisterInvalidationHandler( InvalidationHandler* handler) OVERRIDE; + virtual void AcknowledgeInvalidation( + const invalidation::ObjectId& id, + const syncer::AckHandle& ack_handle) OVERRIDE; virtual void StartSyncingNormally( const ModelSafeRoutingInfo& routing_info) OVERRIDE; virtual void ConfigureSyncer( diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc index b0d826a..e9d8d1c 100644 --- a/sync/internal_api/sync_manager_impl.cc +++ b/sync/internal_api/sync_manager_impl.cc @@ -635,6 +635,13 @@ void SyncManagerImpl::UnregisterInvalidationHandler( invalidator_->UnregisterHandler(handler); } +void SyncManagerImpl::AcknowledgeInvalidation( + const invalidation::ObjectId& id, const syncer::AckHandle& ack_handle) { + DCHECK(thread_checker_.CalledOnValidThread()); + DCHECK(initialized_); + invalidator_->Acknowledge(id, ack_handle); +} + void SyncManagerImpl::AddObserver(SyncManager::Observer* observer) { DCHECK(thread_checker_.CalledOnValidThread()); observers_.AddObserver(observer); @@ -1238,6 +1245,16 @@ void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) { void SyncManagerImpl::OnIncomingInvalidation( const ObjectIdInvalidationMap& invalidation_map) { DCHECK(thread_checker_.CalledOnValidThread()); + + // TODO(dcheng): Acknowledge immediately for now. Fix this once the + // invalidator doesn't repeatedly ping for unacknowledged invaliations, since + // it conflicts with the sync scheduler's internal backoff algorithm. + // See http://crbug.com/124149 for more information. + for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); + it != invalidation_map.end(); ++it) { + invalidator_->Acknowledge(it->first, it->second.ack_handle); + } + const ModelTypeInvalidationMap& type_invalidation_map = ObjectIdInvalidationMapToModelTypeInvalidationMap(invalidation_map); if (type_invalidation_map.empty()) { diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h index 8baf44d..d58a1f2 100644 --- a/sync/internal_api/sync_manager_impl.h +++ b/sync/internal_api/sync_manager_impl.h @@ -96,6 +96,9 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl : const ObjectIdSet& ids) OVERRIDE; virtual void UnregisterInvalidationHandler( InvalidationHandler* handler) OVERRIDE; + virtual void AcknowledgeInvalidation( + const invalidation::ObjectId& id, + const syncer::AckHandle& ack_handle) OVERRIDE; virtual void StartSyncingNormally( const ModelSafeRoutingInfo& routing_info) OVERRIDE; virtual void ConfigureSyncer( diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc index bc9c4dc..57c6c77 100644 --- a/sync/internal_api/test/fake_sync_manager.cc +++ b/sync/internal_api/test/fake_sync_manager.cc @@ -172,6 +172,11 @@ void FakeSyncManager::UnregisterInvalidationHandler( registrar_.UnregisterHandler(handler); } +void FakeSyncManager::AcknowledgeInvalidation(const invalidation::ObjectId& id, + const AckHandle& ack_handle) { + // Do nothing. +} + void FakeSyncManager::StartSyncingNormally( const ModelSafeRoutingInfo& routing_info) { // Do nothing. |