| 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 #ifndef SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_ | 5 #ifndef SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_ |
| 6 #define SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_ | 6 #define SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class StatusController; | 24 class StatusController; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace syncable { | 27 namespace syncable { |
| 28 class ModelNeutralWriteTransaction; | 28 class ModelNeutralWriteTransaction; |
| 29 class Directory; | 29 class Directory; |
| 30 } | 30 } |
| 31 | 31 |
| 32 class Cryptographer; | 32 class Cryptographer; |
| 33 | 33 |
| 34 // TODO(rlarocque): Move these definitions somewhere else? | |
| 35 typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList; | 34 typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList; |
| 36 typedef std::map<ModelType, SyncEntityList> TypeSyncEntityMap; | |
| 37 | |
| 38 // Given a GetUpdates response, iterates over all the returned items and | |
| 39 // divides them according to their type. Outputs a map from model types to | |
| 40 // received SyncEntities. The output map will have entries (possibly empty) | |
| 41 // for all types in |requested_types|. | |
| 42 void PartitionUpdatesByType( | |
| 43 const sync_pb::GetUpdatesResponse& updates, | |
| 44 ModelTypeSet requested_types, | |
| 45 TypeSyncEntityMap* updates_by_type); | |
| 46 | 35 |
| 47 // Processes all the updates associated with a single ModelType. | 36 // Processes all the updates associated with a single ModelType. |
| 48 void ProcessDownloadedUpdates( | 37 void ProcessDownloadedUpdates( |
| 49 syncable::Directory* dir, | 38 syncable::Directory* dir, |
| 50 syncable::ModelNeutralWriteTransaction* trans, | 39 syncable::ModelNeutralWriteTransaction* trans, |
| 51 ModelType type, | 40 ModelType type, |
| 52 const SyncEntityList& applicable_updates, | 41 const SyncEntityList& applicable_updates, |
| 53 sessions::StatusController* status); | 42 sessions::StatusController* status); |
| 54 | 43 |
| 55 // Checks whether or not an update is fit for processing. | 44 // Checks whether or not an update is fit for processing. |
| 56 // | 45 // |
| 57 // The answer may be "no" if the update appears invalid, or it's not releveant | 46 // The answer may be "no" if the update appears invalid, or it's not releveant |
| 58 // (ie. a delete for an item we've never heard of), or other reasons. | 47 // (ie. a delete for an item we've never heard of), or other reasons. |
| 59 VerifyResult VerifyUpdate( | 48 VerifyResult VerifyUpdate( |
| 60 syncable::ModelNeutralWriteTransaction* trans, | 49 syncable::ModelNeutralWriteTransaction* trans, |
| 61 const sync_pb::SyncEntity& entry, | 50 const sync_pb::SyncEntity& entry, |
| 62 ModelType requested_type); | 51 ModelType requested_type); |
| 63 | 52 |
| 64 // If the update passes a series of checks, this function will copy | 53 // If the update passes a series of checks, this function will copy |
| 65 // the SyncEntity's data into the SERVER side of the syncable::Directory. | 54 // the SyncEntity's data into the SERVER side of the syncable::Directory. |
| 66 void ProcessUpdate( | 55 void ProcessUpdate( |
| 67 const sync_pb::SyncEntity& proto_update, | 56 const sync_pb::SyncEntity& proto_update, |
| 68 const Cryptographer* cryptographer, | 57 const Cryptographer* cryptographer, |
| 69 syncable::ModelNeutralWriteTransaction* const trans); | 58 syncable::ModelNeutralWriteTransaction* const trans); |
| 70 | 59 |
| 71 } // namespace syncer | 60 } // namespace syncer |
| 72 | 61 |
| 73 #endif // SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_ | 62 #endif // SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_ |
| OLD | NEW |