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.
5 #include "sync/notifier/object_id_payload_map.h"
9 ObjectIdSet
ObjectIdPayloadMapToSet(
10 const ObjectIdPayloadMap
& id_payloads
) {
12 for (ObjectIdPayloadMap::const_iterator it
= id_payloads
.begin();
13 it
!= id_payloads
.end(); ++it
) {
14 ids
.insert(it
->first
);
19 ObjectIdPayloadMap
ObjectIdSetToPayloadMap(ObjectIdSet ids
,
20 const std::string
& payload
) {
21 ObjectIdPayloadMap id_payloads
;
22 for (ObjectIdSet::const_iterator it
= ids
.begin(); it
!= ids
.end(); ++it
) {
23 id_payloads
[*it
] = payload
;
28 ModelTypePayloadMap
ObjectIdPayloadMapToModelTypePayloadMap(
29 const ObjectIdPayloadMap
& id_payloads
) {
30 ModelTypePayloadMap types_with_payloads
;
31 for (ObjectIdPayloadMap::const_iterator it
= id_payloads
.begin();
32 it
!= id_payloads
.end(); ++it
) {
34 if (!ObjectIdToRealModelType(it
->first
, &model_type
)) {
35 DLOG(WARNING
) << "Invalid object ID: "
36 << ObjectIdToString(it
->first
);
39 types_with_payloads
[model_type
] = it
->second
;
41 return types_with_payloads
;
44 ObjectIdPayloadMap
ModelTypePayloadMapToObjectIdPayloadMap(
45 const ModelTypePayloadMap
& type_payloads
) {
46 ObjectIdPayloadMap id_payloads
;
47 for (ModelTypePayloadMap::const_iterator it
= type_payloads
.begin();
48 it
!= type_payloads
.end(); ++it
) {
49 invalidation::ObjectId id
;
50 if (!RealModelTypeToObjectId(it
->first
, &id
)) {
51 DLOG(WARNING
) << "Invalid model type " << it
->first
;
54 id_payloads
[id
] = it
->second
;