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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_impl.h

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 18 matching lines...) Expand all
29 #include "components/sync/driver/glue/sync_backend_host.h" 29 #include "components/sync/driver/glue/sync_backend_host.h"
30 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 30 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
31 #include "components/sync/engine/cycle/type_debug_info_observer.h" 31 #include "components/sync/engine/cycle/type_debug_info_observer.h"
32 #include "components/sync/protocol/encryption.pb.h" 32 #include "components/sync/protocol/encryption.pb.h"
33 #include "components/sync/protocol/sync_protocol_error.h" 33 #include "components/sync/protocol/sync_protocol_error.h"
34 34
35 class GURL; 35 class GURL;
36 36
37 namespace base { 37 namespace base {
38 class MessageLoop; 38 class MessageLoop;
39 } 39 } // base
40 40
41 namespace invalidation { 41 namespace invalidation {
42 class InvalidationService; 42 class InvalidationService;
43 } 43 } // namespace invalidation
44 44
45 namespace syncer { 45 namespace syncer {
46 class SyncManagerFactory;
47 class UnrecoverableErrorHandler;
48 }
49
50 namespace sync_driver {
51 class SyncClient;
52 class SyncPrefs;
53 }
54
55 namespace browser_sync {
56 46
57 class ChangeProcessor; 47 class ChangeProcessor;
58 class SyncBackendHostCore; 48 class SyncBackendHostCore;
59 class SyncBackendRegistrar; 49 class SyncBackendRegistrar;
50 class SyncClient;
51 class SyncManagerFactory;
52 class SyncPrefs;
53 class UnrecoverableErrorHandler;
60 struct DoInitializeOptions; 54 struct DoInitializeOptions;
61 55
62 // The only real implementation of the SyncBackendHost. See that interface's 56 // The only real implementation of the SyncBackendHost. See that interface's
63 // definition for documentation of public methods. 57 // definition for documentation of public methods.
64 class SyncBackendHostImpl : public SyncBackendHost, 58 class SyncBackendHostImpl : public SyncBackendHost, public InvalidationHandler {
65 public syncer::InvalidationHandler {
66 public: 59 public:
67 typedef syncer::SyncStatus Status; 60 typedef SyncStatus Status;
68 61
69 // Create a SyncBackendHost with a reference to the |frontend| that 62 // Create a SyncBackendHost with a reference to the |frontend| that
70 // it serves and communicates to via the SyncFrontend interface (on 63 // it serves and communicates to via the SyncFrontend interface (on
71 // the same thread it used to call the constructor). Must outlive 64 // the same thread it used to call the constructor). Must outlive
72 // |sync_prefs|. 65 // |sync_prefs|.
73 SyncBackendHostImpl( 66 SyncBackendHostImpl(
74 const std::string& name, 67 const std::string& name,
75 sync_driver::SyncClient* sync_client, 68 SyncClient* sync_client,
76 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, 69 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
77 invalidation::InvalidationService* invalidator, 70 invalidation::InvalidationService* invalidator,
78 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, 71 const base::WeakPtr<SyncPrefs>& sync_prefs,
79 const base::FilePath& sync_folder); 72 const base::FilePath& sync_folder);
80 ~SyncBackendHostImpl() override; 73 ~SyncBackendHostImpl() override;
81 74
82 // SyncBackendHost implementation. 75 // SyncBackendHost implementation.
83 void Initialize( 76 void Initialize(
84 sync_driver::SyncFrontend* frontend, 77 SyncFrontend* frontend,
85 std::unique_ptr<base::Thread> sync_thread, 78 std::unique_ptr<base::Thread> sync_thread,
86 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, 79 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
87 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, 80 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
88 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 81 const WeakHandle<JsEventHandler>& event_handler,
89 const GURL& service_url, 82 const GURL& service_url,
90 const std::string& sync_user_agent, 83 const std::string& sync_user_agent,
91 const syncer::SyncCredentials& credentials, 84 const SyncCredentials& credentials,
92 bool delete_sync_data_folder, 85 bool delete_sync_data_folder,
93 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, 86 std::unique_ptr<SyncManagerFactory> sync_manager_factory,
94 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& 87 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler,
95 unrecoverable_error_handler,
96 const base::Closure& report_unrecoverable_error_function, 88 const base::Closure& report_unrecoverable_error_function,
97 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, 89 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
98 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> 90 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state)
99 saved_nigori_state) override; 91 override;
100 void TriggerRefresh(const syncer::ModelTypeSet& types) override; 92 void TriggerRefresh(const ModelTypeSet& types) override;
101 void UpdateCredentials(const syncer::SyncCredentials& credentials) override; 93 void UpdateCredentials(const SyncCredentials& credentials) override;
102 void StartSyncingWithServer() override; 94 void StartSyncingWithServer() override;
103 void SetEncryptionPassphrase(const std::string& passphrase, 95 void SetEncryptionPassphrase(const std::string& passphrase,
104 bool is_explicit) override; 96 bool is_explicit) override;
105 bool SetDecryptionPassphrase(const std::string& passphrase) override 97 bool SetDecryptionPassphrase(const std::string& passphrase) override
106 WARN_UNUSED_RESULT; 98 WARN_UNUSED_RESULT;
107 void StopSyncingForShutdown() override; 99 void StopSyncingForShutdown() override;
108 std::unique_ptr<base::Thread> Shutdown( 100 std::unique_ptr<base::Thread> Shutdown(ShutdownReason reason) override;
109 syncer::ShutdownReason reason) override;
110 void UnregisterInvalidationIds() override; 101 void UnregisterInvalidationIds() override;
111 syncer::ModelTypeSet ConfigureDataTypes( 102 ModelTypeSet ConfigureDataTypes(
112 syncer::ConfigureReason reason, 103 ConfigureReason reason,
113 const DataTypeConfigStateMap& config_state_map, 104 const DataTypeConfigStateMap& config_state_map,
114 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& 105 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task,
115 ready_task,
116 const base::Callback<void()>& retry_callback) override; 106 const base::Callback<void()>& retry_callback) override;
117 void ActivateDirectoryDataType( 107 void ActivateDirectoryDataType(ModelType type,
118 syncer::ModelType type, 108 ModelSafeGroup group,
119 syncer::ModelSafeGroup group, 109 ChangeProcessor* change_processor) override;
120 sync_driver::ChangeProcessor* change_processor) override; 110 void DeactivateDirectoryDataType(ModelType type) override;
121 void DeactivateDirectoryDataType(syncer::ModelType type) override; 111 void ActivateNonBlockingDataType(ModelType type,
122 void ActivateNonBlockingDataType( 112 std::unique_ptr<ActivationContext>) override;
123 syncer::ModelType type, 113 void DeactivateNonBlockingDataType(ModelType type) override;
124 std::unique_ptr<syncer_v2::ActivationContext>) override;
125 void DeactivateNonBlockingDataType(syncer::ModelType type) override;
126 void EnableEncryptEverything() override; 114 void EnableEncryptEverything() override;
127 syncer::UserShare* GetUserShare() const override; 115 UserShare* GetUserShare() const override;
128 Status GetDetailedStatus() override; 116 Status GetDetailedStatus() override;
129 syncer::SyncCycleSnapshot GetLastCycleSnapshot() const override; 117 SyncCycleSnapshot GetLastCycleSnapshot() const override;
130 bool HasUnsyncedItems() const override; 118 bool HasUnsyncedItems() const override;
131 bool IsNigoriEnabled() const override; 119 bool IsNigoriEnabled() const override;
132 syncer::PassphraseType GetPassphraseType() const override; 120 PassphraseType GetPassphraseType() const override;
133 base::Time GetExplicitPassphraseTime() const override; 121 base::Time GetExplicitPassphraseTime() const override;
134 bool IsCryptographerReady( 122 bool IsCryptographerReady(const BaseTransaction* trans) const override;
135 const syncer::BaseTransaction* trans) const override; 123 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const override;
136 void GetModelSafeRoutingInfo(
137 syncer::ModelSafeRoutingInfo* out) const override;
138 void FlushDirectory() const override; 124 void FlushDirectory() const override;
139 void RequestBufferedProtocolEventsAndEnableForwarding() override; 125 void RequestBufferedProtocolEventsAndEnableForwarding() override;
140 void DisableProtocolEventForwarding() override; 126 void DisableProtocolEventForwarding() override;
141 void EnableDirectoryTypeDebugInfoForwarding() override; 127 void EnableDirectoryTypeDebugInfoForwarding() override;
142 void DisableDirectoryTypeDebugInfoForwarding() override; 128 void DisableDirectoryTypeDebugInfoForwarding() override;
143 base::MessageLoop* GetSyncLoopForTesting() override; 129 base::MessageLoop* GetSyncLoopForTesting() override;
144 void RefreshTypesForTest(syncer::ModelTypeSet types) override; 130 void RefreshTypesForTest(ModelTypeSet types) override;
145 void ClearServerData( 131 void ClearServerData(
146 const syncer::SyncManager::ClearServerDataCallback& callback) override; 132 const SyncManager::ClearServerDataCallback& callback) override;
147 void OnCookieJarChanged(bool account_mismatch, bool empty_jar) override; 133 void OnCookieJarChanged(bool account_mismatch, bool empty_jar) override;
148 134
149 // InvalidationHandler implementation. 135 // InvalidationHandler implementation.
150 void OnInvalidatorStateChange(syncer::InvalidatorState state) override; 136 void OnInvalidatorStateChange(InvalidatorState state) override;
151 void OnIncomingInvalidation( 137 void OnIncomingInvalidation(
152 const syncer::ObjectIdInvalidationMap& invalidation_map) override; 138 const ObjectIdInvalidationMap& invalidation_map) override;
153 std::string GetOwnerName() const override; 139 std::string GetOwnerName() const override;
154 140
155 protected: 141 protected:
156 // The types and functions below are protected so that test 142 // The types and functions below are protected so that test
157 // subclasses can use them. 143 // subclasses can use them.
158 144
159 // Allows tests to perform alternate core initialization work. 145 // Allows tests to perform alternate core initialization work.
160 virtual void InitCore(std::unique_ptr<DoInitializeOptions> options); 146 virtual void InitCore(std::unique_ptr<DoInitializeOptions> options);
161 147
162 // Request the syncer to reconfigure with the specfied params. 148 // Request the syncer to reconfigure with the specfied params.
163 // Virtual for testing. 149 // Virtual for testing.
164 virtual void RequestConfigureSyncer( 150 virtual void RequestConfigureSyncer(
165 syncer::ConfigureReason reason, 151 ConfigureReason reason,
166 syncer::ModelTypeSet to_download, 152 ModelTypeSet to_download,
167 syncer::ModelTypeSet to_purge, 153 ModelTypeSet to_purge,
168 syncer::ModelTypeSet to_journal, 154 ModelTypeSet to_journal,
169 syncer::ModelTypeSet to_unapply, 155 ModelTypeSet to_unapply,
170 syncer::ModelTypeSet to_ignore, 156 ModelTypeSet to_ignore,
171 const syncer::ModelSafeRoutingInfo& routing_info, 157 const ModelSafeRoutingInfo& routing_info,
172 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& 158 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task,
173 ready_task,
174 const base::Closure& retry_callback); 159 const base::Closure& retry_callback);
175 160
176 // Called when the syncer has finished performing a configuration. 161 // Called when the syncer has finished performing a configuration.
177 void FinishConfigureDataTypesOnFrontendLoop( 162 void FinishConfigureDataTypesOnFrontendLoop(
178 const syncer::ModelTypeSet enabled_types, 163 const ModelTypeSet enabled_types,
179 const syncer::ModelTypeSet succeeded_configuration_types, 164 const ModelTypeSet succeeded_configuration_types,
180 const syncer::ModelTypeSet failed_configuration_types, 165 const ModelTypeSet failed_configuration_types,
181 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& 166 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task);
182 ready_task);
183 167
184 // Reports backend initialization success. Includes some objects from sync 168 // Reports backend initialization success. Includes some objects from sync
185 // manager initialization to be passed back to the UI thread. 169 // manager initialization to be passed back to the UI thread.
186 // 170 //
187 // |model_type_connector| is our ModelTypeConnector, which is owned because in 171 // |model_type_connector| is our ModelTypeConnector, which is owned because in
188 // production it is a proxy object to the real ModelTypeConnector. 172 // production it is a proxy object to the real ModelTypeConnector.
189 virtual void HandleInitializationSuccessOnFrontendLoop( 173 virtual void HandleInitializationSuccessOnFrontendLoop(
190 const syncer::WeakHandle<syncer::JsBackend> js_backend, 174 const WeakHandle<JsBackend> js_backend,
191 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> 175 const WeakHandle<DataTypeDebugInfoListener> debug_info_listener,
192 debug_info_listener, 176 std::unique_ptr<ModelTypeConnector> model_type_connector,
193 std::unique_ptr<syncer_v2::ModelTypeConnector> model_type_connector,
194 const std::string& cache_guid); 177 const std::string& cache_guid);
195 178
196 // Forwards a ProtocolEvent to the frontend. Will not be called unless a 179 // Forwards a ProtocolEvent to the frontend. Will not be called unless a
197 // call to SetForwardProtocolEvents() explicitly requested that we start 180 // call to SetForwardProtocolEvents() explicitly requested that we start
198 // forwarding these events. 181 // forwarding these events.
199 void HandleProtocolEventOnFrontendLoop( 182 void HandleProtocolEventOnFrontendLoop(std::unique_ptr<ProtocolEvent> event);
200 std::unique_ptr<syncer::ProtocolEvent> event);
201 183
202 // Forwards a directory commit counter update to the frontend loop. Will not 184 // Forwards a directory commit counter update to the frontend loop. Will not
203 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding() 185 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding()
204 // explicitly requested that we start forwarding these events. 186 // explicitly requested that we start forwarding these events.
205 void HandleDirectoryCommitCountersUpdatedOnFrontendLoop( 187 void HandleDirectoryCommitCountersUpdatedOnFrontendLoop(
206 syncer::ModelType type, 188 ModelType type,
207 const syncer::CommitCounters& counters); 189 const CommitCounters& counters);
208 190
209 // Forwards a directory update counter update to the frontend loop. Will not 191 // Forwards a directory update counter update to the frontend loop. Will not
210 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding() 192 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding()
211 // explicitly requested that we start forwarding these events. 193 // explicitly requested that we start forwarding these events.
212 void HandleDirectoryUpdateCountersUpdatedOnFrontendLoop( 194 void HandleDirectoryUpdateCountersUpdatedOnFrontendLoop(
213 syncer::ModelType type, 195 ModelType type,
214 const syncer::UpdateCounters& counters); 196 const UpdateCounters& counters);
215 197
216 // Forwards a directory status counter update to the frontend loop. Will not 198 // Forwards a directory status counter update to the frontend loop. Will not
217 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding() 199 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding()
218 // explicitly requested that we start forwarding these events. 200 // explicitly requested that we start forwarding these events.
219 void HandleDirectoryStatusCountersUpdatedOnFrontendLoop( 201 void HandleDirectoryStatusCountersUpdatedOnFrontendLoop(
220 syncer::ModelType type, 202 ModelType type,
221 const syncer::StatusCounters& counters); 203 const StatusCounters& counters);
222 204
223 // Overwrites the kSyncInvalidationVersions preference with the most recent 205 // Overwrites the kSyncInvalidationVersions preference with the most recent
224 // set of invalidation versions for each type. 206 // set of invalidation versions for each type.
225 void UpdateInvalidationVersions( 207 void UpdateInvalidationVersions(
226 const std::map<syncer::ModelType, int64_t>& invalidation_versions); 208 const std::map<ModelType, int64_t>& invalidation_versions);
227 209
228 sync_driver::SyncFrontend* frontend() { return frontend_; } 210 SyncFrontend* frontend() { return frontend_; }
229 211
230 private: 212 private:
231 friend class SyncBackendHostCore; 213 friend class SyncBackendHostCore;
232 214
233 // Checks if we have received a notice to turn on experimental datatypes 215 // Checks if we have received a notice to turn on experimental datatypes
234 // (via the nigori node) and informs the frontend if that is the case. 216 // (via the nigori node) and informs the frontend if that is the case.
235 // Note: it is illegal to call this before the backend is initialized. 217 // Note: it is illegal to call this before the backend is initialized.
236 void AddExperimentalTypes(); 218 void AddExperimentalTypes();
237 219
238 // Handles backend initialization failure. 220 // Handles backend initialization failure.
239 void HandleInitializationFailureOnFrontendLoop(); 221 void HandleInitializationFailureOnFrontendLoop();
240 222
241 // Called from Core::OnSyncCycleCompleted to handle updating frontend 223 // Called from Core::OnSyncCycleCompleted to handle updating frontend
242 // thread components. 224 // thread components.
243 void HandleSyncCycleCompletedOnFrontendLoop( 225 void HandleSyncCycleCompletedOnFrontendLoop(
244 const syncer::SyncCycleSnapshot& snapshot); 226 const SyncCycleSnapshot& snapshot);
245 227
246 // Called when the syncer failed to perform a configuration and will 228 // Called when the syncer failed to perform a configuration and will
247 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called 229 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called
248 // on successful completion. 230 // on successful completion.
249 void RetryConfigurationOnFrontendLoop(const base::Closure& retry_callback); 231 void RetryConfigurationOnFrontendLoop(const base::Closure& retry_callback);
250 232
251 // Helpers to persist a token that can be used to bootstrap sync encryption 233 // Helpers to persist a token that can be used to bootstrap sync encryption
252 // across browser restart to avoid requiring the user to re-enter their 234 // across browser restart to avoid requiring the user to re-enter their
253 // passphrase. |token| must be valid UTF-8 as we use the PrefService for 235 // passphrase. |token| must be valid UTF-8 as we use the PrefService for
254 // storage. 236 // storage.
255 void PersistEncryptionBootstrapToken(const std::string& token, 237 void PersistEncryptionBootstrapToken(const std::string& token,
256 syncer::BootstrapTokenType token_type); 238 BootstrapTokenType token_type);
257 239
258 // For convenience, checks if initialization state is INITIALIZED. 240 // For convenience, checks if initialization state is INITIALIZED.
259 bool initialized() const { return initialized_; } 241 bool initialized() const { return initialized_; }
260 242
261 // Let the front end handle the actionable error event. 243 // Let the front end handle the actionable error event.
262 void HandleActionableErrorEventOnFrontendLoop( 244 void HandleActionableErrorEventOnFrontendLoop(
263 const syncer::SyncProtocolError& sync_error); 245 const SyncProtocolError& sync_error);
264 246
265 // Handle a migration request. 247 // Handle a migration request.
266 void HandleMigrationRequestedOnFrontendLoop(const syncer::ModelTypeSet types); 248 void HandleMigrationRequestedOnFrontendLoop(const ModelTypeSet types);
267 249
268 // Checks if |passphrase| can be used to decrypt the cryptographer's pending 250 // Checks if |passphrase| can be used to decrypt the cryptographer's pending
269 // keys that were cached during NotifyPassphraseRequired. Returns true if 251 // keys that were cached during NotifyPassphraseRequired. Returns true if
270 // decryption was successful. Returns false otherwise. Must be called with a 252 // decryption was successful. Returns false otherwise. Must be called with a
271 // non-empty pending keys cache. 253 // non-empty pending keys cache.
272 bool CheckPassphraseAgainstCachedPendingKeys( 254 bool CheckPassphraseAgainstCachedPendingKeys(
273 const std::string& passphrase) const; 255 const std::string& passphrase) const;
274 256
275 // Invoked when a passphrase is required to decrypt a set of Nigori keys, 257 // Invoked when a passphrase is required to decrypt a set of Nigori keys,
276 // or for encrypting. |reason| denotes why the passphrase was required. 258 // or for encrypting. |reason| denotes why the passphrase was required.
277 // |pending_keys| is a copy of the cryptographer's pending keys, that are 259 // |pending_keys| is a copy of the cryptographer's pending keys, that are
278 // cached by the frontend. If there are no pending keys, or if the passphrase 260 // cached by the frontend. If there are no pending keys, or if the passphrase
279 // required reason is REASON_ENCRYPTION, an empty EncryptedData object is 261 // required reason is REASON_ENCRYPTION, an empty EncryptedData object is
280 // passed. 262 // passed.
281 void NotifyPassphraseRequired(syncer::PassphraseRequiredReason reason, 263 void NotifyPassphraseRequired(PassphraseRequiredReason reason,
282 sync_pb::EncryptedData pending_keys); 264 sync_pb::EncryptedData pending_keys);
283 265
284 // Invoked when the passphrase provided by the user has been accepted. 266 // Invoked when the passphrase provided by the user has been accepted.
285 void NotifyPassphraseAccepted(); 267 void NotifyPassphraseAccepted();
286 268
287 // Invoked when the set of encrypted types or the encrypt 269 // Invoked when the set of encrypted types or the encrypt
288 // everything flag changes. 270 // everything flag changes.
289 void NotifyEncryptedTypesChanged(syncer::ModelTypeSet encrypted_types, 271 void NotifyEncryptedTypesChanged(ModelTypeSet encrypted_types,
290 bool encrypt_everything); 272 bool encrypt_everything);
291 273
292 // Invoked when sync finishes encrypting new datatypes. 274 // Invoked when sync finishes encrypting new datatypes.
293 void NotifyEncryptionComplete(); 275 void NotifyEncryptionComplete();
294 276
295 // Invoked when the passphrase state has changed. Caches the passphrase state 277 // Invoked when the passphrase state has changed. Caches the passphrase state
296 // for later use on the UI thread. 278 // for later use on the UI thread.
297 // If |type| is FROZEN_IMPLICIT_PASSPHRASE or CUSTOM_PASSPHRASE, 279 // If |type| is FROZEN_IMPLICIT_PASSPHRASE or CUSTOM_PASSPHRASE,
298 // |explicit_passphrase_time| is the time at which that passphrase was set 280 // |explicit_passphrase_time| is the time at which that passphrase was set
299 // (if available). 281 // (if available).
300 void HandlePassphraseTypeChangedOnFrontendLoop( 282 void HandlePassphraseTypeChangedOnFrontendLoop(
301 syncer::PassphraseType type, 283 PassphraseType type,
302 base::Time explicit_passphrase_time); 284 base::Time explicit_passphrase_time);
303 285
304 void HandleLocalSetPassphraseEncryptionOnFrontendLoop( 286 void HandleLocalSetPassphraseEncryptionOnFrontendLoop(
305 const syncer::SyncEncryptionHandler::NigoriState& nigori_state); 287 const SyncEncryptionHandler::NigoriState& nigori_state);
306 288
307 // Dispatched to from OnConnectionStatusChange to handle updating 289 // Dispatched to from OnConnectionStatusChange to handle updating
308 // frontend UI components. 290 // frontend UI components.
309 void HandleConnectionStatusChangeOnFrontendLoop( 291 void HandleConnectionStatusChangeOnFrontendLoop(ConnectionStatus status);
310 syncer::ConnectionStatus status);
311 292
312 void ClearServerDataDoneOnFrontendLoop( 293 void ClearServerDataDoneOnFrontendLoop(
313 const syncer::SyncManager::ClearServerDataCallback& frontend_callback); 294 const SyncManager::ClearServerDataCallback& frontend_callback);
314 295
315 // A reference to the TaskRUnner used to construct |this|, so we know how to 296 // A reference to the TaskRUnner used to construct |this|, so we know how to
316 // safely talk back to the SyncFrontend. 297 // safely talk back to the SyncFrontend.
317 scoped_refptr<base::SingleThreadTaskRunner> const frontend_task_runner_; 298 scoped_refptr<base::SingleThreadTaskRunner> const frontend_task_runner_;
318 299
319 sync_driver::SyncClient* const sync_client_; 300 SyncClient* const sync_client_;
320 301
321 // The UI thread's task runner. 302 // The UI thread's task runner.
322 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; 303 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_;
323 304
324 // Name used for debugging (set from profile_->GetDebugName()). 305 // Name used for debugging (set from profile_->GetDebugName()).
325 const std::string name_; 306 const std::string name_;
326 307
327 // Our core, which communicates directly to the syncapi. Use refptr instead 308 // Our core, which communicates directly to the syncapi. Use refptr instead
328 // of WeakHandle because |core_| is created on UI loop but released on 309 // of WeakHandle because |core_| is created on UI loop but released on
329 // sync loop. 310 // sync loop.
330 scoped_refptr<SyncBackendHostCore> core_; 311 scoped_refptr<SyncBackendHostCore> core_;
331 312
332 // A handle referencing the main interface for non-blocking sync types. This 313 // A handle referencing the main interface for non-blocking sync types. This
333 // object is owned because in production code it is a proxy object. 314 // object is owned because in production code it is a proxy object.
334 std::unique_ptr<syncer_v2::ModelTypeConnector> model_type_connector_; 315 std::unique_ptr<ModelTypeConnector> model_type_connector_;
335 316
336 bool initialized_; 317 bool initialized_;
337 318
338 const base::WeakPtr<sync_driver::SyncPrefs> sync_prefs_; 319 const base::WeakPtr<SyncPrefs> sync_prefs_;
339 320
340 std::unique_ptr<SyncBackendRegistrar> registrar_; 321 std::unique_ptr<SyncBackendRegistrar> registrar_;
341 322
342 // The frontend which we serve (and are owned by). 323 // The frontend which we serve (and are owned by).
343 sync_driver::SyncFrontend* frontend_; 324 SyncFrontend* frontend_;
344 325
345 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired 326 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired
346 // is called. This way, before the UI calls SetDecryptionPassphrase on the 327 // is called. This way, before the UI calls SetDecryptionPassphrase on the
347 // syncer, it can avoid the overhead of an asynchronous decryption call and 328 // syncer, it can avoid the overhead of an asynchronous decryption call and
348 // give the user immediate feedback about the passphrase entered by first 329 // give the user immediate feedback about the passphrase entered by first
349 // trying to decrypt the cached pending keys on the UI thread. Note that 330 // trying to decrypt the cached pending keys on the UI thread. Note that
350 // SetDecryptionPassphrase can still fail after the cached pending keys are 331 // SetDecryptionPassphrase can still fail after the cached pending keys are
351 // successfully decrypted if the pending keys have changed since the time they 332 // successfully decrypted if the pending keys have changed since the time they
352 // were cached. 333 // were cached.
353 sync_pb::EncryptedData cached_pending_keys_; 334 sync_pb::EncryptedData cached_pending_keys_;
354 335
355 // The state of the passphrase required to decrypt the bag of encryption keys 336 // The state of the passphrase required to decrypt the bag of encryption keys
356 // in the nigori node. Updated whenever a new nigori node arrives or the user 337 // in the nigori node. Updated whenever a new nigori node arrives or the user
357 // manually changes their passphrase state. Cached so we can synchronously 338 // manually changes their passphrase state. Cached so we can synchronously
358 // check it from the UI thread. 339 // check it from the UI thread.
359 syncer::PassphraseType cached_passphrase_type_; 340 PassphraseType cached_passphrase_type_;
360 341
361 // If an explicit passphrase is in use, the time at which the passphrase was 342 // If an explicit passphrase is in use, the time at which the passphrase was
362 // first set (if available). 343 // first set (if available).
363 base::Time cached_explicit_passphrase_time_; 344 base::Time cached_explicit_passphrase_time_;
364 345
365 // UI-thread cache of the last SyncCycleSnapshot received from syncapi. 346 // UI-thread cache of the last SyncCycleSnapshot received from syncapi.
366 syncer::SyncCycleSnapshot last_snapshot_; 347 SyncCycleSnapshot last_snapshot_;
367 348
368 invalidation::InvalidationService* invalidator_; 349 invalidation::InvalidationService* invalidator_;
369 bool invalidation_handler_registered_; 350 bool invalidation_handler_registered_;
370 351
371 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_; 352 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_;
372 353
373 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl); 354 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl);
374 }; 355 };
375 356
376 } // namespace browser_sync 357 } // namespace syncer
377 358
378 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 359 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_core.cc ('k') | components/sync/driver/glue/sync_backend_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698