Fix bug in load time stats.
[chromium-blink-merge.git] / sync / notifier / object_id_payload_map.cc
blob7fa1f7cac35860b216912ffb6bb48a9a7593f13d
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"
7 namespace syncer {
9 ObjectIdSet ObjectIdPayloadMapToSet(
10 const ObjectIdPayloadMap& id_payloads) {
11 ObjectIdSet ids;
12 for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin();
13 it != id_payloads.end(); ++it) {
14 ids.insert(it->first);
16 return ids;
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;
25 return id_payloads;
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) {
33 ModelType model_type;
34 if (!ObjectIdToRealModelType(it->first, &model_type)) {
35 DLOG(WARNING) << "Invalid object ID: "
36 << ObjectIdToString(it->first);
37 continue;
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;
52 continue;
54 id_payloads[id] = it->second;
56 return id_payloads;
59 } // namespace syncer