| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_MODEL_TYPE_REGISTRY_H_ | 5 #ifndef SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ |
| 6 #define SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ | 6 #define SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "sync/base/sync_export.h" | 13 #include "sync/base/sync_export.h" |
| 14 #include "sync/internal_api/public/base/model_type.h" | 14 #include "sync/internal_api/public/base/model_type.h" |
| 15 #include "sync/internal_api/public/engine/model_safe_worker.h" | 15 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 16 | 16 |
| 17 namespace syncer { | 17 namespace syncer { |
| 18 | 18 |
| 19 namespace syncable { | 19 namespace syncable { |
| 20 class Directory; | 20 class Directory; |
| 21 } // namespace syncable | 21 } // namespace syncable |
| 22 | 22 |
| 23 class CommitContributor; | 23 class CommitContributor; |
| 24 class DirectoryCommitContributor; | 24 class DirectoryCommitContributor; |
| 25 class DirectoryUpdateHandler; | 25 class DirectoryUpdateHandler; |
| 26 class DirectoryTypeDebugInfoEmitter; |
| 26 class NonBlockingTypeProcessorCore; | 27 class NonBlockingTypeProcessorCore; |
| 27 class NonBlockingTypeProcessor; | 28 class NonBlockingTypeProcessor; |
| 28 class UpdateHandler; | 29 class UpdateHandler; |
| 29 | 30 |
| 30 typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap; | 31 typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap; |
| 31 typedef std::map<ModelType, CommitContributor*> CommitContributorMap; | 32 typedef std::map<ModelType, CommitContributor*> CommitContributorMap; |
| 33 typedef std::map<ModelType, DirectoryTypeDebugInfoEmitter*> |
| 34 DirectoryTypeDebugInfoEmitterMap; |
| 32 | 35 |
| 33 // Keeps track of the sets of active update handlers and commit contributors. | 36 // Keeps track of the sets of active update handlers and commit contributors. |
| 34 class SYNC_EXPORT_PRIVATE ModelTypeRegistry { | 37 class SYNC_EXPORT_PRIVATE ModelTypeRegistry { |
| 35 public: | 38 public: |
| 36 // This alternative constructor does not support any directory types. | 39 // This alternative constructor does not support any directory types. |
| 37 // It is used only in tests. | 40 // It is used only in tests. |
| 38 ModelTypeRegistry(); | 41 ModelTypeRegistry(); |
| 39 | 42 |
| 40 // Constructs a ModelTypeRegistry that supports directory types. | 43 // Constructs a ModelTypeRegistry that supports directory types. |
| 41 ModelTypeRegistry( | 44 ModelTypeRegistry( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 // Expects that the type is currently enabled. | 63 // Expects that the type is currently enabled. |
| 61 // Deletes the processor core associated with the type. | 64 // Deletes the processor core associated with the type. |
| 62 void RemoveNonBlockingType(syncer::ModelType type); | 65 void RemoveNonBlockingType(syncer::ModelType type); |
| 63 | 66 |
| 64 // Gets the set of enabled types. | 67 // Gets the set of enabled types. |
| 65 ModelTypeSet GetEnabledTypes() const; | 68 ModelTypeSet GetEnabledTypes() const; |
| 66 | 69 |
| 67 // Simple getters. | 70 // Simple getters. |
| 68 UpdateHandlerMap* update_handler_map(); | 71 UpdateHandlerMap* update_handler_map(); |
| 69 CommitContributorMap* commit_contributor_map(); | 72 CommitContributorMap* commit_contributor_map(); |
| 73 DirectoryTypeDebugInfoEmitterMap* directory_type_debug_info_emitter_map(); |
| 70 | 74 |
| 71 private: | 75 private: |
| 72 ModelTypeSet GetEnabledNonBlockingTypes() const; | 76 ModelTypeSet GetEnabledNonBlockingTypes() const; |
| 73 ModelTypeSet GetEnabledDirectoryTypes() const; | 77 ModelTypeSet GetEnabledDirectoryTypes() const; |
| 74 | 78 |
| 75 // Sets of handlers and contributors. | 79 // Sets of handlers and contributors. |
| 76 ScopedVector<DirectoryCommitContributor> directory_commit_contributors_; | 80 ScopedVector<DirectoryCommitContributor> directory_commit_contributors_; |
| 77 ScopedVector<DirectoryUpdateHandler> directory_update_handlers_; | 81 ScopedVector<DirectoryUpdateHandler> directory_update_handlers_; |
| 82 ScopedVector<DirectoryTypeDebugInfoEmitter> |
| 83 directory_type_debug_info_emitters_; |
| 84 |
| 78 ScopedVector<NonBlockingTypeProcessorCore> non_blocking_type_processor_cores_; | 85 ScopedVector<NonBlockingTypeProcessorCore> non_blocking_type_processor_cores_; |
| 79 | 86 |
| 80 // Maps of UpdateHandlers and CommitContributors. | 87 // Maps of UpdateHandlers and CommitContributors. |
| 81 // They do not own any of the objects they point to. | 88 // They do not own any of the objects they point to. |
| 82 UpdateHandlerMap update_handler_map_; | 89 UpdateHandlerMap update_handler_map_; |
| 83 CommitContributorMap commit_contributor_map_; | 90 CommitContributorMap commit_contributor_map_; |
| 84 | 91 |
| 92 // Map of DebugInfoEmitters for directory types. |
| 93 // Non-blocking types handle debug info differently. |
| 94 // Does not own its contents. |
| 95 DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_; |
| 96 |
| 85 // The known ModelSafeWorkers. | 97 // The known ModelSafeWorkers. |
| 86 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_; | 98 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_; |
| 87 | 99 |
| 88 // The directory. Not owned. | 100 // The directory. Not owned. |
| 89 syncable::Directory* directory_; | 101 syncable::Directory* directory_; |
| 90 | 102 |
| 91 // The set of enabled directory types. | 103 // The set of enabled directory types. |
| 92 ModelTypeSet enabled_directory_types_; | 104 ModelTypeSet enabled_directory_types_; |
| 93 | 105 |
| 94 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry); | 106 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry); |
| 95 }; | 107 }; |
| 96 | 108 |
| 97 } // namespace syncer | 109 } // namespace syncer |
| 98 | 110 |
| 99 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ | 111 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ |
| 100 | 112 |
| OLD | NEW |