Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: sync/notifier/invalidation_state_tracker.h

Issue 11415049: Implement features needed for local ack handling in InvalidationStateTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 persisting state
6 // and setting (persisting) max invalidation versions. 6 // needed for invalidations. Currently, it is responsible for managing the
7 // following information:
8 // - Max version and payload seen from the invalidation server.
9 // - Bootstrap data for the invalidation client.
10 // - Locally generated ack handles.
7 11
8 #ifndef SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ 12 #ifndef SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
9 #define SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ 13 #define SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
10 14
11 #include <map> 15 #include <map>
16 #include <string>
12 17
13 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 #include "base/callback_forward.h"
20 #include "base/memory/ref_counted.h"
14 #include "google/cacheinvalidation/include/types.h" 21 #include "google/cacheinvalidation/include/types.h"
22 #include "sync/internal_api/public/base/invalidation.h"
15 #include "sync/notifier/invalidation_util.h" 23 #include "sync/notifier/invalidation_util.h"
16 24
25 namespace base {
26 class TaskRunner;
27 } // namespace base
28
17 namespace syncer { 29 namespace syncer {
18 30
19 struct InvalidationState { 31 struct InvalidationState {
32 InvalidationState();
33 ~InvalidationState();
34
20 int64 version; 35 int64 version;
36 std::string payload;
37 AckHandle expected;
38 AckHandle current;
21 }; 39 };
22 40
23 // TODO(dcheng): Remove this in favor of adding an Equals() method. 41 // TODO(dcheng): Remove this in favor of adding an Equals() method.
24 bool operator==(const InvalidationState& lhs, const InvalidationState& rhs); 42 bool operator==(const InvalidationState& lhs, const InvalidationState& rhs);
25 43
26 typedef std::map<invalidation::ObjectId, InvalidationState, ObjectIdLessThan> 44 typedef std::map<invalidation::ObjectId, InvalidationState, ObjectIdLessThan>
27 InvalidationStateMap; 45 InvalidationStateMap;
46 typedef std::map<invalidation::ObjectId, AckHandle, ObjectIdLessThan>
47 AckHandleMap;
28 48
29 class InvalidationStateTracker { 49 class InvalidationStateTracker {
30 public: 50 public:
31 InvalidationStateTracker() {} 51 InvalidationStateTracker() {}
32 52
33 virtual InvalidationStateMap GetAllInvalidationStates() const = 0; 53 virtual InvalidationStateMap GetAllInvalidationStates() const = 0;
34 54
35 // |max_version| should be strictly greater than any existing max 55 // |max_version| should be strictly greater than any existing max
36 // version for |model_type|. 56 // version for |model_type|.
37 virtual void SetMaxVersion(const invalidation::ObjectId& id, 57 virtual void SetMaxVersionAndPayload(const invalidation::ObjectId& id,
38 int64 max_version) = 0; 58 int64 max_version,
59 const std::string& payload) = 0;
39 // Removes all state tracked for |ids|. 60 // Removes all state tracked for |ids|.
40 virtual void Forget(const ObjectIdSet& ids) = 0; 61 virtual void Forget(const ObjectIdSet& ids) = 0;
41 62
42 // Used by invalidation::InvalidationClient for persistence. |data| is an 63 // Used by invalidation::InvalidationClient for persistence. |data| is an
43 // opaque blob that an invalidation client can use after a restart to 64 // opaque blob that an invalidation client can use after a restart to
44 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls, 65 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls,
45 // etc). 66 // etc).
46 virtual void SetBootstrapData(const std::string& data) = 0; 67 virtual void SetBootstrapData(const std::string& data) = 0;
47 virtual std::string GetBootstrapData() const = 0; 68 virtual std::string GetBootstrapData() const = 0;
48 69
70 // Used for generating our own local ack handles. Generates a new ack handle
71 // for each object id in |ids|. The result is returned via |callback| posted
72 // to |task_runner|.
73 virtual void GenerateAckHandles(
74 const ObjectIdSet& ids,
75 const scoped_refptr<base::TaskRunner>& task_runner,
76 base::Callback<void(const AckHandleMap&)> callback) = 0;
77 virtual void Acknowledge(const invalidation::ObjectId& id,
akalin 2012/11/28 00:11:42 newline before, add comment?
dcheng 2012/11/30 01:42:54 Done.
78 const AckHandle& ack_handle) = 0;
79
49 protected: 80 protected:
50 virtual ~InvalidationStateTracker() {} 81 virtual ~InvalidationStateTracker() {}
51 }; 82 };
52 83
53 } // namespace syncer 84 } // namespace syncer
54 85
55 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ 86 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698