| 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 "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "sync/base/sync_export.h" | 14 #include "sync/base/sync_export.h" |
| 15 #include "sync/engine/nudge_handler.h" |
| 15 #include "sync/internal_api/public/base/model_type.h" | 16 #include "sync/internal_api/public/base/model_type.h" |
| 16 #include "sync/internal_api/public/engine/model_safe_worker.h" | 17 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 17 #include "sync/internal_api/public/sessions/type_debug_info_observer.h" | 18 #include "sync/internal_api/public/sessions/type_debug_info_observer.h" |
| 18 #include "sync/internal_api/public/sync_context.h" | 19 #include "sync/internal_api/public/sync_context.h" |
| 19 | 20 |
| 20 namespace syncer { | 21 namespace syncer { |
| 21 | 22 |
| 22 namespace syncable { | 23 namespace syncable { |
| 23 class Directory; | 24 class Directory; |
| 24 } // namespace syncable | 25 } // namespace syncable |
| 25 | 26 |
| 26 class CommitContributor; | 27 class CommitContributor; |
| 27 class DirectoryCommitContributor; | 28 class DirectoryCommitContributor; |
| 28 class DirectoryUpdateHandler; | 29 class DirectoryUpdateHandler; |
| 29 class DirectoryTypeDebugInfoEmitter; | 30 class DirectoryTypeDebugInfoEmitter; |
| 30 class ModelTypeSyncWorkerImpl; | 31 class ModelTypeSyncWorkerImpl; |
| 31 class ModelTypeSyncProxyImpl; | 32 class ModelTypeSyncProxyImpl; |
| 32 class UpdateHandler; | 33 class UpdateHandler; |
| 33 struct DataTypeState; | 34 struct DataTypeState; |
| 34 | 35 |
| 35 typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap; | 36 typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap; |
| 36 typedef std::map<ModelType, CommitContributor*> CommitContributorMap; | 37 typedef std::map<ModelType, CommitContributor*> CommitContributorMap; |
| 37 typedef std::map<ModelType, DirectoryTypeDebugInfoEmitter*> | 38 typedef std::map<ModelType, DirectoryTypeDebugInfoEmitter*> |
| 38 DirectoryTypeDebugInfoEmitterMap; | 39 DirectoryTypeDebugInfoEmitterMap; |
| 39 | 40 |
| 40 // Keeps track of the sets of active update handlers and commit contributors. | 41 // Keeps track of the sets of active update handlers and commit contributors. |
| 41 class SYNC_EXPORT_PRIVATE ModelTypeRegistry : public SyncContext { | 42 class SYNC_EXPORT_PRIVATE ModelTypeRegistry : public SyncContext { |
| 42 public: | 43 public: |
| 43 // This alternative constructor does not support any directory types. | |
| 44 // It is used only in tests. | |
| 45 ModelTypeRegistry(); | |
| 46 | |
| 47 // Constructs a ModelTypeRegistry that supports directory types. | 44 // Constructs a ModelTypeRegistry that supports directory types. |
| 48 ModelTypeRegistry( | 45 ModelTypeRegistry(const std::vector<scoped_refptr<ModelSafeWorker> >& workers, |
| 49 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | 46 syncable::Directory* directory, |
| 50 syncable::Directory* directory); | 47 NudgeHandler* nudge_handler); |
| 51 virtual ~ModelTypeRegistry(); | 48 virtual ~ModelTypeRegistry(); |
| 52 | 49 |
| 53 // Sets the set of enabled types. | 50 // Sets the set of enabled types. |
| 54 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info); | 51 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info); |
| 55 | 52 |
| 56 // Enables an off-thread type for syncing. Connects the given proxy | 53 // Enables an off-thread type for syncing. Connects the given proxy |
| 57 // and its task_runner to the newly created worker. | 54 // and its task_runner to the newly created worker. |
| 58 // | 55 // |
| 59 // Expects that the proxy's ModelType is not currently enabled. | 56 // Expects that the proxy's ModelType is not currently enabled. |
| 60 virtual void ConnectSyncTypeToWorker( | 57 virtual void ConnectSyncTypeToWorker( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // Non-blocking types handle debug info differently. | 105 // Non-blocking types handle debug info differently. |
| 109 // Does not own its contents. | 106 // Does not own its contents. |
| 110 DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_; | 107 DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_; |
| 111 | 108 |
| 112 // The known ModelSafeWorkers. | 109 // The known ModelSafeWorkers. |
| 113 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_; | 110 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_; |
| 114 | 111 |
| 115 // The directory. Not owned. | 112 // The directory. Not owned. |
| 116 syncable::Directory* directory_; | 113 syncable::Directory* directory_; |
| 117 | 114 |
| 115 // The NudgeHandler. Not owned. |
| 116 NudgeHandler* nudge_handler_; |
| 117 |
| 118 // The set of enabled directory types. | 118 // The set of enabled directory types. |
| 119 ModelTypeSet enabled_directory_types_; | 119 ModelTypeSet enabled_directory_types_; |
| 120 | 120 |
| 121 // The set of observers of per-type debug info. | 121 // The set of observers of per-type debug info. |
| 122 // | 122 // |
| 123 // Each of the DirectoryTypeDebugInfoEmitters needs such a list. There's | 123 // Each of the DirectoryTypeDebugInfoEmitters needs such a list. There's |
| 124 // a lot of them, and their lifetimes are unpredictable, so it makes the | 124 // a lot of them, and their lifetimes are unpredictable, so it makes the |
| 125 // book-keeping easier if we just store the list here. That way it's | 125 // book-keeping easier if we just store the list here. That way it's |
| 126 // guaranteed to live as long as this sync backend. | 126 // guaranteed to live as long as this sync backend. |
| 127 ObserverList<TypeDebugInfoObserver> type_debug_info_observers_; | 127 ObserverList<TypeDebugInfoObserver> type_debug_info_observers_; |
| 128 | 128 |
| 129 base::WeakPtrFactory<ModelTypeRegistry> weak_ptr_factory_; | 129 base::WeakPtrFactory<ModelTypeRegistry> weak_ptr_factory_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry); | 131 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace syncer | 134 } // namespace syncer |
| 135 | 135 |
| 136 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ | 136 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ |
| OLD | NEW |