OLD | NEW |
| (Empty) |
1 // Copyright 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 #ifndef SYNC_ENGINE_PROCESS_UPDATES_COMMAND_H_ | |
6 #define SYNC_ENGINE_PROCESS_UPDATES_COMMAND_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "sync/base/sync_export.h" | |
10 #include "sync/engine/model_changing_syncer_command.h" | |
11 #include "sync/engine/syncer_types.h" | |
12 | |
13 namespace sync_pb { | |
14 class GetUpdatesResponse; | |
15 class SyncEntity; | |
16 } | |
17 | |
18 namespace syncer { | |
19 | |
20 namespace syncable { | |
21 class ModelNeutralWriteTransaction; | |
22 } | |
23 | |
24 class Cryptographer; | |
25 | |
26 // A syncer command for verifying and processing updates. | |
27 // | |
28 // Preconditions - Updates in the SyncerSesssion have been downloaded. | |
29 // | |
30 // Postconditions - All of the verified SyncEntity data will be copied to | |
31 // the server fields of the corresponding syncable entries. | |
32 class SYNC_EXPORT_PRIVATE ProcessUpdatesCommand : public SyncerCommand { | |
33 public: | |
34 ProcessUpdatesCommand(); | |
35 virtual ~ProcessUpdatesCommand(); | |
36 | |
37 protected: | |
38 // SyncerCommand implementation. | |
39 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; | |
40 | |
41 private: | |
42 typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList; | |
43 typedef std::map<ModelType, SyncEntityList> TypeSyncEntityMap; | |
44 | |
45 // Given a GetUpdates response, iterates over all the returned items and | |
46 // divides them according to their type. Outputs a map from model types to | |
47 // received SyncEntities. ModelTypes that had no items in the update response | |
48 // will not be included in this map. | |
49 static void PartitionUpdatesByType( | |
50 const sync_pb::GetUpdatesResponse& updates, | |
51 TypeSyncEntityMap* updates_by_type); | |
52 | |
53 VerifyResult VerifyUpdate( | |
54 syncable::ModelNeutralWriteTransaction* trans, | |
55 const sync_pb::SyncEntity& entry, | |
56 ModelTypeSet requested_types, | |
57 const ModelSafeRoutingInfo& routes); | |
58 void ProcessUpdate( | |
59 const sync_pb::SyncEntity& proto_update, | |
60 const Cryptographer* cryptographer, | |
61 syncable::ModelNeutralWriteTransaction* const trans); | |
62 DISALLOW_COPY_AND_ASSIGN(ProcessUpdatesCommand); | |
63 }; | |
64 | |
65 } // namespace syncer | |
66 | |
67 #endif // SYNC_ENGINE_PROCESS_UPDATES_COMMAND_H_ | |
OLD | NEW |