Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // An InvalidationVersionTracker is an interface that handles getting | 5 // An InvalidationStateTracker is an interface that handles getting |
| 6 // and setting (persisting) max invalidation versions. | 6 // and setting (persisting) max invalidation versions and our local ack |
| 7 // handles. | |
| 7 | 8 |
| 8 #ifndef SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ | 9 #ifndef SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ |
| 9 #define SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ | 10 #define SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ |
| 10 | 11 |
| 12 #include <string> | |
| 11 #include <map> | 13 #include <map> |
| 12 | 14 |
| 13 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/callback_forward.h" | |
| 17 #include "base/memory/ref_counted.h" | |
| 14 #include "google/cacheinvalidation/include/types.h" | 18 #include "google/cacheinvalidation/include/types.h" |
| 19 #include "sync/internal_api/public/base/invalidation.h" | |
| 15 #include "sync/notifier/invalidation_util.h" | 20 #include "sync/notifier/invalidation_util.h" |
| 16 | 21 |
| 22 namespace base { | |
| 23 class TaskRunner; | |
| 24 } // namespace base | |
| 25 | |
| 17 namespace syncer { | 26 namespace syncer { |
| 18 | 27 |
| 19 typedef std::map<invalidation::ObjectId, int64, ObjectIdLessThan> | 28 // TODO(dcheng): Need a better name. |
|
akalin
2012/10/19 13:27:16
may want to have a separate smaller CL to add the
dcheng
2012/10/19 19:38:11
Sure, I'll pull this out into a separate CL.
| |
| 20 InvalidationVersionMap; | 29 struct LocalState { |
|
akalin
2012/10/19 13:27:16
i think since all the other "state" vars have been
dcheng
2012/10/19 19:38:11
Done.
| |
| 30 LocalState(); | |
| 31 ~LocalState(); | |
| 32 | |
| 33 int64 version; | |
| 34 AckHandle expected; | |
| 35 AckHandle current; | |
| 36 }; | |
| 37 | |
| 38 typedef std::map<invalidation::ObjectId, LocalState, ObjectIdLessThan> | |
| 39 InvalidationStateMap; | |
| 40 typedef std::map<invalidation::ObjectId, AckHandle, ObjectIdLessThan> | |
| 41 AckHandleMap; | |
| 21 | 42 |
| 22 class InvalidationStateTracker { | 43 class InvalidationStateTracker { |
| 23 public: | 44 public: |
| 24 InvalidationStateTracker() {} | 45 InvalidationStateTracker() {} |
| 25 | 46 |
| 26 virtual InvalidationVersionMap GetAllMaxVersions() const = 0; | 47 virtual InvalidationStateMap GetStateMap() const = 0; |
|
akalin
2012/10/19 13:27:16
perhaps GetAllInvalidationStates()?
dcheng
2012/10/19 19:38:11
Done.
| |
| 27 | 48 |
| 28 // |max_version| should be strictly greater than any existing max | 49 // |max_version| should be strictly greater than any existing max |
| 29 // version for |model_type|. | 50 // version for |model_type|. |
| 30 virtual void SetMaxVersion(const invalidation::ObjectId& id, | 51 virtual void SetMaxVersion(const invalidation::ObjectId& id, |
| 31 int64 max_version) = 0; | 52 int64 max_version) = 0; |
| 32 // Removes all state tracked for |ids|. | 53 // Removes all state tracked for |ids|. |
| 33 virtual void Forget(const ObjectIdSet& ids) = 0; | 54 virtual void Forget(const ObjectIdSet& ids) = 0; |
| 34 | 55 |
| 35 // Used by invalidation::InvalidationClient for persistence. |data| is an | 56 // Used by invalidation::InvalidationClient for persistence. |data| is an |
| 36 // opaque blob that an invalidation client can use after a restart to | 57 // opaque blob that an invalidation client can use after a restart to |
| 37 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls, | 58 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls, |
| 38 // etc). | 59 // etc). |
| 39 virtual void SetBootstrapData(const std::string& data) = 0; | 60 virtual void SetBootstrapData(const std::string& data) = 0; |
| 40 virtual std::string GetBootstrapData() const = 0; | 61 virtual std::string GetBootstrapData() const = 0; |
| 41 | 62 |
| 63 // Used for generating our own local ack handles. Generates a new ack handle | |
| 64 // for each object id in |ids|. The result is returned via |callback| posted | |
| 65 // to |task_runner|. | |
| 66 virtual void GenerateAckHandles( | |
| 67 const ObjectIdSet& ids, | |
| 68 const scoped_refptr<base::TaskRunner>& task_runner, | |
| 69 base::Callback<void(const AckHandleMap&)> callback) = 0; | |
| 70 virtual void Acknowledge(const invalidation::ObjectId& id, | |
| 71 const AckHandle& ack_handle) = 0; | |
| 72 | |
| 42 protected: | 73 protected: |
| 43 virtual ~InvalidationStateTracker() {} | 74 virtual ~InvalidationStateTracker() {} |
| 44 }; | 75 }; |
| 45 | 76 |
| 46 } // namespace syncer | 77 } // namespace syncer |
| 47 | 78 |
| 48 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ | 79 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ |
| OLD | NEW |