#ifndef SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_
#define SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_
#include <map>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/util/weak_handle.h"
#include "sync/notifier/ack_handler.h"
#include "sync/notifier/invalidation_util.h"
namespace syncer {
class Invalidation;
class SYNC_EXPORT MockAckHandler
: public AckHandler,
public base::SupportsWeakPtr<MockAckHandler> {
public:
MockAckHandler();
virtual ~MockAckHandler();
void RegisterInvalidation(Invalidation* invalidation);
void RegisterUnsentInvalidation(Invalidation* invalidation);
bool IsUnacked(const Invalidation& invalidation) const;
bool IsAcknowledged(const Invalidation& invalidation) const;
bool IsDropped(const Invalidation& invalidation) const;
bool IsUnsent(const Invalidation& invalidation) const;
bool AllInvalidationsAccountedFor() const;
virtual void Acknowledge(
const invalidation::ObjectId& id,
const AckHandle& handle) OVERRIDE;
virtual void Drop(
const invalidation::ObjectId& id,
const AckHandle& handle) OVERRIDE;
private:
typedef std::vector<syncer::Invalidation> InvalidationVector;
typedef std::map<invalidation::ObjectId,
AckHandle,
ObjectIdLessThan> IdHandleMap;
WeakHandle<AckHandler> WeakHandleThis();
InvalidationVector unsent_invalidations_;
InvalidationVector unacked_invalidations_;
InvalidationVector acked_invalidations_;
InvalidationVector dropped_invalidations_;
IdHandleMap unrecovered_drop_events_;
};
}
#endif