OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SYNC_NOTIFIER_DROPPED_INVALIDATION_TRACKER_H_ | |
6 #define SYNC_NOTIFIER_DROPPED_INVALIDATION_TRACKER_H_ | |
7 | |
8 #include "google/cacheinvalidation/include/types.h" | |
9 #include "sync/base/sync_export.h" | |
10 #include "sync/internal_api/public/base/ack_handle.h" | |
11 #include "sync/internal_api/public/util/weak_handle.h" | |
12 #include "sync/notifier/ack_handler.h" | |
13 | |
14 namespace syncer { | |
15 | |
16 class Invalidation; | |
17 | |
18 // Helps InvalidationHandlers keep track of dropped invalidations for a given | |
19 // ObjectId. | |
20 // | |
21 // The intent of this class is to hide some of the implementation details around | |
22 // how the invalidations system manages dropping and drop recovery. Any | |
23 // invalidation handler that intends to buffer and occasionally drop | |
24 // invalidations should keep one instance of it per registered ObjectId. | |
25 // | |
26 // When an invalidation handler wishes to drop an invalidation, it must provide | |
27 // an instance of this class to that Invalidation's Drop() method. In order to | |
28 // indicate recovery from a drop, the handler can call this class' | |
29 // RecordRecoveryFromDropEvent(). | |
30 class SYNC_EXPORT DroppedInvalidationTracker { | |
31 public: | |
32 explicit DroppedInvalidationTracker(const invalidation::ObjectId& id); | |
33 ~DroppedInvalidationTracker(); | |
34 | |
35 const invalidation::ObjectId& object_id() const; | |
36 | |
37 // Called by Invalidation::Drop() to keep track of a drop event. | |
tim (not reviewing)
2013/10/30 02:03:07
Explain parameter or refer to comment at drop_ack_
| |
38 void RecordDropEvent(WeakHandle<AckHandler> handler, AckHandle handle); | |
39 | |
40 // Returns true if we're still recovering from a drop event. | |
41 bool IsRecoveringFromDropEvent() const; | |
42 | |
43 // Called by the InvalidationHandler when it recovers from the drop event. | |
44 void RecordRecoveryFromDropEvent(); | |
45 | |
46 private: | |
47 invalidation::ObjectId id_; | |
48 AckHandle drop_ack_handle_; | |
49 | |
50 // A WeakHandle to the enitity responsible for persisting invalidation | |
51 // acknowledgement state on disk. We can get away with using a WeakHandle | |
52 // because we don't care if our drop recovery message doesn't gets delivered | |
53 // in some shutdown cases. If that happens, we'll have to process the | |
54 // invalidation state again on the next restart. It would be a waste of time | |
55 // and resources, but otherwise not particularly harmful. | |
56 WeakHandle<AckHandler> drop_ack_handler_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(DroppedInvalidationTracker); | |
59 }; | |
60 | |
61 } // namespace syncer | |
62 | |
63 #endif // SYNC_NOTIFIER_DROPPED_INVALIDATION_TRACKER_H_ | |
OLD | NEW |