OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sync/notifier/object_id_invalidation_map.h" | 5 #include "sync/notifier/object_id_invalidation_map.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 | 8 |
9 namespace syncer { | 9 namespace syncer { |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 DCHECK(!lookup->second.IsEmpty()); | 57 DCHECK(!lookup->second.IsEmpty()); |
58 return lookup->second; | 58 return lookup->second; |
59 } | 59 } |
60 | 60 |
61 void ObjectIdInvalidationMap::GetAllInvalidations( | 61 void ObjectIdInvalidationMap::GetAllInvalidations( |
62 std::vector<syncer::Invalidation>* out) const { | 62 std::vector<syncer::Invalidation>* out) const { |
63 for (IdToListMap::const_iterator it = map_.begin(); it != map_.end(); ++it) { | 63 for (IdToListMap::const_iterator it = map_.begin(); it != map_.end(); ++it) { |
64 out->insert(out->begin(), it->second.begin(), it->second.end()); | 64 out->insert(out->begin(), it->second.begin(), it->second.end()); |
65 } | 65 } |
66 } | 66 } |
| 67 void ObjectIdInvalidationMap::AcknowledgeAll() const { |
| 68 for (IdToListMap::const_iterator it1 = map_.begin(); |
| 69 it1 != map_.end(); ++it1) { |
| 70 for (SingleObjectInvalidationSet::const_iterator it2 = it1->second.begin(); |
| 71 it2 != it1->second.end(); ++it2) { |
| 72 it2->Acknowledge(); |
| 73 } |
| 74 } |
| 75 } |
67 | 76 |
68 bool ObjectIdInvalidationMap::operator==( | 77 bool ObjectIdInvalidationMap::operator==( |
69 const ObjectIdInvalidationMap& other) const { | 78 const ObjectIdInvalidationMap& other) const { |
70 return map_ == other.map_; | 79 return map_ == other.map_; |
71 } | 80 } |
72 | 81 |
73 scoped_ptr<base::ListValue> ObjectIdInvalidationMap::ToValue() const { | 82 scoped_ptr<base::ListValue> ObjectIdInvalidationMap::ToValue() const { |
74 scoped_ptr<base::ListValue> value(new base::ListValue()); | 83 scoped_ptr<base::ListValue> value(new base::ListValue()); |
75 for (IdToListMap::const_iterator it1 = map_.begin(); | 84 for (IdToListMap::const_iterator it1 = map_.begin(); |
76 it1 != map_.end(); ++it1) { | 85 it1 != map_.end(); ++it1) { |
(...skipping 26 matching lines...) Expand all Loading... |
103 JSONStringValueSerializer serializer(&output); | 112 JSONStringValueSerializer serializer(&output); |
104 serializer.set_pretty_print(true); | 113 serializer.set_pretty_print(true); |
105 serializer.Serialize(*ToValue().get()); | 114 serializer.Serialize(*ToValue().get()); |
106 return output; | 115 return output; |
107 } | 116 } |
108 | 117 |
109 ObjectIdInvalidationMap::ObjectIdInvalidationMap(const IdToListMap& map) | 118 ObjectIdInvalidationMap::ObjectIdInvalidationMap(const IdToListMap& map) |
110 : map_(map) {} | 119 : map_(map) {} |
111 | 120 |
112 } // namespace syncer | 121 } // namespace syncer |
OLD | NEW |