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

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

Issue 93433006: sync: Introduce ModelTypeRegistry and helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split the type manager Created 7 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 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_UPDATER_LIST_H_
6 #define SYNC_ENGINE_UPDATER_LIST_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "base/stl_util.h"
12 #include "sync/base/sync_export.h"
13 #include "sync/internal_api/public/base/model_type.h"
14 #include "sync/internal_api/public/engine/model_safe_worker.h"
15
16 namespace sync_pb {
17 class GetUpdatesMessage;
18 class GetUpdatesResponse;
19 } // namespace sync_pb
20
21 namespace syncer {
22
23 namespace sessions {
24 class StatusController;
25 } // namespace sessions
26
27 namespace syncable {
28 class Directory;
29 } // namespace syncable
30
31 class SyncDirectoryUpdateHandler;
32
33 typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList;
34 typedef std::map<ModelType, SyncEntityList> TypeSyncEntityMap;
35
36 // This class manages the set of per-type syncer objects.
37 //
38 // It owns these types and hides the details of iterating over all of them.
39 // Most methods allow the caller to specify a subset of types on which the
40 // operation is to be applied. It is a logic error if the supplied set of types
41 // contains a type which was not previously registered with the manager.
42 class SYNC_EXPORT_PRIVATE UpdaterList {
43 public:
44 UpdaterList();
45 ~UpdaterList();
46
47 // Builds or rebuilds the set of syncable::Directory sync type objects.
48 void SetEnabledSyncDirectoryTypes(
49 const std::vector<scoped_refptr<ModelSafeWorker> > workers,
50 const ModelSafeRoutingInfo& routing_info,
51 syncable::Directory* dir);
52
53 // Populates a GetUpdates request message with per-type information.
54 void PrepareGetUpdates(ModelTypeSet gu_types,
55 sync_pb::GetUpdatesMessage* get_updates);
56
57 // Processes a GetUpdates responses for each type.
58 bool ProcessGetUpdatesResponse(
59 ModelTypeSet gu_types,
60 const sync_pb::GetUpdatesResponse& gu_response,
61 sessions::StatusController* status_controller);
62
63 // Applies pending updates for all sync types known to the manager.
64 void ApplyUpdatesForAllTypes(sessions::StatusController* status_controller);
65
66 // Registers an update handler directly. Useful in tests.
67 void RegisterTypeForTest(
68 ModelType type,
69 SyncDirectoryUpdateHandler* handler);
70
71 private:
72 typedef std::map<ModelType, SyncDirectoryUpdateHandler*> UpdateHandlerMap;
73
74 // A map of 'update handlers', one for each enabled type.
75 // This must be kept in sync with the routing info. Our temporary solution to
76 // that problem is to initialize this map in set_routing_info().
77 UpdateHandlerMap update_handler_map_;
78
79 // Deleter for the |update_handler_map_|.
80 STLValueDeleter<UpdateHandlerMap> update_handler_deleter_;
81 };
82
83 } // namespace syncer
84
85 #endif // SYNC_ENGINE_UPDATER_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698