1 // Copyright 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.
5 #ifndef SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
6 #define SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
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"
21 } // namespace syncable
23 class SyncDirectoryUpdateHandler
;
24 class SyncDirectoryCommitContributor
;
26 typedef std::map
<ModelType
, SyncDirectoryUpdateHandler
*> UpdateHandlerMap
;
27 typedef std::map
<ModelType
, SyncDirectoryCommitContributor
*>
30 // Keeps track of the sets of active update handlers and commit contributors.
31 class SYNC_EXPORT_PRIVATE ModelTypeRegistry
{
34 const std::vector
<scoped_refptr
<ModelSafeWorker
> >& workers
,
35 syncable::Directory
* directory
);
38 // Sets the set of enabled types.
39 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo
& routing_info
);
42 UpdateHandlerMap
* update_handler_map();
43 CommitContributorMap
* commit_contributor_map();
46 // Classes to manage the types hooked up to receive and commit sync data.
47 UpdateHandlerMap update_handler_map_
;
48 CommitContributorMap commit_contributor_map_
;
50 // Deleter for the |update_handler_map_|.
51 STLValueDeleter
<UpdateHandlerMap
> update_handler_deleter_
;
53 // Deleter for the |commit_contributor_map_|.
54 STLValueDeleter
<CommitContributorMap
> commit_contributor_deleter_
;
56 // The known ModelSafeWorkers.
57 std::map
<ModelSafeGroup
, scoped_refptr
<ModelSafeWorker
> > workers_map_
;
59 // The directory. Not owned.
60 syncable::Directory
* directory_
;
62 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry
);
67 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_