| OLD | NEW |
| 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 #include "chrome/browser/sync/glue/sync_backend_host_core.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host_core.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/browser/sync/glue/device_info.h" | 9 #include "chrome/browser/sync/glue/device_info.h" |
| 10 #include "chrome/browser/sync/glue/invalidation_adapter.h" | 10 #include "chrome/browser/sync/glue/invalidation_adapter.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 void SyncBackendHostCore::OnInitializationComplete( | 145 void SyncBackendHostCore::OnInitializationComplete( |
| 146 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 146 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
| 147 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 147 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 148 debug_info_listener, | 148 debug_info_listener, |
| 149 bool success, | 149 bool success, |
| 150 const syncer::ModelTypeSet restored_types) { | 150 const syncer::ModelTypeSet restored_types) { |
| 151 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 151 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 152 | 152 |
| 153 if (!success) { | 153 if (!success) { |
| 154 DoDestroySyncManager(); | 154 DoDestroySyncManager(syncer::STOP_SYNC); |
| 155 host_.Call(FROM_HERE, | 155 host_.Call(FROM_HERE, |
| 156 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop); | 156 &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 // Register for encryption related changes now. We have to do this before | 160 // Register for encryption related changes now. We have to do this before |
| 161 // the initializing downloading control types or initializing the encryption | 161 // the initializing downloading control types or initializing the encryption |
| 162 // handler in order to receive notifications triggered during encryption | 162 // handler in order to receive notifications triggered during encryption |
| 163 // startup. | 163 // startup. |
| 164 sync_manager_->GetEncryptionHandler()->AddObserver(this); | 164 sync_manager_->GetEncryptionHandler()->AddObserver(this); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 | 559 |
| 560 // This will drop the HttpBridgeFactory's reference to the | 560 // This will drop the HttpBridgeFactory's reference to the |
| 561 // RequestContextGetter. Once this has been called, the HttpBridgeFactory can | 561 // RequestContextGetter. Once this has been called, the HttpBridgeFactory can |
| 562 // no longer be used to create new HttpBridge instances. We can get away with | 562 // no longer be used to create new HttpBridge instances. We can get away with |
| 563 // this because the stop_syncing_signal_ has already been signalled, which | 563 // this because the stop_syncing_signal_ has already been signalled, which |
| 564 // guarantees that the ServerConnectionManager will no longer attempt to | 564 // guarantees that the ServerConnectionManager will no longer attempt to |
| 565 // create new connections. | 565 // create new connections. |
| 566 release_request_context_signal_.Signal(); | 566 release_request_context_signal_.Signal(); |
| 567 } | 567 } |
| 568 | 568 |
| 569 void SyncBackendHostCore::DoShutdown(bool sync_disabled) { | 569 void SyncBackendHostCore::DoShutdown(syncer::ShutdownReason reason) { |
| 570 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 570 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 571 | 571 |
| 572 // It's safe to do this even if the type was never activated. | 572 // It's safe to do this even if the type was never activated. |
| 573 registrar_->DeactivateDataType(syncer::DEVICE_INFO); | 573 registrar_->DeactivateDataType(syncer::DEVICE_INFO); |
| 574 synced_device_tracker_.reset(); | 574 synced_device_tracker_.reset(); |
| 575 | 575 |
| 576 DoDestroySyncManager(); | 576 DoDestroySyncManager(reason); |
| 577 | 577 |
| 578 registrar_ = NULL; | 578 registrar_ = NULL; |
| 579 | 579 |
| 580 if (sync_disabled) | 580 if (reason == syncer::DISABLE_SYNC) |
| 581 DeleteSyncDataFolder(); | 581 DeleteSyncDataFolder(); |
| 582 | 582 |
| 583 host_.Reset(); | 583 host_.Reset(); |
| 584 weak_ptr_factory_.InvalidateWeakPtrs(); | 584 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 585 } | 585 } |
| 586 | 586 |
| 587 void SyncBackendHostCore::DoDestroySyncManager() { | 587 void SyncBackendHostCore::DoDestroySyncManager(syncer::ShutdownReason reason) { |
| 588 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 588 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 589 if (sync_manager_) { | 589 if (sync_manager_) { |
| 590 DisableDirectoryTypeDebugInfoForwarding(); | 590 DisableDirectoryTypeDebugInfoForwarding(); |
| 591 save_changes_timer_.reset(); | 591 save_changes_timer_.reset(); |
| 592 sync_manager_->RemoveObserver(this); | 592 sync_manager_->RemoveObserver(this); |
| 593 sync_manager_->ShutdownOnSyncThread(); | 593 sync_manager_->ShutdownOnSyncThread(reason); |
| 594 sync_manager_.reset(); | 594 sync_manager_.reset(); |
| 595 } | 595 } |
| 596 } | 596 } |
| 597 | 597 |
| 598 void SyncBackendHostCore::DoConfigureSyncer( | 598 void SyncBackendHostCore::DoConfigureSyncer( |
| 599 syncer::ConfigureReason reason, | 599 syncer::ConfigureReason reason, |
| 600 const DoConfigureSyncerTypes& config_types, | 600 const DoConfigureSyncerTypes& config_types, |
| 601 const syncer::ModelSafeRoutingInfo routing_info, | 601 const syncer::ModelSafeRoutingInfo routing_info, |
| 602 const base::Callback<void(syncer::ModelTypeSet, | 602 const base::Callback<void(syncer::ModelTypeSet, |
| 603 syncer::ModelTypeSet)>& ready_task, | 603 syncer::ModelTypeSet)>& ready_task, |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 this, &SyncBackendHostCore::SaveChanges); | 746 this, &SyncBackendHostCore::SaveChanges); |
| 747 } | 747 } |
| 748 | 748 |
| 749 void SyncBackendHostCore::SaveChanges() { | 749 void SyncBackendHostCore::SaveChanges() { |
| 750 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 750 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
| 751 sync_manager_->SaveChanges(); | 751 sync_manager_->SaveChanges(); |
| 752 } | 752 } |
| 753 | 753 |
| 754 } // namespace browser_sync | 754 } // namespace browser_sync |
| 755 | 755 |
| OLD | NEW |