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

Unified Diff: sync/notifier/object_id_payload_map.cc

Issue 10702074: Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DEPS Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: sync/notifier/object_id_payload_map.cc
diff --git a/sync/notifier/object_id_payload_map.cc b/sync/notifier/object_id_payload_map.cc
new file mode 100644
index 0000000000000000000000000000000000000000..747b8b7c2ec58e5eb5b686e009bbab26f3ef551b
--- /dev/null
+++ b/sync/notifier/object_id_payload_map.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/notifier/object_id_payload_map.h"
+
+namespace syncer {
+
+ModelTypePayloadMap ObjectIdPayloadMapToModelTypePayloadMap(
+ const ObjectIdPayloadMap& id_payloads) {
+ ModelTypePayloadMap types_with_payloads;
+ for (ObjectIdPayloadMap::const_iterator it = id_payloads.begin();
+ it != id_payloads.end(); ++it) {
+ ModelType model_type;
+ if (!syncer::ObjectIdToRealModelType(it->first, &model_type)) {
+ DLOG(WARNING) << "Invalid object ID: "
+ << syncer::ObjectIdToString(it->first);
+ continue;
+ }
+ types_with_payloads[model_type] = it->second;
+ }
+ return types_with_payloads;
+}
+
+syncer::ObjectIdPayloadMap ModelTypePayloadMapToObjectIdPayloadMap(
+ const ModelTypePayloadMap& type_payloads) {
+ ObjectIdPayloadMap id_payloads;
+ for (ModelTypePayloadMap::const_iterator it = type_payloads.begin();
+ it != type_payloads.end(); ++it) {
+ invalidation::ObjectId id;
+ if (!RealModelTypeToObjectId(it->first, &id)) {
+ DLOG(WARNING) << "Invalid model type " << it->first;
+ continue;
+ }
+ id_payloads[id] = it->second;
+ }
+ return id_payloads;
+}
+
+} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698