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

Unified Diff: sync/internal_api/public/base/invalidation.h

Issue 23441042: Refactor common invalidation framework types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move DEPS rule 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/internal_api/public/base/ack_handle.cc ('k') | sync/internal_api/public/base/invalidation.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/public/base/invalidation.h
diff --git a/sync/internal_api/public/base/invalidation.h b/sync/internal_api/public/base/invalidation.h
index 851dbed747338433be6db6ba745318c87040b3bc..2b83564b54c2ed3c694257abb574d3d08502d048 100644
--- a/sync/internal_api/public/base/invalidation.h
+++ b/sync/internal_api/public/base/invalidation.h
@@ -9,59 +9,73 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-#include "base/time/time.h"
+#include "base/values.h"
+#include "google/cacheinvalidation/include/types.h"
#include "sync/base/sync_export.h"
-
-namespace base {
-class DictionaryValue;
-} // namespace
+#include "sync/internal_api/public/base/ack_handle.h"
namespace syncer {
-// Opaque class that represents a local ack handle. We don't reuse the
-// invalidation ack handles to avoid unnecessary dependencies.
-class SYNC_EXPORT AckHandle {
+class DroppedInvalidationTracker;
+class AckHandler;
+
+// Represents a local invalidation, and is roughly analogous to
+// invalidation::Invalidation. Unlike invalidation::Invalidation, this class
+// supports "local" ack-tracking and simple serialization to pref values.
+class SYNC_EXPORT Invalidation {
public:
- static AckHandle CreateUnique();
- static AckHandle InvalidAckHandle();
+ // Factory functions.
+ static Invalidation Init(
+ const invalidation::ObjectId& id,
+ int64 version,
+ const std::string& payload);
+ static Invalidation InitUnknownVersion(const invalidation::ObjectId& id);
+ static scoped_ptr<Invalidation> InitFromValue(
+ const base::DictionaryValue& value);
+
+ ~Invalidation();
+
+ // Compares two invalidations. The comparison ignores ack-tracking state.
+ bool Equals(const Invalidation& other) const;
- bool Equals(const AckHandle& other) const;
+ invalidation::ObjectId object_id() const;
+ bool is_unknown_version() const;
- scoped_ptr<base::DictionaryValue> ToValue() const;
- bool ResetFromValue(const base::DictionaryValue& value);
+ // Safe to call only if is_unknown_version() returns false.
+ int64 version() const;
- bool IsValid() const;
+ // Safe to call only if is_unknown_version() returns false.
+ const std::string& payload() const;
- ~AckHandle();
+ const AckHandle& ack_handle() const;
+ void set_ack_handle(const AckHandle& ack_handle);
+
+ scoped_ptr<base::DictionaryValue> ToValue() const;
+ std::string ToString() const;
private:
- // Explicitly copyable and assignable for STL containers.
- AckHandle(const std::string& state, base::Time timestamp);
+ Invalidation(const invalidation::ObjectId& id,
+ bool is_unknown_version,
+ int64 version,
+ const std::string& payload,
+ AckHandle ack_handle);
- std::string state_;
- base::Time timestamp_;
-};
+ // The ObjectId to which this invalidation belongs.
+ invalidation::ObjectId id_;
-// Represents a local invalidation, and is roughly analogous to
-// invalidation::Invalidation. It contains a version (which may be
-// kUnknownVersion), a payload (which may be empty) and an
-// associated ack handle that an InvalidationHandler implementation can use to
-// acknowledge receipt of the invalidation. It does not embed the object ID,
-// since it is typically associated with it through ObjectIdInvalidationMap.
-struct SYNC_EXPORT Invalidation {
- static const int64 kUnknownVersion;
-
- Invalidation();
- ~Invalidation();
+ // This flag is set to true if this is an unknown version invalidation.
+ bool is_unknown_version_;
- bool Equals(const Invalidation& other) const;
+ // The version number of this invalidation. Should not be accessed if this is
+ // an unkown version invalidation.
+ int64 version_;
- scoped_ptr<base::DictionaryValue> ToValue() const;
- bool ResetFromValue(const base::DictionaryValue& value);
+ // The payaload associated with this invalidation. Should not be accessed if
+ // this is an unknown version invalidation.
+ std::string payload_;
- int64 version;
- std::string payload;
- AckHandle ack_handle;
+ // A locally generated unique ID used to manage local acknowledgements.
+ AckHandle ack_handle_;
};
} // namespace syncer
« no previous file with comments | « sync/internal_api/public/base/ack_handle.cc ('k') | sync/internal_api/public/base/invalidation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698