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

Side by Side Diff: sync/engine/process_updates_util.h

Issue 93433006: sync: Introduce ModelTypeRegistry and helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak in tests Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/get_updates_processor.cc ('k') | sync/engine/process_updates_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
9 #include <vector> 8 #include <vector>
10 9
11 #include "base/compiler_specific.h"
12 #include "sync/base/sync_export.h"
13 #include "sync/engine/syncer_types.h"
14 #include "sync/internal_api/public/base/model_type.h" 10 #include "sync/internal_api/public/base/model_type.h"
15 11
16 namespace sync_pb { 12 namespace sync_pb {
17 class GetUpdatesResponse;
18 class SyncEntity; 13 class SyncEntity;
19 } 14 }
20 15
21 namespace syncer { 16 namespace syncer {
22 17
23 namespace sessions { 18 namespace sessions {
24 class StatusController; 19 class StatusController;
25 } 20 }
26 21
27 namespace syncable { 22 namespace syncable {
28 class ModelNeutralWriteTransaction; 23 class ModelNeutralWriteTransaction;
29 class Directory; 24 class Directory;
30 } 25 }
31 26
32 class Cryptographer;
33
34 // TODO(rlarocque): Move these definitions somewhere else?
35 typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList; 27 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 28
47 // Processes all the updates associated with a single ModelType. 29 // Processes all the updates associated with a single ModelType.
48 void ProcessDownloadedUpdates( 30 void ProcessDownloadedUpdates(
49 syncable::Directory* dir, 31 syncable::Directory* dir,
50 syncable::ModelNeutralWriteTransaction* trans, 32 syncable::ModelNeutralWriteTransaction* trans,
51 ModelType type, 33 ModelType type,
52 const SyncEntityList& applicable_updates, 34 const SyncEntityList& applicable_updates,
53 sessions::StatusController* status); 35 sessions::StatusController* status);
54 36
55 // Checks whether or not an update is fit for processing.
56 //
57 // 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.
59 VerifyResult VerifyUpdate(
60 syncable::ModelNeutralWriteTransaction* trans,
61 const sync_pb::SyncEntity& entry,
62 ModelType requested_type);
63
64 // 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.
66 void ProcessUpdate(
67 const sync_pb::SyncEntity& proto_update,
68 const Cryptographer* cryptographer,
69 syncable::ModelNeutralWriteTransaction* const trans);
70
71 } // namespace syncer 37 } // namespace syncer
72 38
73 #endif // SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_ 39 #endif // SYNC_ENGINE_PROCESS_UPDATES_UTIL_H_
OLDNEW
« no previous file with comments | « sync/engine/get_updates_processor.cc ('k') | sync/engine/process_updates_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698