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" |
14 #include "google/cacheinvalidation/include/types.h" | 16 #include "google/cacheinvalidation/include/types.h" |
17 #include "sync/internal_api/public/base/invalidation_state.h" | |
15 #include "sync/notifier/invalidation_util.h" | 18 #include "sync/notifier/invalidation_util.h" |
16 | 19 |
17 namespace syncer { | 20 namespace syncer { |
18 | 21 |
19 typedef std::map<invalidation::ObjectId, int64, ObjectIdLessThan> | 22 // TODO(dcheng): Need a better name. |
akalin
2012/09/17 23:59:54
since this CL is pretty big and will take a while,
dcheng
2012/09/25 22:35:06
If you're relatively comfortable with the naming,
akalin
2012/10/01 23:23:08
We were talking about better names than 'state', r
| |
20 InvalidationVersionMap; | 23 struct LocalState { |
24 LocalState(); | |
25 ~LocalState(); | |
26 | |
27 int64 version; | |
28 std::string payload; | |
29 AckHandle expected; | |
30 AckHandle current; | |
31 }; | |
32 | |
33 typedef std::map<invalidation::ObjectId, LocalState, ObjectIdLessThan> | |
34 InvalidationStateMap; | |
35 typedef std::map<invalidation::ObjectId, AckHandle, ObjectIdLessThan> | |
36 AckHandleMap; | |
21 | 37 |
22 class InvalidationStateTracker { | 38 class InvalidationStateTracker { |
23 public: | 39 public: |
24 InvalidationStateTracker() {} | 40 InvalidationStateTracker() {} |
25 | 41 |
26 virtual InvalidationVersionMap GetAllMaxVersions() const = 0; | 42 virtual InvalidationStateMap GetStateMap() const = 0; |
27 | 43 |
28 // |max_version| should be strictly greater than any existing max | 44 // |max_version| should be strictly greater than any existing max |
29 // version for |model_type|. | 45 // version for |model_type|. |
30 virtual void SetMaxVersion(const invalidation::ObjectId& id, | 46 virtual void SetMaxVersion(const invalidation::ObjectId& id, |
31 int64 max_version) = 0; | 47 int64 max_version) = 0; |
32 // Removes all state tracked for |ids|. | 48 // Removes all state tracked for |ids|. |
33 virtual void Forget(const ObjectIdSet& ids) = 0; | 49 virtual void Forget(const ObjectIdSet& ids) = 0; |
34 | 50 |
35 // Used by InvalidationClient for persistence. |state| is opaque data we can | 51 // Used by InvalidationClient for persistence. |state| is opaque data we can |
36 // present back to the client (e.g. after a restart) for it to bootstrap | 52 // present back to the client (e.g. after a restart) for it to bootstrap |
37 // itself. | 53 // itself. |
38 // |state| is plain old data (not valid UTF8, embedded nulls, etc). | 54 // |state| is plain old data (not valid UTF8, embedded nulls, etc). |
39 virtual void SetInvalidationState(const std::string& state) = 0; | 55 virtual void SetInvalidationState(const std::string& state) = 0; |
40 virtual std::string GetInvalidationState() const = 0; | 56 virtual std::string GetInvalidationState() const = 0; |
41 | 57 |
58 // Used for generating our own local ack handles. | |
59 // Generates a new ack handle for each object id in |ids|. The resulting ack | |
60 // handles are passed back in the output parameter rather than being returned | |
61 // directly, since this method is typically used with PostTaskAndReply. | |
62 virtual void GenerateAckHandles(const ObjectIdSet& ids, | |
63 AckHandleMap* ack_handles) = 0; | |
64 virtual void Acknowledge(const invalidation::ObjectId& id, | |
65 const AckHandle& ack_handle) = 0; | |
66 | |
42 protected: | 67 protected: |
43 virtual ~InvalidationStateTracker() {} | 68 virtual ~InvalidationStateTracker() {} |
44 }; | 69 }; |
45 | 70 |
46 } // namespace syncer | 71 } // namespace syncer |
47 | 72 |
48 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ | 73 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ |
OLD | NEW |