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 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 bool is_unknown_version() const; | 44 bool is_unknown_version() const; |
45 | 45 |
46 // Safe to call only if is_unknown_version() returns false. | 46 // Safe to call only if is_unknown_version() returns false. |
47 int64 version() const; | 47 int64 version() const; |
48 | 48 |
49 // Safe to call only if is_unknown_version() returns false. | 49 // Safe to call only if is_unknown_version() returns false. |
50 const std::string& payload() const; | 50 const std::string& payload() const; |
51 | 51 |
52 const AckHandle& ack_handle() const; | 52 const AckHandle& ack_handle() const; |
53 | 53 |
54 // TODO(rlarocque): Remove this method and use AckHandlers instead. | 54 // Sets the AckHandler to be used to track this Invalidation. |
55 void set_ack_handle(const AckHandle& ack_handle); | 55 // |
| 56 // This should be set by the class that generates the invalidation. Clients |
| 57 // of the Invalidations API should not need to call this. |
| 58 // |
| 59 // Note that some sources of invalidations do not support ack tracking, and do |
| 60 // not set the ack_handler. This will be hidden from users of this class. |
| 61 void set_ack_handler(syncer::WeakHandle<AckHandler> ack_handler); |
56 | 62 |
57 // Functions from the alternative ack tracking framework. | 63 // Returns whether or not this instance supports ack tracking. This will |
58 // Currently unused. | 64 // depend on whether or not the source of invaliadations supports |
59 void set_ack_handler(syncer::WeakHandle<AckHandler> ack_handler); | 65 // invalidations. |
| 66 // |
| 67 // Clients can safely ignore this flag. They can assume that all |
| 68 // invalidations support ack tracking. If they're wrong, then invalidations |
| 69 // will be less reliable, but their behavior will be no less correct. |
60 bool SupportsAcknowledgement() const; | 70 bool SupportsAcknowledgement() const; |
| 71 |
| 72 // Acknowledges the receipt of this invalidation. |
| 73 // |
| 74 // Clients should call this on a received invalidation when they have fully |
| 75 // processed the invalidation and persisted the results to disk. Once this |
| 76 // function is called, the invalidations system is under no obligation to |
| 77 // re-deliver this invalidation in the event of a crash or restart. |
61 void Acknowledge() const; | 78 void Acknowledge() const; |
62 | 79 |
63 // Drops an invalidation. | 80 // Informs the ack tracker that this invalidation will not be serviced. |
| 81 // |
| 82 // If a client's buffer reaches its limit and it is forced to start dropping |
| 83 // invalidations, it should call this function before dropping its |
| 84 // invalidations in order to allow the ack tracker to drop the invalidation, |
| 85 // too. |
64 // | 86 // |
65 // The drop record will be tracked by the specified | 87 // The drop record will be tracked by the specified |
66 // DroppedInvalidationTracker. The caller should hang on to this tracker. It | 88 // DroppedInvalidationTracker. The caller should hang on to this tracker. It |
67 // will need to use it when it recovers from this drop event. See the | 89 // will need to use it when it recovers from this drop event, or if it needs |
| 90 // to record another drop event for the same ObjectID. Refer to the |
68 // documentation of DroppedInvalidationTracker for more details. | 91 // documentation of DroppedInvalidationTracker for more details. |
69 void Drop(DroppedInvalidationTracker* tracker) const; | 92 void Drop(DroppedInvalidationTracker* tracker) const; |
70 | 93 |
71 scoped_ptr<base::DictionaryValue> ToValue() const; | 94 scoped_ptr<base::DictionaryValue> ToValue() const; |
72 std::string ToString() const; | 95 std::string ToString() const; |
73 | 96 |
74 private: | 97 private: |
75 Invalidation(const invalidation::ObjectId& id, | 98 Invalidation(const invalidation::ObjectId& id, |
76 bool is_unknown_version, | 99 bool is_unknown_version, |
77 int64 version, | 100 int64 version, |
(...skipping 15 matching lines...) Expand all Loading... |
93 std::string payload_; | 116 std::string payload_; |
94 | 117 |
95 // A locally generated unique ID used to manage local acknowledgements. | 118 // A locally generated unique ID used to manage local acknowledgements. |
96 AckHandle ack_handle_; | 119 AckHandle ack_handle_; |
97 syncer::WeakHandle<AckHandler> ack_handler_; | 120 syncer::WeakHandle<AckHandler> ack_handler_; |
98 }; | 121 }; |
99 | 122 |
100 } // namespace syncer | 123 } // namespace syncer |
101 | 124 |
102 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ | 125 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ |
OLD | NEW |