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