1 // Copyright 2014 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.
5 #ifndef SYNC_TEST_MOCK_INVALIDATION_TRACKER_H_
6 #define SYNC_TEST_MOCK_INVALIDATION_TRACKER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "sync/test/trackable_mock_invalidation.h"
15 // Instantiates and track the acknowledgement state of
16 // TrackableMockInvalidations.
17 class MockInvalidationTracker
{
19 // Builers to return new TrackableMockInvalidations associated with this
21 scoped_ptr
<TrackableMockInvalidation
> IssueUnknownVersionInvalidation();
22 scoped_ptr
<TrackableMockInvalidation
> IssueInvalidation(
24 const std::string
& payload
);
26 MockInvalidationTracker();
27 ~MockInvalidationTracker();
29 // Records the acknowledgement of the invalidation
30 // specified by the given ID.
31 void Acknowledge(int invaliation_id
);
33 // Records the drop of the invalidation specified by the given ID.
34 void Drop(int invalidation_id
);
36 // Returns true if the invalidation associated with the given ID is neither
37 // acknowledged nor dropped.
38 bool IsUnacked(int invalidation_id
) const;
40 // Returns true if the invalidation associated with the given ID is
42 bool IsAcknowledged(int invalidation_id
) const;
44 // Returns true if the invalidation associated with the given ID is dropped.
45 bool IsDropped(int invalidation_id
) const;
47 // Returns true if all issued invalidations were acknowledged or dropped.
48 bool AllInvalidationsAccountedFor() const;
51 // A counter used to assign strictly increasing IDs to each invalidation
52 // issued by this class.
55 // Acknowledgements and drops are tracked by adding the IDs for the
56 // acknowledged or dropped items to the proper set. An invalidation may be
57 // both dropped and acknowledged if it represents the recovery from a drop
59 std::set
<int> dropped_
;
60 std::set
<int> acknowledged_
;
65 #endif // SYNC_TEST_MOCK_INVALIDATION_TRACKER_H_