| Index: trunk/src/chrome/browser/sync/glue/sync_backend_host.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/sync/glue/sync_backend_host.cc (revision 222204)
|
| +++ trunk/src/chrome/browser/sync/glue/sync_backend_host.cc (working copy)
|
| @@ -198,10 +198,11 @@
|
| void DoFinishInitialProcessControlTypes();
|
|
|
| // The shutdown order is a bit complicated:
|
| - // 1) Call the SyncManagerStopHandle's RequestStop() from |frontend_loop_| to
|
| - // request sync manager to stop as soon as possible.
|
| + // 1) Call DoStopSyncManagerForShutdown() from |frontend_loop_| to request
|
| + // sync manager to stop as soon as possible.
|
| // 2) Post DoShutdown() to sync loop to clean up backend state, save
|
| // directory and destroy sync manager.
|
| + void DoStopSyncManagerForShutdown();
|
| void DoShutdown(bool sync_disabled);
|
| void DoDestroySyncManager();
|
|
|
| @@ -400,8 +401,7 @@
|
| new InternalComponentsFactoryImpl(factory_switches)).Pass(),
|
| unrecoverable_error_handler.Pass(),
|
| report_unrecoverable_error_function,
|
| - !cl->HasSwitch(switches::kSyncDisableOAuth2Token),
|
| - &cancelation_signal_));
|
| + !cl->HasSwitch(switches::kSyncDisableOAuth2Token)));
|
| InitCore(init_opts.Pass());
|
| }
|
|
|
| @@ -492,9 +492,24 @@
|
| return true;
|
| }
|
|
|
| +void SyncBackendHost::StopSyncManagerForShutdown() {
|
| + DCHECK_GT(initialization_state_, NOT_ATTEMPTED);
|
| + if (initialization_state_ == CREATING_SYNC_MANAGER) {
|
| + // We post here to implicitly wait for the SyncManager to be created,
|
| + // if needed. We have to wait, since we need to shutdown immediately,
|
| + // and we need to tell the SyncManager so it can abort any activity
|
| + // (net I/O, data application).
|
| + DCHECK(registrar_->sync_thread()->IsRunning());
|
| + registrar_->sync_thread()->message_loop()->PostTask(FROM_HERE,
|
| + base::Bind(&SyncBackendHost::Core::DoStopSyncManagerForShutdown,
|
| + core_.get()));
|
| + } else {
|
| + core_->DoStopSyncManagerForShutdown();
|
| + }
|
| +}
|
| +
|
| void SyncBackendHost::StopSyncingForShutdown() {
|
| DCHECK_EQ(base::MessageLoop::current(), frontend_loop_);
|
| - DCHECK_GT(initialization_state_, NOT_ATTEMPTED);
|
|
|
| // Immediately stop sending messages to the frontend.
|
| frontend_ = NULL;
|
| @@ -506,7 +521,7 @@
|
|
|
| registrar_->RequestWorkerStopOnUIThread();
|
|
|
| - cancelation_signal_.RequestStop();
|
| + StopSyncManagerForShutdown();
|
| }
|
|
|
| scoped_ptr<base::Thread> SyncBackendHost::Shutdown(ShutdownOption option) {
|
| @@ -868,8 +883,7 @@
|
| scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler,
|
| syncer::ReportUnrecoverableErrorFunction
|
| report_unrecoverable_error_function,
|
| - bool use_oauth2_token,
|
| - syncer::CancelationSignal* const cancelation_signal)
|
| + bool use_oauth2_token)
|
| : sync_loop(sync_loop),
|
| registrar(registrar),
|
| routing_info(routing_info),
|
| @@ -889,8 +903,7 @@
|
| unrecoverable_error_handler(unrecoverable_error_handler.Pass()),
|
| report_unrecoverable_error_function(
|
| report_unrecoverable_error_function),
|
| - use_oauth2_token(use_oauth2_token),
|
| - cancelation_signal(cancelation_signal) {
|
| + use_oauth2_token(use_oauth2_token) {
|
| }
|
|
|
| SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {}
|
| @@ -1155,8 +1168,7 @@
|
| &encryptor_,
|
| options->unrecoverable_error_handler.Pass(),
|
| options->report_unrecoverable_error_function,
|
| - options->use_oauth2_token,
|
| - options->cancelation_signal);
|
| + options->use_oauth2_token);
|
|
|
| // |sync_manager_| may end up being NULL here in tests (in
|
| // synchronous initialization mode).
|
| @@ -1266,6 +1278,11 @@
|
| sync_manager_->GetEncryptionHandler()->EnableEncryptEverything();
|
| }
|
|
|
| +void SyncBackendHost::Core::DoStopSyncManagerForShutdown() {
|
| + if (sync_manager_)
|
| + sync_manager_->StopSyncingForShutdown();
|
| +}
|
| +
|
| void SyncBackendHost::Core::DoShutdown(bool sync_disabled) {
|
| DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
|
| // It's safe to do this even if the type was never activated.
|
|
|