| 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" |
| 11 | 11 |
| 12 namespace syncer { | 12 namespace syncer { |
| 13 | 13 |
| 14 ObjectIdSet ObjectIdInvalidationMapToSet( | 14 ObjectIdSet ObjectIdInvalidationMapToSet( |
| 15 const ObjectIdInvalidationMap& invalidation_map) { | 15 const ObjectIdInvalidationMap& invalidation_map) { |
| 16 ObjectIdSet ids; | 16 ObjectIdSet ids; |
| 17 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); | 17 for (ObjectIdInvalidationMap::const_iterator it = invalidation_map.begin(); |
| 18 it != invalidation_map.end(); ++it) { | 18 it != invalidation_map.end(); ++it) { |
| 19 ids.insert(it->first); | 19 ids.insert(it->first); |
| 20 } | 20 } |
| 21 return ids; | 21 return ids; |
| 22 } | 22 } |
| 23 | 23 |
| 24 ObjectIdInvalidationMap ObjectIdSetToInvalidationMap( | 24 ObjectIdInvalidationMap ObjectIdSetToInvalidationMap( |
| 25 const ObjectIdSet& ids, const std::string& payload) { | 25 const ObjectIdSet& ids, int64 version, const std::string& payload) { |
| 26 ObjectIdInvalidationMap invalidation_map; | 26 ObjectIdInvalidationMap invalidation_map; |
| 27 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { | 27 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { |
| 28 // TODO(dcheng): Do we need to provide a way to set AckHandle? | 28 // TODO(dcheng): Do we need to provide a way to set AckHandle? |
| 29 invalidation_map[*it].version = version; |
| 29 invalidation_map[*it].payload = payload; | 30 invalidation_map[*it].payload = payload; |
| 30 } | 31 } |
| 31 return invalidation_map; | 32 return invalidation_map; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 struct ObjectIdInvalidationMapValueEquals { | 37 struct ObjectIdInvalidationMapValueEquals { |
| 37 bool operator()(const ObjectIdInvalidationMap::value_type& value1, | 38 bool operator()(const ObjectIdInvalidationMap::value_type& value1, |
| 38 const ObjectIdInvalidationMap::value_type& value2) const { | 39 const ObjectIdInvalidationMap::value_type& value2) const { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 if (!RealModelTypeToObjectId(it->first, &id)) { | 115 if (!RealModelTypeToObjectId(it->first, &id)) { |
| 115 DLOG(WARNING) << "Invalid model type " << it->first; | 116 DLOG(WARNING) << "Invalid model type " << it->first; |
| 116 continue; | 117 continue; |
| 117 } | 118 } |
| 118 id_invalidation_map[id] = it->second; | 119 id_invalidation_map[id] = it->second; |
| 119 } | 120 } |
| 120 return id_invalidation_map; | 121 return id_invalidation_map; |
| 121 } | 122 } |
| 122 | 123 |
| 123 } // namespace syncer | 124 } // namespace syncer |
| OLD | NEW |