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

Side by Side Diff: components/invalidation/mock_ack_handler.h

Issue 1191393008: Introduce a layering in the invalidation component as public and impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explicitly forbid content to prevent future additions Created 5 years, 6 months 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
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_INVALIDATION_MOCK_ACK_HANDLER_H_
6 #define COMPONENTS_INVALIDATION_MOCK_ACK_HANDLER_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "components/invalidation/ack_handler.h"
14 #include "components/invalidation/invalidation_export.h"
15 #include "components/invalidation/invalidation_util.h"
16
17 namespace syncer {
18
19 class Invalidation;
20
21 // This AckHandler implementation colaborates with the FakeInvalidationService
22 // to enable unit tests to assert that invalidations are being acked properly.
23 class INVALIDATION_EXPORT MockAckHandler
24 : public AckHandler,
25 public base::SupportsWeakPtr<MockAckHandler> {
26 public:
27 MockAckHandler();
28 ~MockAckHandler() override;
29
30 // Sets up some internal state to track this invalidation, and modifies it so
31 // that its Acknowledge() and Drop() methods will route back to us.
32 void RegisterInvalidation(Invalidation* invalidation);
33
34 // No one was listening for this invalidation, so no one will receive it or
35 // ack it. We keep track of it anyway to let tests make assertions about it.
36 void RegisterUnsentInvalidation(Invalidation* invalidation);
37
38 // Returns true if the specified invalidaition has been delivered, but has not
39 // been acknowledged yet.
40 bool IsUnacked(const Invalidation& invalidation) const;
41
42 // Returns true if the specified invalidation has been delivered and
43 // acknowledged.
44 bool IsAcknowledged(const Invalidation& invalidation) const;
45
46 // Returns true if the specified invalidation has been delivered and
47 // dropped.
48 bool IsDropped(const Invalidation& invalidation) const;
49
50 // Returns true if the specified invalidation was never delivered.
51 bool IsUnsent(const Invalidation& invalidation) const;
52
53 // Retruns true if all invalidations have been acked and all drops recovered.
54 bool AllInvalidationsAccountedFor() const;
55
56 // Implementation of AckHandler.
57 void Acknowledge(const invalidation::ObjectId& id,
58 const AckHandle& handle) override;
59 void Drop(const invalidation::ObjectId& id, const AckHandle& handle) override;
60
61 private:
62 typedef std::vector<syncer::Invalidation> InvalidationVector;
63 typedef std::map<invalidation::ObjectId,
64 AckHandle,
65 ObjectIdLessThan> IdHandleMap;
66
67 InvalidationVector unsent_invalidations_;
68 InvalidationVector unacked_invalidations_;
69 InvalidationVector acked_invalidations_;
70 InvalidationVector dropped_invalidations_;
71
72 IdHandleMap unrecovered_drop_events_;
73 };
74
75 } // namespace syncer
76
77 #endif // COMPONENTS_INVALIDATION_MOCK_ACK_HANDLER_H_
OLDNEW
« no previous file with comments | « components/invalidation/invalidator_test_template.cc ('k') | components/invalidation/mock_ack_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698