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

Side by Side Diff: sync/notifier/object_id_state_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, 3 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_state_map.h ('k') | sync/notifier/object_id_state_map_test_util.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_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
OLDNEW
« no previous file with comments | « sync/notifier/object_id_state_map.h ('k') | sync/notifier/object_id_state_map_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698