| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 // This alternative constructor does not support any directory types. |
| 44 // It is used only in tests. | 45 // It is used only in tests. |
| 45 ModelTypeRegistry(); | 46 ModelTypeRegistry(); |
| 46 | 47 |
| 47 // Constructs a ModelTypeRegistry that supports directory types. | 48 // Constructs a ModelTypeRegistry that supports directory types. |
| 48 ModelTypeRegistry( | 49 ModelTypeRegistry(const std::vector<scoped_refptr<ModelSafeWorker> >& workers, |
| 49 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | 50 syncable::Directory* directory, |
| 50 syncable::Directory* directory); | 51 NudgeHandler* nudge_handler); |
| 51 virtual ~ModelTypeRegistry(); | 52 virtual ~ModelTypeRegistry(); |
| 52 | 53 |
| 53 // Sets the set of enabled types. | 54 // Sets the set of enabled types. |
| 54 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info); | 55 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info); |
| 55 | 56 |
| 56 // Enables an off-thread type for syncing. Connects the given proxy | 57 // Enables an off-thread type for syncing. Connects the given proxy |
| 57 // and its task_runner to the newly created worker. | 58 // and its task_runner to the newly created worker. |
| 58 // | 59 // |
| 59 // Expects that the proxy's ModelType is not currently enabled. | 60 // Expects that the proxy's ModelType is not currently enabled. |
| 60 virtual void ConnectSyncTypeToWorker( | 61 virtual void ConnectSyncTypeToWorker( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // Non-blocking types handle debug info differently. | 109 // Non-blocking types handle debug info differently. |
| 109 // Does not own its contents. | 110 // Does not own its contents. |
| 110 DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_; | 111 DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_; |
| 111 | 112 |
| 112 // The known ModelSafeWorkers. | 113 // The known ModelSafeWorkers. |
| 113 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_; | 114 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_map_; |
| 114 | 115 |
| 115 // The directory. Not owned. | 116 // The directory. Not owned. |
| 116 syncable::Directory* directory_; | 117 syncable::Directory* directory_; |
| 117 | 118 |
| 119 // The NudgeHandler. Not owned. |
| 120 NudgeHandler* nudge_handler_; |
| 121 |
| 118 // The set of enabled directory types. | 122 // The set of enabled directory types. |
| 119 ModelTypeSet enabled_directory_types_; | 123 ModelTypeSet enabled_directory_types_; |
| 120 | 124 |
| 121 // The set of observers of per-type debug info. | 125 // The set of observers of per-type debug info. |
| 122 // | 126 // |
| 123 // Each of the DirectoryTypeDebugInfoEmitters needs such a list. There's | 127 // Each of the DirectoryTypeDebugInfoEmitters needs such a list. There's |
| 124 // a lot of them, and their lifetimes are unpredictable, so it makes the | 128 // 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 | 129 // book-keeping easier if we just store the list here. That way it's |
| 126 // guaranteed to live as long as this sync backend. | 130 // guaranteed to live as long as this sync backend. |
| 127 ObserverList<TypeDebugInfoObserver> type_debug_info_observers_; | 131 ObserverList<TypeDebugInfoObserver> type_debug_info_observers_; |
| 128 | 132 |
| 129 base::WeakPtrFactory<ModelTypeRegistry> weak_ptr_factory_; | 133 base::WeakPtrFactory<ModelTypeRegistry> weak_ptr_factory_; |
| 130 | 134 |
| 131 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry); | 135 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry); |
| 132 }; | 136 }; |
| 133 | 137 |
| 134 } // namespace syncer | 138 } // namespace syncer |
| 135 | 139 |
| 136 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ | 140 #endif // SYNC_ENGINE_MODEL_TYPE_REGISTRY_H_ |
| OLD | NEW |