OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sync/engine/process_updates_util.h" | 5 #include "sync/engine/process_updates_util.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "sync/engine/syncer_proto_util.h" | 8 #include "sync/engine/syncer_proto_util.h" |
9 #include "sync/engine/syncer_util.h" | 9 #include "sync/engine/syncer_util.h" |
10 #include "sync/syncable/directory.h" | 10 #include "sync/syncable/directory.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // reflections of these items. Instead, we assume any received tombstones | 69 // reflections of these items. Instead, we assume any received tombstones |
70 // are reflections. That should be correct most of the time. | 70 // are reflections. That should be correct most of the time. |
71 return false; | 71 return false; |
72 } | 72 } |
73 | 73 |
74 return existing_version < update.version(); | 74 return existing_version < update.version(); |
75 } | 75 } |
76 | 76 |
77 } // namespace | 77 } // namespace |
78 | 78 |
79 void PartitionUpdatesByType( | |
80 const sync_pb::GetUpdatesResponse& updates, | |
81 ModelTypeSet requested_types, | |
82 TypeSyncEntityMap* updates_by_type) { | |
83 int update_count = updates.entries().size(); | |
84 for (ModelTypeSet::Iterator it = requested_types.First(); | |
85 it.Good(); it.Inc()) { | |
86 updates_by_type->insert(std::make_pair(it.Get(), SyncEntityList())); | |
87 } | |
88 for (int i = 0; i < update_count; ++i) { | |
89 const sync_pb::SyncEntity& update = updates.entries(i); | |
90 ModelType type = GetModelType(update); | |
91 if (!IsRealDataType(type)) { | |
92 NOTREACHED() << "Received update with invalid type."; | |
93 continue; | |
94 } | |
95 | |
96 TypeSyncEntityMap::iterator it = updates_by_type->find(type); | |
97 if (it == updates_by_type->end()) { | |
98 DLOG(WARNING) << "Skipping update for unexpected type " | |
99 << ModelTypeToString(type); | |
100 continue; | |
101 } | |
102 | |
103 it->second.push_back(&update); | |
104 } | |
105 } | |
106 | |
107 void ProcessDownloadedUpdates( | 79 void ProcessDownloadedUpdates( |
108 syncable::Directory* dir, | 80 syncable::Directory* dir, |
109 syncable::ModelNeutralWriteTransaction* trans, | 81 syncable::ModelNeutralWriteTransaction* trans, |
110 ModelType type, | 82 ModelType type, |
111 const SyncEntityList& applicable_updates, | 83 const SyncEntityList& applicable_updates, |
112 sessions::StatusController* status) { | 84 sessions::StatusController* status) { |
113 for (SyncEntityList::const_iterator update_it = applicable_updates.begin(); | 85 for (SyncEntityList::const_iterator update_it = applicable_updates.begin(); |
114 update_it != applicable_updates.end(); ++update_it) { | 86 update_it != applicable_updates.end(); ++update_it) { |
115 DCHECK_EQ(type, GetModelType(**update_it)); | 87 DCHECK_EQ(type, GetModelType(**update_it)); |
116 if (!UpdateContainsNewVersion(trans, **update_it)) | 88 if (!UpdateContainsNewVersion(trans, **update_it)) |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 target_entry.PutBaseServerSpecifics( | 292 target_entry.PutBaseServerSpecifics( |
321 sync_pb::EntitySpecifics()); | 293 sync_pb::EntitySpecifics()); |
322 } | 294 } |
323 | 295 |
324 UpdateServerFieldsFromUpdate(&target_entry, update, name); | 296 UpdateServerFieldsFromUpdate(&target_entry, update, name); |
325 | 297 |
326 return; | 298 return; |
327 } | 299 } |
328 | 300 |
329 } // namespace syncer | 301 } // namespace syncer |
OLD | NEW |