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

Unified Diff: blimp/net/helium/vector_clock.h

Issue 2382533002: Helium: Initial proto and Syncable interface definition (Closed)
Patch Set: remainder stufft Created 4 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
Index: blimp/net/helium/vector_clock.h
diff --git a/blimp/net/helium/vector_clock.h b/blimp/net/helium/vector_clock.h
index c375aacc274a52b642d5da580c22579180ef25db..d5d9688178f5a72b529b81d921ef93834de4072e 100644
--- a/blimp/net/helium/vector_clock.h
+++ b/blimp/net/helium/vector_clock.h
@@ -7,6 +7,8 @@
#include <stdint.h>
+#include "blimp/common/proto/helium.pb.h"
+
namespace blimp {
// From wikipedia:
@@ -18,7 +20,7 @@ namespace blimp {
// For more info see:
// https://en.wikipedia.org/wiki/Vector_clock
-typedef uint32_t Revision;
+typedef uint64_t Revision;
class VectorClock {
public:
@@ -26,6 +28,7 @@ class VectorClock {
VectorClock(Revision local_revision, Revision remote_revision);
VectorClock();
+ VectorClock(const VectorClock&) = default;
// Compares two vector clocks. There are 4 possibilities for the result:
// * LessThan: One revision is equal and for the other is smaller.
@@ -56,6 +59,14 @@ class VectorClock {
remote_revision_ = remote_revision;
}
+ // Create the proto message corresponding to this object.
+ proto::VectorClockMessage ToProto() const;
+
+ // Inverts the local and remote components respectively.
+ // Used when we send VectorClock across the wire. The local becomes
+ // remote and vice versa.
+ VectorClock Invert() const;
+
private:
Revision local_revision_ = 0;
Revision remote_revision_ = 0;

Powered by Google App Engine
This is Rietveld 408576698