OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 const ObjectIdInvalidationMap& invalidation_map2) { | 49 const ObjectIdInvalidationMap& invalidation_map2) { |
50 return | 50 return |
51 (invalidation_map1.size() == invalidation_map2.size()) && | 51 (invalidation_map1.size() == invalidation_map2.size()) && |
52 std::equal(invalidation_map1.begin(), invalidation_map1.end(), | 52 std::equal(invalidation_map1.begin(), invalidation_map1.end(), |
53 invalidation_map2.begin(), | 53 invalidation_map2.begin(), |
54 ObjectIdInvalidationMapValueEquals()); | 54 ObjectIdInvalidationMapValueEquals()); |
55 } | 55 } |
56 | 56 |
57 scoped_ptr<base::ListValue> ObjectIdInvalidationMapToValue( | 57 scoped_ptr<base::ListValue> ObjectIdInvalidationMapToValue( |
58 const ObjectIdInvalidationMap& invalidation_map) { | 58 const ObjectIdInvalidationMap& invalidation_map) { |
59 scoped_ptr<ListValue> value(new ListValue()); | 59 scoped_ptr<base::ListValue> value(new base::ListValue()); |
60 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); | 60 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); |
61 it != invalidation_map.end(); ++it) { | 61 it != invalidation_map.end(); ++it) { |
62 DictionaryValue* entry = new DictionaryValue(); | 62 base::DictionaryValue* entry = new base::DictionaryValue(); |
63 entry->Set("objectId", ObjectIdToValue(it->first).release()); | 63 entry->Set("objectId", ObjectIdToValue(it->first).release()); |
64 entry->Set("state", it->second.ToValue().release()); | 64 entry->Set("state", it->second.ToValue().release()); |
65 value->Append(entry); | 65 value->Append(entry); |
66 } | 66 } |
67 return value.Pass(); | 67 return value.Pass(); |
68 } | 68 } |
69 | 69 |
70 bool ObjectIdInvalidationMapFromValue(const base::ListValue& value, | 70 bool ObjectIdInvalidationMapFromValue(const base::ListValue& value, |
71 ObjectIdInvalidationMap* out) { | 71 ObjectIdInvalidationMap* out) { |
72 out->clear(); | 72 out->clear(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (!RealModelTypeToObjectId(it->first, &id)) { | 114 if (!RealModelTypeToObjectId(it->first, &id)) { |
115 DLOG(WARNING) << "Invalid model type " << it->first; | 115 DLOG(WARNING) << "Invalid model type " << it->first; |
116 continue; | 116 continue; |
117 } | 117 } |
118 id_invalidation_map[id] = it->second; | 118 id_invalidation_map[id] = it->second; |
119 } | 119 } |
120 return id_invalidation_map; | 120 return id_invalidation_map; |
121 } | 121 } |
122 | 122 |
123 } // namespace syncer | 123 } // namespace syncer |
OLD | NEW |