diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 22:24:51 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 22:24:51 +0000 |
commit | 19d7cace55665ae4a4668b33d6e2e0683d26f87e (patch) | |
tree | 0202bc38f3aee4ce7e70c4f05ff107c19e5ac11f /sync | |
parent | 01e0cf2f93e830e8bc84c4eb9b46f6dbaf24572f (diff) | |
download | chromium_src-19d7cace55665ae4a4668b33d6e2e0683d26f87e.zip chromium_src-19d7cace55665ae4a4668b33d6e2e0683d26f87e.tar.gz chromium_src-19d7cace55665ae4a4668b33d6e2e0683d26f87e.tar.bz2 |
Add the InvalidationState struct to bundle local state about invalidations.
Currently this only has one member, but I anticipate adding several more
as we add support for local acknowledgements.
BUG=124149
Review URL: https://codereview.chromium.org/11229015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163077 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/notifier/fake_invalidation_state_tracker.cc | 18 | ||||
-rw-r--r-- | sync/notifier/fake_invalidation_state_tracker.h | 4 | ||||
-rw-r--r-- | sync/notifier/invalidation_notifier.cc | 6 | ||||
-rw-r--r-- | sync/notifier/invalidation_notifier.h | 4 | ||||
-rw-r--r-- | sync/notifier/invalidation_notifier_unittest.cc | 2 | ||||
-rw-r--r-- | sync/notifier/invalidation_state_tracker.h | 10 | ||||
-rw-r--r-- | sync/notifier/invalidator_factory.cc | 12 | ||||
-rw-r--r-- | sync/notifier/invalidator_factory.h | 2 | ||||
-rw-r--r-- | sync/notifier/non_blocking_invalidator.cc | 8 | ||||
-rw-r--r-- | sync/notifier/non_blocking_invalidator.h | 2 | ||||
-rw-r--r-- | sync/notifier/non_blocking_invalidator_unittest.cc | 2 | ||||
-rw-r--r-- | sync/notifier/sync_invalidation_listener.cc | 25 | ||||
-rw-r--r-- | sync/notifier/sync_invalidation_listener.h | 4 | ||||
-rw-r--r-- | sync/notifier/sync_invalidation_listener_unittest.cc | 2 | ||||
-rw-r--r-- | sync/tools/sync_client.cc | 4 | ||||
-rw-r--r-- | sync/tools/sync_listen_notifications.cc | 4 |
16 files changed, 56 insertions, 53 deletions
diff --git a/sync/notifier/fake_invalidation_state_tracker.cc b/sync/notifier/fake_invalidation_state_tracker.cc index a64079b..9073e45b 100644 --- a/sync/notifier/fake_invalidation_state_tracker.cc +++ b/sync/notifier/fake_invalidation_state_tracker.cc @@ -16,28 +16,28 @@ FakeInvalidationStateTracker::~FakeInvalidationStateTracker() {} int64 FakeInvalidationStateTracker::GetMaxVersion( const invalidation::ObjectId& id) const { - InvalidationVersionMap::const_iterator it = versions_.find(id); - return (it == versions_.end()) ? kMinVersion : it->second; + InvalidationStateMap::const_iterator it = state_map_.find(id); + return (it == state_map_.end()) ? kMinVersion : it->second.version; } -InvalidationVersionMap -FakeInvalidationStateTracker::GetAllMaxVersions() const { - return versions_; +InvalidationStateMap +FakeInvalidationStateTracker::GetAllInvalidationStates() const { + return state_map_; } void FakeInvalidationStateTracker::SetMaxVersion( const invalidation::ObjectId& id, int64 max_version) { - InvalidationVersionMap::const_iterator it = versions_.find(id); - if ((it != versions_.end()) && (max_version <= it->second)) { + InvalidationStateMap::const_iterator it = state_map_.find(id); + if ((it != state_map_.end()) && (max_version <= it->second.version)) { ADD_FAILURE(); return; } - versions_[id] = max_version; + state_map_[id].version = max_version; } void FakeInvalidationStateTracker::Forget(const ObjectIdSet& ids) { for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { - versions_.erase(*it); + state_map_.erase(*it); } } diff --git a/sync/notifier/fake_invalidation_state_tracker.h b/sync/notifier/fake_invalidation_state_tracker.h index aea358d..bd9003b 100644 --- a/sync/notifier/fake_invalidation_state_tracker.h +++ b/sync/notifier/fake_invalidation_state_tracker.h @@ -22,7 +22,7 @@ class FakeInvalidationStateTracker int64 GetMaxVersion(const invalidation::ObjectId& id) const; // InvalidationStateTracker implementation. - virtual InvalidationVersionMap GetAllMaxVersions() const OVERRIDE; + virtual InvalidationStateMap GetAllInvalidationStates() const OVERRIDE; virtual void SetMaxVersion(const invalidation::ObjectId& id, int64 max_version) OVERRIDE; virtual void Forget(const ObjectIdSet& ids) OVERRIDE; @@ -32,7 +32,7 @@ class FakeInvalidationStateTracker static const int64 kMinVersion; private: - InvalidationVersionMap versions_; + InvalidationStateMap state_map_; std::string bootstrap_data_; }; diff --git a/sync/notifier/invalidation_notifier.cc b/sync/notifier/invalidation_notifier.cc index 873c578..93417e2 100644 --- a/sync/notifier/invalidation_notifier.cc +++ b/sync/notifier/invalidation_notifier.cc @@ -19,12 +19,12 @@ namespace syncer { InvalidationNotifier::InvalidationNotifier( scoped_ptr<notifier::PushClient> push_client, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, const std::string& client_info) : state_(STOPPED), - initial_max_invalidation_versions_(initial_max_invalidation_versions), + initial_invalidation_state_map_(initial_invalidation_state_map), invalidation_state_tracker_(invalidation_state_tracker), client_info_(client_info), invalidation_bootstrap_data_(invalidation_bootstrap_data), @@ -90,7 +90,7 @@ void InvalidationNotifier::UpdateCredentials( invalidation_listener_.Start( base::Bind(&invalidation::CreateInvalidationClient), client_id_, client_info_, invalidation_bootstrap_data_, - initial_max_invalidation_versions_, + initial_invalidation_state_map_, invalidation_state_tracker_, this); invalidation_bootstrap_data_.clear(); diff --git a/sync/notifier/invalidation_notifier.h b/sync/notifier/invalidation_notifier.h index f736124..471beba 100644 --- a/sync/notifier/invalidation_notifier.h +++ b/sync/notifier/invalidation_notifier.h @@ -41,7 +41,7 @@ class InvalidationNotifier // |invalidation_state_tracker| must be initialized. InvalidationNotifier( scoped_ptr<notifier::PushClient> push_client, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, @@ -82,7 +82,7 @@ class InvalidationNotifier InvalidatorRegistrar registrar_; // Passed to |invalidation_listener_|. - const InvalidationVersionMap initial_max_invalidation_versions_; + const InvalidationStateMap initial_invalidation_state_map_; // Passed to |invalidation_listener_|. const WeakHandle<InvalidationStateTracker> diff --git a/sync/notifier/invalidation_notifier_unittest.cc b/sync/notifier/invalidation_notifier_unittest.cc index 14877a6..5b5f8fa 100644 --- a/sync/notifier/invalidation_notifier_unittest.cc +++ b/sync/notifier/invalidation_notifier_unittest.cc @@ -40,7 +40,7 @@ class InvalidationNotifierTestDelegate { invalidator_.reset( new InvalidationNotifier( scoped_ptr<notifier::PushClient>(new notifier::FakePushClient()), - InvalidationVersionMap(), + InvalidationStateMap(), initial_state, MakeWeakHandle(invalidation_state_tracker), "fake_client_info")); diff --git a/sync/notifier/invalidation_state_tracker.h b/sync/notifier/invalidation_state_tracker.h index 5541142..c547cf6 100644 --- a/sync/notifier/invalidation_state_tracker.h +++ b/sync/notifier/invalidation_state_tracker.h @@ -16,14 +16,18 @@ namespace syncer { -typedef std::map<invalidation::ObjectId, int64, ObjectIdLessThan> - InvalidationVersionMap; +struct InvalidationState { + int64 version; +}; + +typedef std::map<invalidation::ObjectId, InvalidationState, ObjectIdLessThan> + InvalidationStateMap; class InvalidationStateTracker { public: InvalidationStateTracker() {} - virtual InvalidationVersionMap GetAllMaxVersions() const = 0; + virtual InvalidationStateMap GetAllInvalidationStates() const = 0; // |max_version| should be strictly greater than any existing max // version for |model_type|. diff --git a/sync/notifier/invalidator_factory.cc b/sync/notifier/invalidator_factory.cc index ea0d59d..9c746e2 100644 --- a/sync/notifier/invalidator_factory.cc +++ b/sync/notifier/invalidator_factory.cc @@ -17,7 +17,7 @@ namespace { Invalidator* CreateDefaultInvalidator( const notifier::NotifierOptions& notifier_options, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, const std::string& client_info) { @@ -32,7 +32,7 @@ Invalidator* CreateDefaultInvalidator( } return new NonBlockingInvalidator( - notifier_options, initial_max_invalidation_versions, + notifier_options, initial_invalidation_state_map, invalidation_bootstrap_data, invalidation_state_tracker, client_info); } @@ -46,10 +46,10 @@ InvalidatorFactory::InvalidatorFactory( invalidation_state_tracker) : notifier_options_(notifier_options), client_info_(client_info), - initial_max_invalidation_versions_( + initial_invalidation_state_map_( invalidation_state_tracker.get() ? - invalidation_state_tracker->GetAllMaxVersions() : - InvalidationVersionMap()), + invalidation_state_tracker->GetAllInvalidationStates() : + InvalidationStateMap()), invalidation_bootstrap_data_( invalidation_state_tracker.get() ? invalidation_state_tracker->GetBootstrapData() : @@ -66,7 +66,7 @@ Invalidator* InvalidatorFactory::CreateInvalidator() { return NULL; #else return CreateDefaultInvalidator(notifier_options_, - initial_max_invalidation_versions_, + initial_invalidation_state_map_, invalidation_bootstrap_data_, invalidation_state_tracker_, client_info_); diff --git a/sync/notifier/invalidator_factory.h b/sync/notifier/invalidator_factory.h index c92291f..4a33c6b 100644 --- a/sync/notifier/invalidator_factory.h +++ b/sync/notifier/invalidator_factory.h @@ -38,7 +38,7 @@ class InvalidatorFactory { private: const notifier::NotifierOptions notifier_options_; const std::string client_info_; - const InvalidationVersionMap initial_max_invalidation_versions_; + const InvalidationStateMap initial_invalidation_state_map_; const std::string invalidation_bootstrap_data_; const WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; diff --git a/sync/notifier/non_blocking_invalidator.cc b/sync/notifier/non_blocking_invalidator.cc index 7472902..47aa53f 100644 --- a/sync/notifier/non_blocking_invalidator.cc +++ b/sync/notifier/non_blocking_invalidator.cc @@ -30,7 +30,7 @@ class NonBlockingInvalidator::Core // Helpers called on I/O thread. void Initialize( const notifier::NotifierOptions& notifier_options, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, const std::string& client_info); @@ -72,7 +72,7 @@ NonBlockingInvalidator::Core::~Core() { void NonBlockingInvalidator::Core::Initialize( const notifier::NotifierOptions& notifier_options, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, const std::string& client_info) { @@ -85,7 +85,7 @@ void NonBlockingInvalidator::Core::Initialize( invalidation_notifier_.reset( new InvalidationNotifier( notifier::PushClient::CreateDefaultOnIOThread(notifier_options), - initial_max_invalidation_versions, + initial_invalidation_state_map, invalidation_bootstrap_data, invalidation_state_tracker, client_info)); @@ -140,7 +140,7 @@ void NonBlockingInvalidator::Core::OnIncomingInvalidation( NonBlockingInvalidator::NonBlockingInvalidator( const notifier::NotifierOptions& notifier_options, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_max_invalidation_versions, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, diff --git a/sync/notifier/non_blocking_invalidator.h b/sync/notifier/non_blocking_invalidator.h index 3cb4f26..5e27cb0 100644 --- a/sync/notifier/non_blocking_invalidator.h +++ b/sync/notifier/non_blocking_invalidator.h @@ -37,7 +37,7 @@ class NonBlockingInvalidator // |invalidation_state_tracker| must be initialized. NonBlockingInvalidator( const notifier::NotifierOptions& notifier_options, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const std::string& invalidation_bootstrap_data, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, diff --git a/sync/notifier/non_blocking_invalidator_unittest.cc b/sync/notifier/non_blocking_invalidator_unittest.cc index df8142a..73b85bf 100644 --- a/sync/notifier/non_blocking_invalidator_unittest.cc +++ b/sync/notifier/non_blocking_invalidator_unittest.cc @@ -49,7 +49,7 @@ class NonBlockingInvalidatorTestDelegate { invalidator_.reset( new NonBlockingInvalidator( invalidator_options, - InvalidationVersionMap(), + InvalidationStateMap(), initial_state, MakeWeakHandle(invalidation_state_tracker), "fake_client_info")); diff --git a/sync/notifier/sync_invalidation_listener.cc b/sync/notifier/sync_invalidation_listener.cc index ab70527f6..c947859 100644 --- a/sync/notifier/sync_invalidation_listener.cc +++ b/sync/notifier/sync_invalidation_listener.cc @@ -52,7 +52,7 @@ void SyncInvalidationListener::Start( create_invalidation_client_callback, const std::string& client_id, const std::string& client_info, const std::string& invalidation_bootstrap_data, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, Delegate* delegate) { DCHECK(CalledOnValidThread()); @@ -67,16 +67,16 @@ void SyncInvalidationListener::Start( sync_system_resources_.storage()->SetInitialState( invalidation_bootstrap_data); - max_invalidation_versions_ = initial_max_invalidation_versions; - if (max_invalidation_versions_.empty()) { + invalidation_state_map_ = initial_invalidation_state_map; + if (invalidation_state_map_.empty()) { DVLOG(2) << "No initial max invalidation versions for any id"; } else { - for (InvalidationVersionMap::const_iterator it = - max_invalidation_versions_.begin(); - it != max_invalidation_versions_.end(); ++it) { + for (InvalidationStateMap::const_iterator it = + invalidation_state_map_.begin(); + it != invalidation_state_map_.end(); ++it) { DVLOG(2) << "Initial max invalidation version for " << ObjectIdToString(it->first) << " is " - << it->second; + << it->second.version; } } invalidation_state_tracker_ = invalidation_state_tracker; @@ -141,17 +141,16 @@ void SyncInvalidationListener::Invalidate( // should drop invalidations for unregistered ids. We may also // have to filter it at a higher level, as invalidations for // newly-unregistered ids may already be in flight. - InvalidationVersionMap::const_iterator it = - max_invalidation_versions_.find(id); - if ((it != max_invalidation_versions_.end()) && - (invalidation.version() <= it->second)) { + InvalidationStateMap::const_iterator it = invalidation_state_map_.find(id); + if ((it != invalidation_state_map_.end()) && + (invalidation.version() <= it->second.version)) { // Drop redundant invalidations. client->Acknowledge(ack_handle); return; } DVLOG(2) << "Setting max invalidation version for " << ObjectIdToString(id) << " to " << invalidation.version(); - max_invalidation_versions_[id] = invalidation.version(); + invalidation_state_map_[id].version = invalidation.version(); invalidation_state_tracker_.Call( FROM_HERE, &InvalidationStateTracker::SetMaxVersion, @@ -313,7 +312,7 @@ void SyncInvalidationListener::Stop() { delegate_ = NULL; invalidation_state_tracker_.Reset(); - max_invalidation_versions_.clear(); + invalidation_state_map_.clear(); ticl_state_ = DEFAULT_INVALIDATION_ERROR; push_client_state_ = DEFAULT_INVALIDATION_ERROR; } diff --git a/sync/notifier/sync_invalidation_listener.h b/sync/notifier/sync_invalidation_listener.h index d1fc079..a167119 100644 --- a/sync/notifier/sync_invalidation_listener.h +++ b/sync/notifier/sync_invalidation_listener.h @@ -75,7 +75,7 @@ class SyncInvalidationListener create_invalidation_client_callback, const std::string& client_id, const std::string& client_info, const std::string& invalidation_bootstrap_data, - const InvalidationVersionMap& initial_max_invalidation_versions, + const InvalidationStateMap& initial_invalidation_state_map, const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, Delegate* delegate); @@ -142,7 +142,7 @@ class SyncInvalidationListener // Owned by |sync_system_resources_|. notifier::PushClient* const push_client_; SyncSystemResources sync_system_resources_; - InvalidationVersionMap max_invalidation_versions_; + InvalidationStateMap invalidation_state_map_; WeakHandle<InvalidationStateTracker> invalidation_state_tracker_; Delegate* delegate_; scoped_ptr<invalidation::InvalidationClient> invalidation_client_; diff --git a/sync/notifier/sync_invalidation_listener_unittest.cc b/sync/notifier/sync_invalidation_listener_unittest.cc index a335060..2de36c8 100644 --- a/sync/notifier/sync_invalidation_listener_unittest.cc +++ b/sync/notifier/sync_invalidation_listener_unittest.cc @@ -296,7 +296,7 @@ class SyncInvalidationListenerTest : public testing::Test { client_.Start(base::Bind(&CreateFakeInvalidationClient, &fake_invalidation_client_), kClientId, kClientInfo, kState, - InvalidationVersionMap(), + fake_tracker_.GetAllInvalidationStates(), MakeWeakHandle(fake_tracker_.AsWeakPtr()), &fake_delegate_); DCHECK(fake_invalidation_client_); diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc index 8a8c76b..01da983 100644 --- a/sync/tools/sync_client.cc +++ b/sync/tools/sync_client.cc @@ -72,8 +72,8 @@ class NullInvalidationStateTracker NullInvalidationStateTracker() {} virtual ~NullInvalidationStateTracker() {} - virtual InvalidationVersionMap GetAllMaxVersions() const OVERRIDE { - return InvalidationVersionMap(); + virtual InvalidationStateMap GetAllInvalidationStates() const OVERRIDE { + return InvalidationStateMap(); } virtual void SetMaxVersion( diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc index 51cef83..73d78e3 100644 --- a/sync/tools/sync_listen_notifications.cc +++ b/sync/tools/sync_listen_notifications.cc @@ -85,8 +85,8 @@ class NullInvalidationStateTracker NullInvalidationStateTracker() {} virtual ~NullInvalidationStateTracker() {} - virtual InvalidationVersionMap GetAllMaxVersions() const OVERRIDE { - return InvalidationVersionMap(); + virtual InvalidationStateMap GetAllInvalidationStates() const OVERRIDE { + return InvalidationStateMap(); } virtual void SetMaxVersion( |