OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 290 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
291 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 291 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
292 const GURL& service_url, | 292 const GURL& service_url, |
293 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, | 293 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, |
294 const syncer::SyncCredentials& credentials, | 294 const syncer::SyncCredentials& credentials, |
295 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, | 295 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, |
296 syncer::SyncNotifierFactory* sync_notifier_factory, | 296 syncer::SyncNotifierFactory* sync_notifier_factory, |
297 syncer::SyncManagerFactory* sync_manager_factory, | 297 syncer::SyncManagerFactory* sync_manager_factory, |
298 bool delete_sync_data_folder, | 298 bool delete_sync_data_folder, |
299 const std::string& restored_key_for_bootstrapping, | 299 const std::string& restored_key_for_bootstrapping, |
| 300 const std::string& restored_keystore_key_for_bootstrapping, |
300 syncer::InternalComponentsFactory* internal_components_factory, | 301 syncer::InternalComponentsFactory* internal_components_factory, |
301 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, | 302 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, |
302 syncer::ReportUnrecoverableErrorFunction | 303 syncer::ReportUnrecoverableErrorFunction |
303 report_unrecoverable_error_function); | 304 report_unrecoverable_error_function); |
304 ~DoInitializeOptions(); | 305 ~DoInitializeOptions(); |
305 | 306 |
306 MessageLoop* sync_loop; | 307 MessageLoop* sync_loop; |
307 SyncBackendRegistrar* registrar; | 308 SyncBackendRegistrar* registrar; |
308 syncer::ModelSafeRoutingInfo routing_info; | 309 syncer::ModelSafeRoutingInfo routing_info; |
309 std::vector<syncer::ModelSafeWorker*> workers; | 310 std::vector<syncer::ModelSafeWorker*> workers; |
310 syncer::ExtensionsActivityMonitor* extensions_activity_monitor; | 311 syncer::ExtensionsActivityMonitor* extensions_activity_monitor; |
311 syncer::WeakHandle<syncer::JsEventHandler> event_handler; | 312 syncer::WeakHandle<syncer::JsEventHandler> event_handler; |
312 GURL service_url; | 313 GURL service_url; |
313 // Overridden by tests. | 314 // Overridden by tests. |
314 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; | 315 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn; |
315 syncer::SyncCredentials credentials; | 316 syncer::SyncCredentials credentials; |
316 ChromeSyncNotificationBridge* const chrome_sync_notification_bridge; | 317 ChromeSyncNotificationBridge* const chrome_sync_notification_bridge; |
317 syncer::SyncNotifierFactory* const sync_notifier_factory; | 318 syncer::SyncNotifierFactory* const sync_notifier_factory; |
318 syncer::SyncManagerFactory* const sync_manager_factory; | 319 syncer::SyncManagerFactory* const sync_manager_factory; |
319 std::string lsid; | 320 std::string lsid; |
320 bool delete_sync_data_folder; | 321 bool delete_sync_data_folder; |
321 std::string restored_key_for_bootstrapping; | 322 std::string restored_key_for_bootstrapping; |
| 323 std::string restored_keystore_key_for_bootstrapping; |
322 syncer::InternalComponentsFactory* internal_components_factory; | 324 syncer::InternalComponentsFactory* internal_components_factory; |
323 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler; | 325 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler; |
324 syncer::ReportUnrecoverableErrorFunction | 326 syncer::ReportUnrecoverableErrorFunction |
325 report_unrecoverable_error_function; | 327 report_unrecoverable_error_function; |
326 }; | 328 }; |
327 | 329 |
328 // Allows tests to perform alternate core initialization work. | 330 // Allows tests to perform alternate core initialization work. |
329 virtual void InitCore(const DoInitializeOptions& options); | 331 virtual void InitCore(const DoInitializeOptions& options); |
330 | 332 |
331 // Request the syncer to reconfigure with the specfied params. | 333 // Request the syncer to reconfigure with the specfied params. |
(...skipping 29 matching lines...) Expand all Loading... |
361 // constructed a SyncManager. | 363 // constructed a SyncManager. |
362 DOWNLOADING_NIGORI, // The SyncManager is initialized, but | 364 DOWNLOADING_NIGORI, // The SyncManager is initialized, but |
363 // we're fetching encryption information. | 365 // we're fetching encryption information. |
364 REFRESHING_NIGORI, // The SyncManager is initialized, and we | 366 REFRESHING_NIGORI, // The SyncManager is initialized, and we |
365 // have the encryption information, but we | 367 // have the encryption information, but we |
366 // still need to refresh encryption. Also, we need | 368 // still need to refresh encryption. Also, we need |
367 // to update the device information in the nigori. | 369 // to update the device information in the nigori. |
368 INITIALIZED, // Initialization is complete. | 370 INITIALIZED, // Initialization is complete. |
369 }; | 371 }; |
370 | 372 |
| 373 // Enum used to distinguish which bootstrap encryption token is being updated. |
| 374 enum BootstrapTokenType { |
| 375 PASSPHRASE_BOOTSTRAP_TOKEN, |
| 376 KEYSTORE_BOOTSTRAP_TOKEN |
| 377 }; |
| 378 |
371 // Checks if we have received a notice to turn on experimental datatypes | 379 // Checks if we have received a notice to turn on experimental datatypes |
372 // (via the nigori node) and informs the frontend if that is the case. | 380 // (via the nigori node) and informs the frontend if that is the case. |
373 // Note: it is illegal to call this before the backend is initialized. | 381 // Note: it is illegal to call this before the backend is initialized. |
374 void AddExperimentalTypes(); | 382 void AddExperimentalTypes(); |
375 | 383 |
376 // Downloading of nigori failed and will be retried. | 384 // Downloading of nigori failed and will be retried. |
377 void OnNigoriDownloadRetry(); | 385 void OnNigoriDownloadRetry(); |
378 | 386 |
379 // InitializationComplete passes through the SyncBackendHost to forward | 387 // InitializationComplete passes through the SyncBackendHost to forward |
380 // on to |frontend_|, and so that tests can intercept here if they need to | 388 // on to |frontend_|, and so that tests can intercept here if they need to |
381 // set up initial conditions. | 389 // set up initial conditions. |
382 void HandleInitializationCompletedOnFrontendLoop( | 390 void HandleInitializationCompletedOnFrontendLoop( |
383 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 391 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
384 bool success); | 392 bool success); |
385 | 393 |
386 // Called from Core::OnSyncCycleCompleted to handle updating frontend | 394 // Called from Core::OnSyncCycleCompleted to handle updating frontend |
387 // thread components. | 395 // thread components. |
388 void HandleSyncCycleCompletedOnFrontendLoop( | 396 void HandleSyncCycleCompletedOnFrontendLoop( |
389 const syncer::sessions::SyncSessionSnapshot& snapshot); | 397 const syncer::sessions::SyncSessionSnapshot& snapshot); |
390 | 398 |
391 // Called when the syncer failed to perform a configuration and will | 399 // Called when the syncer failed to perform a configuration and will |
392 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called | 400 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called |
393 // on successful completion. | 401 // on successful completion. |
394 void RetryConfigurationOnFrontendLoop(const base::Closure& retry_callback); | 402 void RetryConfigurationOnFrontendLoop(const base::Closure& retry_callback); |
395 | 403 |
396 // Helpers to persist a token that can be used to bootstrap sync encryption | 404 // Helpers to persist a token that can be used to bootstrap sync encryption |
397 // across browser restart to avoid requiring the user to re-enter their | 405 // across browser restart to avoid requiring the user to re-enter their |
398 // passphrase. |token| must be valid UTF-8 as we use the PrefService for | 406 // passphrase. |token| must be valid UTF-8 as we use the PrefService for |
399 // storage. | 407 // storage. |
400 void PersistEncryptionBootstrapToken(const std::string& token); | 408 void PersistEncryptionBootstrapToken( |
| 409 const std::string& token, |
| 410 BootstrapTokenType token_type); |
401 | 411 |
402 // For convenience, checks if initialization state is INITIALIZED. | 412 // For convenience, checks if initialization state is INITIALIZED. |
403 bool initialized() const { return initialization_state_ == INITIALIZED; } | 413 bool initialized() const { return initialization_state_ == INITIALIZED; } |
404 | 414 |
405 // Let the front end handle the actionable error event. | 415 // Let the front end handle the actionable error event. |
406 void HandleActionableErrorEventOnFrontendLoop( | 416 void HandleActionableErrorEventOnFrontendLoop( |
407 const syncer::SyncProtocolError& sync_error); | 417 const syncer::SyncProtocolError& sync_error); |
408 | 418 |
409 // Checks if |passphrase| can be used to decrypt the cryptographer's pending | 419 // Checks if |passphrase| can be used to decrypt the cryptographer's pending |
410 // keys that were cached during NotifyPassphraseRequired. Returns true if | 420 // keys that were cached during NotifyPassphraseRequired. Returns true if |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 514 |
505 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. | 515 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. |
506 syncer::sessions::SyncSessionSnapshot last_snapshot_; | 516 syncer::sessions::SyncSessionSnapshot last_snapshot_; |
507 | 517 |
508 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 518 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
509 }; | 519 }; |
510 | 520 |
511 } // namespace browser_sync | 521 } // namespace browser_sync |
512 | 522 |
513 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 523 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
OLD | NEW |