| Index: chrome/browser/sync/glue/sync_backend_host.h
|
| diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
|
| index 02352f40117409cea0d6b3dde617b5b9dfa6771a..3de9a815e3107922dd621f994fd19dcc7155ef51 100644
|
| --- a/chrome/browser/sync/glue/sync_backend_host.h
|
| +++ b/chrome/browser/sync/glue/sync_backend_host.h
|
| @@ -25,6 +25,7 @@
|
| #include "sync/internal_api/public/engine/model_safe_worker.h"
|
| #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
|
| #include "sync/internal_api/public/sync_manager.h"
|
| +#include "sync/internal_api/public/sync_manager_factory.h"
|
| #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
|
| #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
|
| #include "sync/internal_api/public/util/weak_handle.h"
|
| @@ -170,6 +171,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| syncer::ModelTypeSet initial_types,
|
| const syncer::SyncCredentials& credentials,
|
| bool delete_sync_data_folder,
|
| + syncer::SyncManagerFactory* sync_manager_factory,
|
| syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
|
| syncer::ReportUnrecoverableErrorFunction
|
| report_unrecoverable_error_function);
|
| @@ -225,12 +227,8 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| syncer::ModelTypeSet types_to_add,
|
| syncer::ModelTypeSet types_to_remove,
|
| NigoriState nigori_state,
|
| - base::Callback<void(syncer::ModelTypeSet)> ready_task,
|
| - base::Callback<void()> retry_callback) OVERRIDE;
|
| -
|
| - // Makes an asynchronous call to syncer to switch to config mode. When done
|
| - // syncer will call us back on FinishConfigureDataTypes.
|
| - virtual void StartConfiguration(const base::Closure& callback);
|
| + const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
|
| + const base::Callback<void()>& retry_callback) OVERRIDE;
|
|
|
| // Turns on encryption of all present and future sync data.
|
| virtual void EnableEncryptEverything();
|
| @@ -280,7 +278,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| // TODO(akalin): Figure out a better way for tests to hook into
|
| // SyncBackendHost.
|
|
|
| - typedef base::Callback<syncer::HttpPostProviderFactory*(void)>
|
| + typedef base::Callback<scoped_ptr<syncer::HttpPostProviderFactory>(void)>
|
| MakeHttpBridgeFactoryFn;
|
|
|
| struct DoInitializeOptions {
|
| @@ -296,6 +294,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| const syncer::SyncCredentials& credentials,
|
| ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
|
| syncer::SyncNotifierFactory* sync_notifier_factory,
|
| + syncer::SyncManagerFactory* sync_manager_factory,
|
| bool delete_sync_data_folder,
|
| const std::string& restored_key_for_bootstrapping,
|
| syncer::SyncManager::TestingMode testing_mode,
|
| @@ -316,6 +315,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| syncer::SyncCredentials credentials;
|
| ChromeSyncNotificationBridge* const chrome_sync_notification_bridge;
|
| syncer::SyncNotifierFactory* const sync_notifier_factory;
|
| + syncer::SyncManagerFactory* const sync_manager_factory;
|
| std::string lsid;
|
| bool delete_sync_data_folder;
|
| std::string restored_key_for_bootstrapping;
|
| @@ -325,19 +325,31 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| report_unrecoverable_error_function;
|
| };
|
|
|
| + // Allow derived classes to start the sync thread early.
|
| + // Returns true on success, false otherwise. If the thread was already
|
| + // running, does nothing and returns true.
|
| + bool StartSyncThread();
|
| +
|
| + // Getter for derived classes. May be NULL if the thread is not running.
|
| + MessageLoop* sync_loop() const { return sync_thread_.message_loop(); }
|
| +
|
| // Allows tests to perform alternate core initialization work.
|
| virtual void InitCore(const DoInitializeOptions& options);
|
|
|
| - // Called from Core::OnSyncCycleCompleted to handle updating frontend
|
| - // thread components.
|
| - void HandleSyncCycleCompletedOnFrontendLoop(
|
| - const syncer::sessions::SyncSessionSnapshot& snapshot);
|
| -
|
| - // Called to finish the job of ConfigureDataTypes once the syncer is in
|
| - // configuration mode.
|
| - void FinishConfigureDataTypesOnFrontendLoop();
|
| + // Request the syncer to reconfigure with the specfied params.
|
| + // Virtual for testing.
|
| + virtual void RequestConfigureSyncer(
|
| + syncer::ConfigureReason reason,
|
| + syncer::ModelTypeSet types_to_config,
|
| + const syncer::ModelSafeRoutingInfo& routing_info,
|
| + const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
|
| + const base::Closure& retry_callback);
|
|
|
| - bool IsDownloadingNigoriForTest() const;
|
| + // Called when the syncer has finished performing a configuration.
|
| + void FinishConfigureDataTypesOnFrontendLoop(
|
| + const syncer::ModelTypeSet types_to_configure,
|
| + const syncer::ModelTypeSet configured_types,
|
| + const base::Callback<void(syncer::ModelTypeSet)>& ready_task);
|
|
|
| private:
|
| // The real guts of SyncBackendHost, to keep the public client API clean.
|
| @@ -351,6 +363,8 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| // has been created.
|
| NOT_INITIALIZED, // Initialization hasn't completed, but we've
|
| // constructed a SyncManager.
|
| + CLEANING_NIGORI, // A partially downloaded nigori was found. We
|
| + // perform a configuration cycle to blow it away.
|
| DOWNLOADING_NIGORI, // The SyncManager is initialized, but
|
| // we're fetching encryption information.
|
| REFRESHING_NIGORI, // The SyncManager is initialized, and we
|
| @@ -360,31 +374,12 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| INITIALIZED, // Initialization is complete.
|
| };
|
|
|
| - struct PendingConfigureDataTypesState {
|
| - PendingConfigureDataTypesState();
|
| - ~PendingConfigureDataTypesState();
|
| -
|
| - // The ready_task will be run when configuration is done with the
|
| - // set of all types that failed configuration (i.e., if its
|
| - // argument is non-empty, then an error was encountered).
|
| - base::Callback<void(syncer::ModelTypeSet)> ready_task;
|
| -
|
| - // The retry callback will be run when the download failed due to a
|
| - // transient error. This is to notify DTM so it can apropriately inform
|
| - // the UI. Note: The retry_callback will be run only once and after
|
| - // that we will not notify DTM until the sync is successful or in a
|
| - // permanent error state.
|
| - base::Callback<void()> retry_callback;
|
| -
|
| - // The set of types that we are waiting to be initially synced in a
|
| - // configuration cycle.
|
| - syncer::ModelTypeSet types_to_add;
|
| -
|
| - // Additional details about which types were added.
|
| - syncer::ModelTypeSet added_types;
|
| - syncer::ConfigureReason reason;
|
| - bool retry_in_progress;
|
| - };
|
| + // InitializationComplete passes through the SyncBackendHost to forward
|
| + // on to |frontend_|, and so that tests can intercept here if they need to
|
| + // set up initial conditions.
|
| + void HandleInitializationCompletedOnFrontendLoop(
|
| + const syncer::WeakHandle<syncer::JsBackend>& js_backend,
|
| + bool success);
|
|
|
| // Checks if we have received a notice to turn on experimental datatypes
|
| // (via the nigori node) and informs the frontend if that is the case.
|
| @@ -392,14 +387,17 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| void AddExperimentalTypes();
|
|
|
| // Downloading of nigori failed and will be retried.
|
| - virtual void OnNigoriDownloadRetry();
|
| + void OnNigoriDownloadRetry();
|
|
|
| - // InitializationComplete passes through the SyncBackendHost to forward
|
| - // on to |frontend_|, and so that tests can intercept here if they need to
|
| - // set up initial conditions.
|
| - virtual void HandleInitializationCompletedOnFrontendLoop(
|
| - const syncer::WeakHandle<syncer::JsBackend>& js_backend,
|
| - bool success);
|
| + // Called from Core::OnSyncCycleCompleted to handle updating frontend
|
| + // thread components.
|
| + void HandleSyncCycleCompletedOnFrontendLoop(
|
| + const syncer::sessions::SyncSessionSnapshot& snapshot);
|
| +
|
| + // Called when the syncer failed to perform a configuration and will
|
| + // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called
|
| + // on successful completion.
|
| + void RetryConfigurationOnFrontendLoop(const base::Closure& retry_callback);
|
|
|
| // Helpers to persist a token that can be used to bootstrap sync encryption
|
| // across browser restart to avoid requiring the user to re-enter their
|
| @@ -500,9 +498,6 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
|
| // The frontend which we serve (and are owned by).
|
| SyncFrontend* frontend_;
|
|
|
| - scoped_ptr<PendingConfigureDataTypesState> pending_download_state_;
|
| - scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_;
|
| -
|
| // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired
|
| // is called. This way, before the UI calls SetDecryptionPassphrase on the
|
| // syncer, it can avoid the overhead of an asynchronous decryption call and
|
|
|