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

Unified Diff: sync/engine/process_updates_util.h

Issue 38803003: sync: Implement per-type update processing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix integration tests Created 7 years, 2 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/engine/process_updates_util.h
diff --git a/sync/engine/process_updates_util.h b/sync/engine/process_updates_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..c096850134307254d2605f4ce6ed0587b7c6b7b8
--- /dev/null
+++ b/sync/engine/process_updates_util.h
@@ -0,0 +1,73 @@
+// Copyright 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.
+
+#ifndef SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_
+#define SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_
+
+#include <map>
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "sync/base/sync_export.h"
+#include "sync/engine/syncer_types.h"
+#include "sync/internal_api/public/base/model_type.h"
+
+namespace sync_pb {
+class GetUpdatesResponse;
+class SyncEntity;
+}
+
+namespace syncer {
+
+namespace sessions {
+class StatusController;
+}
+
+namespace syncable {
+class ModelNeutralWriteTransaction;
+class Directory;
+}
+
+class Cryptographer;
+
+// TODO: Move these definitions somewhere else?
Nicolas Zea 2013/10/25 21:04:41 TODO(rlarocque)
rlarocque 2013/10/25 22:29:47 Done.
+typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList;
+typedef std::map<ModelType, SyncEntityList> TypeSyncEntityMap;
+
+// Given a GetUpdates response, iterates over all the returned items and
+// divides them according to their type. Outputs a map from model types to
+// received SyncEntities. The output map will have entries (possibly empty)
+// for all types in |requested_types|.
+void PartitionUpdatesByType(
+ const sync_pb::GetUpdatesResponse& updates,
+ ModelTypeSet requested_types,
+ TypeSyncEntityMap* updates_by_type);
+
+// Processes all the updates associated with a single ModelType.
+void ProcessDownloadedUpdates(
+ syncable::Directory* dir,
+ syncable::ModelNeutralWriteTransaction* trans,
+ ModelType type,
+ const SyncEntityList& applicable_updates,
+ sessions::StatusController* status);
+
+// Checks whether or not an update is fit for processing.
+//
+// The answer may be "no" if the update appears invalid, or it's not releveant
+// (ie. a delete for an item we've never heard of), or other reasons.
+VerifyResult VerifyUpdate(
+ syncable::ModelNeutralWriteTransaction* trans,
+ const sync_pb::SyncEntity& entry,
+ ModelType requested_type);
+
+// If the update passes a series of checks, this function will copy
+// the SyncEntity's data into the SERVER side of the syncable::Directory.
+void ProcessUpdate(
+ const sync_pb::SyncEntity& proto_update,
+ const Cryptographer* cryptographer,
+ syncable::ModelNeutralWriteTransaction* const trans);
+
+} // namespace syncer
+
+#endif // SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698