Chromium Code Reviews| Index: chrome/browser/sync/glue/sync_backend_host.cc |
| diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc |
| index 295bb8c5f7ea6b4d89007e75e9ce6f0fe54bda97..89feb67aaa86b289d91680341a85160135a3ccfb 100644 |
| --- a/chrome/browser/sync/glue/sync_backend_host.cc |
| +++ b/chrome/browser/sync/glue/sync_backend_host.cc |
| @@ -846,6 +846,12 @@ void SyncBackendHost::Core::OnInitializationComplete( |
| bool success, |
| const syncer::ModelTypeSet restored_types) { |
| DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| + |
| + if (!success) { |
| + sync_manager_->RemoveObserver(this); |
| + sync_manager_.reset(); |
|
tim (not reviewing)
2012/07/31 19:40:26
The main danger with this is that SyncManager need
rlarocque
2012/07/31 20:14:07
Good idea. Done.
|
| + } |
| + |
| host_.Call( |
| FROM_HERE, |
| &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, |
| @@ -1051,19 +1057,22 @@ void SyncBackendHost::Core::DoRefreshNigori( |
| void SyncBackendHost::Core::DoStopSyncManagerForShutdown( |
| const base::Closure& closure) { |
| - DCHECK(sync_manager_.get()); |
| - sync_manager_->StopSyncingForShutdown(closure); |
| + if (sync_manager_.get()) { |
| + sync_manager_->StopSyncingForShutdown(closure); |
| + } else { |
| + sync_loop_->PostTask(FROM_HERE, closure); |
| + } |
| } |
| void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { |
| DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| - if (!sync_manager_.get()) |
| - return; |
| + if (sync_manager_.get()) { |
| + save_changes_timer_.reset(); |
| + sync_manager_->ShutdownOnSyncThread(); |
| + sync_manager_->RemoveObserver(this); |
| + sync_manager_.reset(); |
| + } |
| - save_changes_timer_.reset(); |
| - sync_manager_->ShutdownOnSyncThread(); |
| - sync_manager_->RemoveObserver(this); |
| - sync_manager_.reset(); |
| chrome_sync_notification_bridge_ = NULL; |
| registrar_ = NULL; |