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

Unified Diff: sync/notifier/mock_ack_handler.h

Issue 40303005: Add code for new invalidation local ack system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt at fixing win Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/notifier/dropped_invalidation_tracker.cc ('k') | sync/notifier/mock_ack_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/notifier/mock_ack_handler.h
diff --git a/sync/notifier/mock_ack_handler.h b/sync/notifier/mock_ack_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..665955892bfd60803b1e429db781694471ae4d4b
--- /dev/null
+++ b/sync/notifier/mock_ack_handler.h
@@ -0,0 +1,64 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_
+#define SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_
+
+#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"
+
+namespace syncer {
+
+class Invalidation;
+
+// This AckHandler implementation colaborates with the FakeInvalidationService
+// to enable unit tests to assert that invalidations are being acked properly.
+class MockAckHandler
+ : public AckHandler,
+ public base::SupportsWeakPtr<MockAckHandler> {
+ public:
+ MockAckHandler();
+ virtual ~MockAckHandler();
+
+ // Sets up some internal state to track this invalidation, and modifies it so
+ // that its Acknowledge() and Drop() methods will route back to us.
+ void RegisterInvalidation(Invalidation* invalidation);
+
+ // No one was listening for this invalidation, so no one will receive it or
+ // ack it. We keep track of it anyway to let tests make assertions about it.
+ void RegisterUnsentInvalidation(Invalidation* invalidation);
+
+ // Returns true if the specified invalidaition has been delivered, but has not
+ // been acknowledged yet.
+ bool IsUnacked(const Invalidation& invalidation) const;
+
+ // Returns true if the specified invalidation was never delivered.
+ bool IsUnsent(const Invalidation& invalidation) const;
+
+ // Implementation of AckHandler.
+ 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;
+
+ WeakHandle<AckHandler> WeakHandleThis();
+
+ InvalidationVector unsent_invalidations_;
+ InvalidationVector unacked_invalidations_;
+ InvalidationVector acked_invalidations_;
+};
+
+} // namespace syncer
+
+#endif // SYNC_NOTIFIER_MOCK_ACK_HANDLER_H_
« no previous file with comments | « sync/notifier/dropped_invalidation_tracker.cc ('k') | sync/notifier/mock_ack_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698