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.
5 #ifndef SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_
6 #define SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "sync/base/sync_export.h"
13 #include "sync/internal_api/public/util/weak_handle.h"
14 #include "sync/notifier/ack_handler.h"
20 // This AckHandler implementation colaborates with the FakeInvalidationService
21 // to enable unit tests to assert that invalidations are being acked properly.
24 public base::SupportsWeakPtr
<MockAckHandler
> {
27 virtual ~MockAckHandler();
29 // Sets up some internal state to track this invalidation, and modifies it so
30 // that its Acknowledge() and Drop() methods will route back to us.
31 void RegisterInvalidation(Invalidation
* invalidation
);
33 // No one was listening for this invalidation, so no one will receive it or
34 // ack it. We keep track of it anyway to let tests make assertions about it.
35 void RegisterUnsentInvalidation(Invalidation
* invalidation
);
37 // Returns true if the specified invalidaition has been delivered, but has not
38 // been acknowledged yet.
39 bool IsUnacked(const Invalidation
& invalidation
) const;
41 // Returns true if the specified invalidation was never delivered.
42 bool IsUnsent(const Invalidation
& invalidation
) const;
44 // Implementation of AckHandler.
45 virtual void Acknowledge(
46 const invalidation::ObjectId
& id
,
47 const AckHandle
& handle
) OVERRIDE
;
49 const invalidation::ObjectId
& id
,
50 const AckHandle
& handle
) OVERRIDE
;
53 typedef std::vector
<syncer::Invalidation
> InvalidationVector
;
55 WeakHandle
<AckHandler
> WeakHandleThis();
57 InvalidationVector unsent_invalidations_
;
58 InvalidationVector unacked_invalidations_
;
59 InvalidationVector acked_invalidations_
;
64 #endif // SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_