OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sync/notifier/object_id_state_map.h" |
| 6 |
| 7 namespace syncer { |
| 8 |
| 9 ObjectIdSet ObjectIdStateMapToSet(const ObjectIdStateMap& id_state_map) { |
| 10 ObjectIdSet ids; |
| 11 for (ObjectIdStateMap::const_iterator it = id_state_map.begin(); |
| 12 it != id_state_map.end(); ++it) { |
| 13 ids.insert(it->first); |
| 14 } |
| 15 return ids; |
| 16 } |
| 17 |
| 18 ObjectIdStateMap ObjectIdSetToStateMap(const ObjectIdSet& ids, |
| 19 const std::string& payload) { |
| 20 ObjectIdStateMap id_state_map; |
| 21 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { |
| 22 // TODO(dcheng): Do we need to provide a way to set AckHandle? |
| 23 id_state_map[*it].payload = payload; |
| 24 } |
| 25 return id_state_map; |
| 26 } |
| 27 |
| 28 ModelTypeStateMap ObjectIdStateMapToModelTypeStateMap( |
| 29 const ObjectIdStateMap& id_state_map) { |
| 30 ModelTypeStateMap type_state_map; |
| 31 for (ObjectIdStateMap::const_iterator it = id_state_map.begin(); |
| 32 it != id_state_map.end(); ++it) { |
| 33 ModelType model_type; |
| 34 if (!ObjectIdToRealModelType(it->first, &model_type)) { |
| 35 DLOG(WARNING) << "Invalid object ID: " |
| 36 << ObjectIdToString(it->first); |
| 37 continue; |
| 38 } |
| 39 type_state_map[model_type] = it->second; |
| 40 } |
| 41 return type_state_map; |
| 42 } |
| 43 |
| 44 ObjectIdStateMap ModelTypeStateMapToObjectIdStateMap( |
| 45 const ModelTypeStateMap& type_state_map) { |
| 46 ObjectIdStateMap id_state_map; |
| 47 for (ModelTypeStateMap::const_iterator it = type_state_map.begin(); |
| 48 it != type_state_map.end(); ++it) { |
| 49 invalidation::ObjectId id; |
| 50 if (!RealModelTypeToObjectId(it->first, &id)) { |
| 51 DLOG(WARNING) << "Invalid model type " << it->first; |
| 52 continue; |
| 53 } |
| 54 id_state_map[id] = it->second; |
| 55 } |
| 56 return id_state_map; |
| 57 } |
| 58 |
| 59 } // namespace syncer |
OLD | NEW |