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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 !entry->GetDictionary("state", &invalidation_value) || | 83 !entry->GetDictionary("state", &invalidation_value) || |
84 !ObjectIdFromValue(*id_value, &id) || | 84 !ObjectIdFromValue(*id_value, &id) || |
85 !invalidation.ResetFromValue(*invalidation_value)) { | 85 !invalidation.ResetFromValue(*invalidation_value)) { |
86 return false; | 86 return false; |
87 } | 87 } |
88 ignore_result(out->insert(std::make_pair(id, invalidation))); | 88 ignore_result(out->insert(std::make_pair(id, invalidation))); |
89 } | 89 } |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 ModelTypeInvalidationMap ObjectIdInvalidationMapToModelTypeInvalidationMap( | |
94 const ObjectIdInvalidationMap& invalidation_map) { | |
95 ModelTypeInvalidationMap type_invalidation_map; | |
96 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); | |
97 it != invalidation_map.end(); ++it) { | |
98 ModelType model_type; | |
99 if (!ObjectIdToRealModelType(it->first, &model_type)) { | |
100 DLOG(WARNING) << "Invalid object ID: " | |
101 << ObjectIdToString(it->first); | |
102 continue; | |
103 } | |
104 type_invalidation_map[model_type] = it->second; | |
105 } | |
106 return type_invalidation_map; | |
107 } | |
108 | |
109 ObjectIdInvalidationMap ModelTypeInvalidationMapToObjectIdInvalidationMap( | |
110 const ModelTypeInvalidationMap& invalidation_map) { | |
111 ObjectIdInvalidationMap id_invalidation_map; | |
112 for (ModelTypeInvalidationMap::const_iterator it = invalidation_map.begin(); | |
113 it != invalidation_map.end(); ++it) { | |
114 invalidation::ObjectId id; | |
115 if (!RealModelTypeToObjectId(it->first, &id)) { | |
116 DLOG(WARNING) << "Invalid model type " << it->first; | |
117 continue; | |
118 } | |
119 id_invalidation_map[id] = it->second; | |
120 } | |
121 return id_invalidation_map; | |
122 } | |
123 | |
124 } // namespace syncer | 93 } // namespace syncer |
OLD | NEW |