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

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

Issue 93433006: sync: Introduce ModelTypeRegistry and helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor map ownership 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
OLDNEW
(Empty)
1 // Copyright (c) 2014 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_MODEL_TYPE_REGISTRY_H_
6 #define SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h"
13 #include "sync/base/sync_export.h"
14 #include "sync/internal_api/public/base/model_type.h"
15 #include "sync/internal_api/public/engine/model_safe_worker.h"
16
17 namespace syncer {
18
19 class CommitterList;
20 class UpdaterList;
21
22 namespace syncable {
23 class Directory;
24 } // namespace syncable
25
26 class SyncDirectoryUpdateHandler;
27 class SyncDirectoryCommitContributor;
28
29 typedef std::map<ModelType, SyncDirectoryUpdateHandler*> UpdateHandlerMap;
30 typedef std::map<ModelType, SyncDirectoryCommitContributor*>
31 CommitContributorMap;
32
33 // Keeps track of the sets of active update handlers and commit contributors.
34 class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
35 public:
36 ModelTypeRegistry(
37 const std::vector<ModelSafeWorker*>& workers,
38 syncable::Directory* directory);
39 ~ModelTypeRegistry();
40
41 // Sets the set of enabled types.
42 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info);
43
44 // Simple getters.
45 UpdateHandlerMap* update_handler_map();
46 CommitContributorMap* commit_contributor_map();
47
48 private:
49 // Classes to manage the types hooked up to receive and commit sync data.
50 UpdateHandlerMap update_handler_map_;
51 CommitContributorMap commit_contributor_map_;
52
53 // Deleter for the |update_handler_map_|.
54 STLValueDeleter<UpdateHandlerMap> update_handler_deleter_;
55
56 // Deleter for the |commit_contributor_map_|.
57 STLValueDeleter<CommitContributorMap> commit_contributor_deleter_;
58
59 // The known ModelSafeWorkers.
60 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_;
61
62 // The directory. Not owned.
63 syncable::Directory* directory_;
64
65 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry);
66 };
67
68 } // namespace syncer
69
70 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
71
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698