OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 InvalidationStateTracker is an interface that handles persisting state | 5 // An InvalidationStateTracker is an interface that handles persisting state |
6 // needed for invalidations. Currently, it is responsible for managing the | 6 // needed for invalidations. Currently, it is responsible for managing the |
7 // following information: | 7 // following information: |
8 // - Max version seen from the invalidation server to help dedupe invalidations. | 8 // - Max version seen from the invalidation server to help dedupe invalidations. |
9 // - Bootstrap data for the invalidation client. | 9 // - Bootstrap data for the invalidation client. |
10 // - Payloads and locally generated ack handles, to support local acking. | 10 // - Payloads and locally generated ack handles, to support local acking. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 virtual InvalidationStateMap GetAllInvalidationStates() const = 0; | 55 virtual InvalidationStateMap GetAllInvalidationStates() const = 0; |
56 | 56 |
57 // |max_version| should be strictly greater than any existing max | 57 // |max_version| should be strictly greater than any existing max |
58 // version for |model_type|. | 58 // version for |model_type|. |
59 virtual void SetMaxVersionAndPayload(const invalidation::ObjectId& id, | 59 virtual void SetMaxVersionAndPayload(const invalidation::ObjectId& id, |
60 int64 max_version, | 60 int64 max_version, |
61 const std::string& payload) = 0; | 61 const std::string& payload) = 0; |
62 // Removes all state tracked for |ids|. | 62 // Removes all state tracked for |ids|. |
63 virtual void Forget(const ObjectIdSet& ids) = 0; | 63 virtual void Forget(const ObjectIdSet& ids) = 0; |
64 | 64 |
| 65 // The per-client unique ID used to register the invalidation client with the |
| 66 // server. This is used to 'squelch' invalidation notifications that |
| 67 // originate from changes made by this client. |
| 68 virtual void SetInvalidatorClientId(const std::string& data) = 0; |
| 69 virtual std::string GetInvalidatorClientId() const = 0; |
| 70 |
65 // Used by invalidation::InvalidationClient for persistence. |data| is an | 71 // Used by invalidation::InvalidationClient for persistence. |data| is an |
66 // opaque blob that an invalidation client can use after a restart to | 72 // opaque blob that an invalidation client can use after a restart to |
67 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls, | 73 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls, |
68 // etc). | 74 // etc). |
69 virtual void SetBootstrapData(const std::string& data) = 0; | 75 virtual void SetBootstrapData(const std::string& data) = 0; |
70 virtual std::string GetBootstrapData() const = 0; | 76 virtual std::string GetBootstrapData() const = 0; |
71 | 77 |
| 78 // Erases invalidation versions, client ID, and state stored on disk. |
| 79 virtual void Clear() = 0; |
| 80 |
72 // Used for generating our own local ack handles. Generates a new ack handle | 81 // Used for generating our own local ack handles. Generates a new ack handle |
73 // for each object id in |ids|. The result is returned via |callback| posted | 82 // for each object id in |ids|. The result is returned via |callback| posted |
74 // to |task_runner|. | 83 // to |task_runner|. |
75 virtual void GenerateAckHandles( | 84 virtual void GenerateAckHandles( |
76 const ObjectIdSet& ids, | 85 const ObjectIdSet& ids, |
77 const scoped_refptr<base::TaskRunner>& task_runner, | 86 const scoped_refptr<base::TaskRunner>& task_runner, |
78 base::Callback<void(const AckHandleMap&)> callback) = 0; | 87 base::Callback<void(const AckHandleMap&)> callback) = 0; |
79 | 88 |
80 // Records an acknowledgement for |id|. Note that no attempt at ordering is | 89 // Records an acknowledgement for |id|. Note that no attempt at ordering is |
81 // made. Acknowledge() only records the last ack_handle it received, even if | 90 // made. Acknowledge() only records the last ack_handle it received, even if |
82 // the last ack_handle it received was generated before the value currently | 91 // the last ack_handle it received was generated before the value currently |
83 // recorded. | 92 // recorded. |
84 virtual void Acknowledge(const invalidation::ObjectId& id, | 93 virtual void Acknowledge(const invalidation::ObjectId& id, |
85 const AckHandle& ack_handle) = 0; | 94 const AckHandle& ack_handle) = 0; |
86 | 95 |
87 protected: | 96 protected: |
88 virtual ~InvalidationStateTracker() {} | 97 virtual ~InvalidationStateTracker() {} |
89 }; | 98 }; |
90 | 99 |
91 } // namespace syncer | 100 } // namespace syncer |
92 | 101 |
93 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ | 102 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ |
OLD | NEW |