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

Side by Side Diff: sync/notifier/object_id_invalidation_map.h

Issue 387733004: Move sync/notifier to components/invalidation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (GN) Comment out dependency on internal target Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/notifier/mock_ack_handler.cc ('k') | sync/notifier/object_id_invalidation_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SYNC_NOTIFIER_OBJECT_ID_INVALIDATION_MAP_H_
6 #define SYNC_NOTIFIER_OBJECT_ID_INVALIDATION_MAP_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "sync/base/sync_export.h"
12 #include "sync/internal_api/public/base/invalidation.h"
13 #include "sync/notifier/invalidation_util.h"
14 #include "sync/notifier/single_object_invalidation_set.h"
15
16 namespace syncer {
17
18 // A set of notifications with some helper methods to organize them by object ID
19 // and version number.
20 class SYNC_EXPORT ObjectIdInvalidationMap {
21 public:
22 // Creates an invalidation map that includes an 'unknown version'
23 // invalidation for each specified ID in |ids|.
24 static ObjectIdInvalidationMap InvalidateAll(const ObjectIdSet& ids);
25
26 ObjectIdInvalidationMap();
27 ~ObjectIdInvalidationMap();
28
29 // Returns set of ObjectIds for which at least one invalidation is present.
30 ObjectIdSet GetObjectIds() const;
31
32 // Returns true if this map contains no invalidations.
33 bool Empty() const;
34
35 // Returns true if both maps contain the same set of invalidations.
36 bool operator==(const ObjectIdInvalidationMap& other) const;
37
38 // Inserts a new invalidation into this map.
39 void Insert(const Invalidation& invalidation);
40
41 // Returns a new map containing the subset of invaliations from this map
42 // whose IDs were in the specified |ids| set.
43 ObjectIdInvalidationMap GetSubsetWithObjectIds(const ObjectIdSet& ids) const;
44
45 // Returns the subset of invalidations with IDs matching |id|.
46 const SingleObjectInvalidationSet& ForObject(
47 invalidation::ObjectId id) const;
48
49 // Returns the contents of this map in a single vector.
50 void GetAllInvalidations(std::vector<syncer::Invalidation>* out) const;
51
52 // Call Acknowledge() on all contained Invalidations.
53 void AcknowledgeAll() const;
54
55 // Serialize this map to a value.
56 scoped_ptr<base::ListValue> ToValue() const;
57
58 // Deserialize the value into a map and use it to re-initialize this object.
59 bool ResetFromValue(const base::ListValue& value);
60
61 // Prints the contentes of this map as a human-readable string.
62 std::string ToString() const;
63
64 private:
65 typedef std::map<invalidation::ObjectId,
66 SingleObjectInvalidationSet,
67 ObjectIdLessThan> IdToListMap;
68
69 ObjectIdInvalidationMap(const IdToListMap& map);
70
71 IdToListMap map_;
72 };
73
74 } // namespace syncer
75
76 #endif // SYNC_NOTIFIER_OBJECT_ID_INVALIDATION_MAP_H_
OLDNEW
« no previous file with comments | « sync/notifier/mock_ack_handler.cc ('k') | sync/notifier/object_id_invalidation_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698