Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: sync/notifier/object_id_payload_map.cc

Issue 10837214: Refactor ModelTypePayloadMap and ObjectIdPayloadMap to StateMaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/notifier/object_id_payload_map.h ('k') | sync/notifier/object_id_state_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_payload_map.h"
6
7 namespace syncer {
8
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);
15 }
16 return ids;
17 }
18
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;
24 }
25 return id_payloads;
26 }
27
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;
38 }
39 types_with_payloads[model_type] = it->second;
40 }
41 return types_with_payloads;
42 }
43
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;
53 }
54 id_payloads[id] = it->second;
55 }
56 return id_payloads;
57 }
58
59 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/object_id_payload_map.h ('k') | sync/notifier/object_id_state_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698