#ifndef SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
#define SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_
#include <map>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/engine/model_safe_worker.h"
namespace syncer {
namespace syncable {
class Directory;
}
class CommitContributor;
class DirectoryCommitContributor;
class DirectoryUpdateHandler;
class NonBlockingTypeProcessorCore;
class NonBlockingTypeProcessor;
class UpdateHandler;
typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap;
typedef std::map<ModelType, CommitContributor*> CommitContributorMap;
class SYNC_EXPORT_PRIVATE ModelTypeRegistry {
public:
ModelTypeRegistry();
ModelTypeRegistry(
const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
syncable::Directory* directory);
~ModelTypeRegistry();
void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info);
void InitializeNonBlockingType(
syncer::ModelType type,
scoped_refptr<base::SequencedTaskRunner> type_task_runner,
base::WeakPtr<NonBlockingTypeProcessor> processor);
void RemoveNonBlockingType(syncer::ModelType type);
ModelTypeSet GetEnabledTypes() const;
UpdateHandlerMap* update_handler_map();
CommitContributorMap* commit_contributor_map();
private:
ModelTypeSet GetEnabledNonBlockingTypes() const;
ModelTypeSet GetEnabledDirectoryTypes() const;
ScopedVector<DirectoryCommitContributor> directory_commit_contributors_;
ScopedVector<DirectoryUpdateHandler> directory_update_handlers_;
ScopedVector<NonBlockingTypeProcessorCore> non_blocking_type_processor_cores_;
UpdateHandlerMap update_handler_map_;
CommitContributorMap commit_contributor_map_;
std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_;
syncable::Directory* directory_;
ModelTypeSet enabled_directory_types_;
DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry);
};
}
#endif