Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: components/sync/engine_impl/model_type_registry.h

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_SYNC_ENGINE_IMPL_MODEL_TYPE_REGISTRY_H_ 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_MODEL_TYPE_REGISTRY_H_
6 #define COMPONENTS_SYNC_ENGINE_IMPL_MODEL_TYPE_REGISTRY_H_ 6 #define COMPONENTS_SYNC_ENGINE_IMPL_MODEL_TYPE_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "components/sync/base/model_type.h" 16 #include "components/sync/base/model_type.h"
17 #include "components/sync/core/model_type_connector.h" 17 #include "components/sync/core/model_type_connector.h"
18 #include "components/sync/core/non_blocking_sync_common.h" 18 #include "components/sync/core/non_blocking_sync_common.h"
19 #include "components/sync/core/sync_encryption_handler.h" 19 #include "components/sync/core/sync_encryption_handler.h"
20 #include "components/sync/engine/cycle/type_debug_info_observer.h" 20 #include "components/sync/engine/cycle/type_debug_info_observer.h"
21 #include "components/sync/engine/model_safe_worker.h" 21 #include "components/sync/engine/model_safe_worker.h"
22 #include "components/sync/engine_impl/nudge_handler.h" 22 #include "components/sync/engine_impl/nudge_handler.h"
23 23
24 namespace syncer { 24 namespace syncer_v2 {
25 struct DataTypeState; 25 struct DataTypeState;
26 class ModelTypeProcessor; 26 class ModelTypeProcessor;
27 class ModelTypeWorker; 27 class ModelTypeWorker;
28 } 28 }
29 29
30 namespace syncer { 30 namespace syncer {
31 31
32 namespace syncable { 32 namespace syncable {
33 class Directory; 33 class Directory;
34 } // namespace syncable 34 } // namespace syncable
35 35
36 class CommitContributor; 36 class CommitContributor;
37 class DirectoryCommitContributor; 37 class DirectoryCommitContributor;
38 class DirectoryUpdateHandler; 38 class DirectoryUpdateHandler;
39 class DirectoryTypeDebugInfoEmitter; 39 class DirectoryTypeDebugInfoEmitter;
40 class UpdateHandler; 40 class UpdateHandler;
41 41
42 typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap; 42 typedef std::map<ModelType, UpdateHandler*> UpdateHandlerMap;
43 typedef std::map<ModelType, CommitContributor*> CommitContributorMap; 43 typedef std::map<ModelType, CommitContributor*> CommitContributorMap;
44 typedef std::map<ModelType, DirectoryTypeDebugInfoEmitter*> 44 typedef std::map<ModelType, DirectoryTypeDebugInfoEmitter*>
45 DirectoryTypeDebugInfoEmitterMap; 45 DirectoryTypeDebugInfoEmitterMap;
46 46
47 // Keeps track of the sets of active update handlers and commit contributors. 47 // Keeps track of the sets of active update handlers and commit contributors.
48 class ModelTypeRegistry : public ModelTypeConnector, 48 class ModelTypeRegistry : public syncer_v2::ModelTypeConnector,
49 public SyncEncryptionHandler::Observer { 49 public SyncEncryptionHandler::Observer {
50 public: 50 public:
51 // Constructs a ModelTypeRegistry that supports directory types. 51 // Constructs a ModelTypeRegistry that supports directory types.
52 ModelTypeRegistry(const std::vector<scoped_refptr<ModelSafeWorker>>& workers, 52 ModelTypeRegistry(const std::vector<scoped_refptr<ModelSafeWorker>>& workers,
53 syncable::Directory* directory, 53 syncable::Directory* directory,
54 NudgeHandler* nudge_handler); 54 NudgeHandler* nudge_handler);
55 ~ModelTypeRegistry() override; 55 ~ModelTypeRegistry() override;
56 56
57 // Sets the set of enabled types. 57 // Sets the set of enabled types.
58 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info); 58 void SetEnabledDirectoryTypes(const ModelSafeRoutingInfo& routing_info);
59 59
60 // Enables an off-thread type for syncing. Connects the given proxy 60 // Enables an off-thread type for syncing. Connects the given proxy
61 // and its task_runner to the newly created worker. 61 // and its task_runner to the newly created worker.
62 // 62 //
63 // Expects that the proxy's ModelType is not currently enabled. 63 // Expects that the proxy's ModelType is not currently enabled.
64 void ConnectType( 64 void ConnectType(syncer::ModelType type,
65 ModelType type, 65 std::unique_ptr<syncer_v2::ActivationContext>
66 std::unique_ptr<ActivationContext> activation_context) override; 66 activation_context) override;
67 67
68 // Disables the syncing of an off-thread type. 68 // Disables the syncing of an off-thread type.
69 // 69 //
70 // Expects that the type is currently enabled. 70 // Expects that the type is currently enabled.
71 // Deletes the worker associated with the type. 71 // Deletes the worker associated with the type.
72 void DisconnectType(ModelType type) override; 72 void DisconnectType(syncer::ModelType type) override;
73 73
74 // Implementation of SyncEncryptionHandler::Observer. 74 // Implementation of SyncEncryptionHandler::Observer.
75 void OnPassphraseRequired( 75 void OnPassphraseRequired(
76 PassphraseRequiredReason reason, 76 PassphraseRequiredReason reason,
77 const sync_pb::EncryptedData& pending_keys) override; 77 const sync_pb::EncryptedData& pending_keys) override;
78 void OnPassphraseAccepted() override; 78 void OnPassphraseAccepted() override;
79 void OnBootstrapTokenUpdated(const std::string& bootstrap_token, 79 void OnBootstrapTokenUpdated(const std::string& bootstrap_token,
80 BootstrapTokenType type) override; 80 BootstrapTokenType type) override;
81 void OnEncryptedTypesChanged(ModelTypeSet encrypted_types, 81 void OnEncryptedTypesChanged(ModelTypeSet encrypted_types,
82 bool encrypt_everything) override; 82 bool encrypt_everything) override;
83 void OnEncryptionComplete() override; 83 void OnEncryptionComplete() override;
84 void OnCryptographerStateChanged(Cryptographer* cryptographer) override; 84 void OnCryptographerStateChanged(Cryptographer* cryptographer) override;
85 void OnPassphraseTypeChanged(PassphraseType type, 85 void OnPassphraseTypeChanged(PassphraseType type,
86 base::Time passphrase_time) override; 86 base::Time passphrase_time) override;
87 void OnLocalSetPassphraseEncryption( 87 void OnLocalSetPassphraseEncryption(
88 const SyncEncryptionHandler::NigoriState& nigori_state) override; 88 const SyncEncryptionHandler::NigoriState& nigori_state) override;
89 89
90 // Gets the set of enabled types. 90 // Gets the set of enabled types.
91 ModelTypeSet GetEnabledTypes() const; 91 ModelTypeSet GetEnabledTypes() const;
92 92
93 // Returns set of types for which initial set of updates was downloaded and 93 // Returns set of types for which initial set of updates was downloaded and
94 // applied. 94 // applied.
95 ModelTypeSet GetInitialSyncEndedTypes() const; 95 ModelTypeSet GetInitialSyncEndedTypes() const;
96 96
97 // Simple getters. 97 // Simple getters.
98 UpdateHandlerMap* update_handler_map(); 98 UpdateHandlerMap* update_handler_map();
99 CommitContributorMap* commit_contributor_map(); 99 CommitContributorMap* commit_contributor_map();
100 DirectoryTypeDebugInfoEmitterMap* directory_type_debug_info_emitter_map(); 100 DirectoryTypeDebugInfoEmitterMap* directory_type_debug_info_emitter_map();
101 101
102 void RegisterDirectoryTypeDebugInfoObserver(TypeDebugInfoObserver* observer); 102 void RegisterDirectoryTypeDebugInfoObserver(
103 syncer::TypeDebugInfoObserver* observer);
103 void UnregisterDirectoryTypeDebugInfoObserver( 104 void UnregisterDirectoryTypeDebugInfoObserver(
104 TypeDebugInfoObserver* observer); 105 syncer::TypeDebugInfoObserver* observer);
105 bool HasDirectoryTypeDebugInfoObserver( 106 bool HasDirectoryTypeDebugInfoObserver(
106 const TypeDebugInfoObserver* observer) const; 107 const syncer::TypeDebugInfoObserver* observer) const;
107 void RequestEmitDebugInfo(); 108 void RequestEmitDebugInfo();
108 109
109 base::WeakPtr<ModelTypeConnector> AsWeakPtr(); 110 base::WeakPtr<ModelTypeConnector> AsWeakPtr();
110 111
111 private: 112 private:
112 void OnEncryptionStateChanged(); 113 void OnEncryptionStateChanged();
113 114
114 ModelTypeSet GetEnabledNonBlockingTypes() const; 115 ModelTypeSet GetEnabledNonBlockingTypes() const;
115 ModelTypeSet GetEnabledDirectoryTypes() const; 116 ModelTypeSet GetEnabledDirectoryTypes() const;
116 117
117 // Sets of handlers and contributors. 118 // Sets of handlers and contributors.
118 ScopedVector<DirectoryCommitContributor> directory_commit_contributors_; 119 ScopedVector<DirectoryCommitContributor> directory_commit_contributors_;
119 ScopedVector<DirectoryUpdateHandler> directory_update_handlers_; 120 ScopedVector<DirectoryUpdateHandler> directory_update_handlers_;
120 ScopedVector<DirectoryTypeDebugInfoEmitter> 121 ScopedVector<DirectoryTypeDebugInfoEmitter>
121 directory_type_debug_info_emitters_; 122 directory_type_debug_info_emitters_;
122 123
123 ScopedVector<ModelTypeWorker> model_type_workers_; 124 ScopedVector<syncer_v2::ModelTypeWorker> model_type_workers_;
124 125
125 // Maps of UpdateHandlers and CommitContributors. 126 // Maps of UpdateHandlers and CommitContributors.
126 // They do not own any of the objects they point to. 127 // They do not own any of the objects they point to.
127 UpdateHandlerMap update_handler_map_; 128 UpdateHandlerMap update_handler_map_;
128 CommitContributorMap commit_contributor_map_; 129 CommitContributorMap commit_contributor_map_;
129 130
130 // Map of DebugInfoEmitters for directory types. 131 // Map of DebugInfoEmitters for directory types.
131 // Non-blocking types handle debug info differently. 132 // Non-blocking types handle debug info differently.
132 // Does not own its contents. 133 // Does not own its contents.
133 DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_; 134 DirectoryTypeDebugInfoEmitterMap directory_type_debug_info_emitter_map_;
(...skipping 25 matching lines...) Expand all
159 base::ObserverList<TypeDebugInfoObserver> type_debug_info_observers_; 160 base::ObserverList<TypeDebugInfoObserver> type_debug_info_observers_;
160 161
161 base::WeakPtrFactory<ModelTypeRegistry> weak_ptr_factory_; 162 base::WeakPtrFactory<ModelTypeRegistry> weak_ptr_factory_;
162 163
163 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry); 164 DISALLOW_COPY_AND_ASSIGN(ModelTypeRegistry);
164 }; 165 };
165 166
166 } // namespace syncer 167 } // namespace syncer
167 168
168 #endif // COMPONENTS_SYNC_ENGINE_IMPL_MODEL_TYPE_REGISTRY_H_ 169 #endif // COMPONENTS_SYNC_ENGINE_IMPL_MODEL_TYPE_REGISTRY_H_
OLDNEW
« no previous file with comments | « components/sync/engine_impl/get_updates_processor_unittest.cc ('k') | components/sync/engine_impl/model_type_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698