Index: sync/notifier/object_id_invalidation_map.h |
diff --git a/sync/notifier/object_id_invalidation_map.h b/sync/notifier/object_id_invalidation_map.h |
index bb97fb3b1337f63a9ee7b7200c6095d6da53a823..c17e101e83505e41c8b82fdb76fb5ae5edd1b0ac 100644 |
--- a/sync/notifier/object_id_invalidation_map.h |
+++ b/sync/notifier/object_id_invalidation_map.h |
@@ -1,4 +1,4 @@ |
-// Copyright 2012 The Chromium Authors. All rights reserved. |
+// 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. |
@@ -6,40 +6,67 @@ |
#define SYNC_NOTIFIER_OBJECT_ID_INVALIDATION_MAP_H_ |
#include <map> |
-#include <string> |
+#include <vector> |
-#include "base/basictypes.h" |
-#include "base/memory/scoped_ptr.h" |
-#include "google/cacheinvalidation/include/types.h" |
#include "sync/base/sync_export.h" |
#include "sync/internal_api/public/base/invalidation.h" |
#include "sync/notifier/invalidation_util.h" |
- |
-namespace base { |
-class ListValue; |
-} // namespace base |
+#include "sync/notifier/single_object_invalidation_set.h" |
namespace syncer { |
-typedef std::map<invalidation::ObjectId, |
- Invalidation, |
- ObjectIdLessThan> ObjectIdInvalidationMap; |
+// A set of notifications with some helper methods to organize them by object ID |
+// and version number. |
+class SYNC_EXPORT ObjectIdInvalidationMap { |
+ public: |
+ // Creates an invalidation map that includes an 'unknown version' |
+ // invalidation for each specified ID in |ids|. |
+ static ObjectIdInvalidationMap InvalidateAll(const ObjectIdSet& ids); |
+ |
+ ObjectIdInvalidationMap(); |
+ ~ObjectIdInvalidationMap(); |
+ |
+ // Returns set of ObjectIds for which at least one invalidation is present. |
+ ObjectIdSet GetObjectIds() const; |
+ |
+ // Returns true if this map contains no invalidations. |
+ bool Empty() const; |
+ |
+ // Returns true if both maps contain the same set of invalidations. |
+ bool operator==(const ObjectIdInvalidationMap& other) const; |
+ |
+ // Inserts a new invalidation into this map. |
+ void Insert(const Invalidation& invalidation); |
+ |
+ // Returns a new map containing the subset of invaliations from this map |
+ // whose IDs were in the specified |ids| set. |
+ ObjectIdInvalidationMap GetSubsetWithObjectIds(const ObjectIdSet& ids) const; |
+ |
+ // Returns the subset of invalidations with IDs matching |id|. |
+ const SingleObjectInvalidationSet& ForObject( |
+ invalidation::ObjectId id) const; |
+ |
+ // Returns the contents of this map in a single vector. |
+ void GetAllInvalidations(std::vector<syncer::Invalidation>* out) const; |
+ |
+ // Serialize this map to a value. |
+ scoped_ptr<base::ListValue> ToValue() const; |
+ |
+ // Deserialize the value into a map and use it to re-initialize this object. |
+ bool ResetFromValue(const base::ListValue& value); |
-// Converts between ObjectIdInvalidationMaps and ObjectIdSets. |
-ObjectIdSet ObjectIdInvalidationMapToSet( |
- const ObjectIdInvalidationMap& invalidation_map); |
-SYNC_EXPORT ObjectIdInvalidationMap ObjectIdSetToInvalidationMap( |
- const ObjectIdSet& ids, int64 version, const std::string& payload); |
+ // Prints the contentes of this map as a human-readable string. |
+ std::string ToString() const; |
-SYNC_EXPORT bool ObjectIdInvalidationMapEquals( |
- const ObjectIdInvalidationMap& invalidation_map1, |
- const ObjectIdInvalidationMap& invalidation_map2); |
+ private: |
+ typedef std::map<invalidation::ObjectId, |
+ SingleObjectInvalidationSet, |
+ ObjectIdLessThan> IdToListMap; |
-scoped_ptr<base::ListValue> ObjectIdInvalidationMapToValue( |
- const ObjectIdInvalidationMap& invalidation_map); |
+ ObjectIdInvalidationMap(const IdToListMap& map); |
-bool ObjectIdInvalidationMapFromValue(const base::ListValue& value, |
- ObjectIdInvalidationMap* out); |
+ IdToListMap map_; |
+}; |
} // namespace syncer |