| 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 "components/sync/driver/glue/sync_backend_host_core.h" | 5 #include "components/sync/driver/glue/sync_backend_host_core.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/trace_event/memory_dump_manager.h" |
| 14 #include "components/data_use_measurement/core/data_use_user_data.h" | 15 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 15 #include "components/invalidation/public/invalidation_util.h" | 16 #include "components/invalidation/public/invalidation_util.h" |
| 16 #include "components/invalidation/public/object_id_invalidation_map.h" | 17 #include "components/invalidation/public/object_id_invalidation_map.h" |
| 17 #include "components/sync/core/http_post_provider_factory.h" | 18 #include "components/sync/core/http_post_provider_factory.h" |
| 18 #include "components/sync/core/internal_components_factory.h" | 19 #include "components/sync/core/internal_components_factory.h" |
| 19 #include "components/sync/core/sync_manager.h" | 20 #include "components/sync/core/sync_manager.h" |
| 20 #include "components/sync/core/sync_manager_factory.h" | 21 #include "components/sync/core/sync_manager_factory.h" |
| 21 #include "components/sync/device_info/local_device_info_provider_impl.h" | 22 #include "components/sync/device_info/local_device_info_provider_impl.h" |
| 22 #include "components/sync/driver/glue/sync_backend_registrar.h" | 23 #include "components/sync/driver/glue/sync_backend_registrar.h" |
| 23 #include "components/sync/driver/invalidation_adapter.h" | 24 #include "components/sync/driver/invalidation_adapter.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 forward_protocol_events_(false), | 124 forward_protocol_events_(false), |
| 124 forward_type_info_(false), | 125 forward_type_info_(false), |
| 125 weak_ptr_factory_(this) { | 126 weak_ptr_factory_(this) { |
| 126 DCHECK(backend.get()); | 127 DCHECK(backend.get()); |
| 127 } | 128 } |
| 128 | 129 |
| 129 SyncBackendHostCore::~SyncBackendHostCore() { | 130 SyncBackendHostCore::~SyncBackendHostCore() { |
| 130 DCHECK(!sync_manager_.get()); | 131 DCHECK(!sync_manager_.get()); |
| 131 } | 132 } |
| 132 | 133 |
| 134 bool SyncBackendHostCore::OnMemoryDump( |
| 135 const base::trace_event::MemoryDumpArgs& args, |
| 136 base::trace_event::ProcessMemoryDump* pmd) { |
| 137 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 138 if (!sync_manager_) |
| 139 return false; |
| 140 sync_manager_->OnMemoryDump(pmd); |
| 141 return true; |
| 142 } |
| 143 |
| 133 void SyncBackendHostCore::OnSyncCycleCompleted( | 144 void SyncBackendHostCore::OnSyncCycleCompleted( |
| 134 const syncer::SyncCycleSnapshot& snapshot) { | 145 const syncer::SyncCycleSnapshot& snapshot) { |
| 135 if (!sync_loop_) | 146 if (!sync_loop_) |
| 136 return; | 147 return; |
| 137 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 148 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 138 | 149 |
| 139 host_.Call(FROM_HERE, | 150 host_.Call(FROM_HERE, |
| 140 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop, | 151 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop, |
| 141 snapshot); | 152 snapshot); |
| 142 } | 153 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 options->restored_keystore_key_for_bootstrapping; | 440 options->restored_keystore_key_for_bootstrapping; |
| 430 args.internal_components_factory = | 441 args.internal_components_factory = |
| 431 std::move(options->internal_components_factory); | 442 std::move(options->internal_components_factory); |
| 432 args.encryptor = &encryptor_; | 443 args.encryptor = &encryptor_; |
| 433 args.unrecoverable_error_handler = options->unrecoverable_error_handler; | 444 args.unrecoverable_error_handler = options->unrecoverable_error_handler; |
| 434 args.report_unrecoverable_error_function = | 445 args.report_unrecoverable_error_function = |
| 435 options->report_unrecoverable_error_function; | 446 options->report_unrecoverable_error_function; |
| 436 args.cancelation_signal = &stop_syncing_signal_; | 447 args.cancelation_signal = &stop_syncing_signal_; |
| 437 args.saved_nigori_state = std::move(options->saved_nigori_state); | 448 args.saved_nigori_state = std::move(options->saved_nigori_state); |
| 438 sync_manager_->Init(&args); | 449 sync_manager_->Init(&args); |
| 450 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 451 this, "SyncDirectory", sync_loop_->task_runner()); |
| 439 } | 452 } |
| 440 | 453 |
| 441 void SyncBackendHostCore::DoUpdateCredentials( | 454 void SyncBackendHostCore::DoUpdateCredentials( |
| 442 const syncer::SyncCredentials& credentials) { | 455 const syncer::SyncCredentials& credentials) { |
| 443 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 456 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 444 // UpdateCredentials can be called during backend initialization, possibly | 457 // UpdateCredentials can be called during backend initialization, possibly |
| 445 // when backend initialization has failed but hasn't notified the UI thread | 458 // when backend initialization has failed but hasn't notified the UI thread |
| 446 // yet. In that case, the sync manager may have been destroyed on the sync | 459 // yet. In that case, the sync manager may have been destroyed on the sync |
| 447 // thread before this task was executed, so we do nothing. | 460 // thread before this task was executed, so we do nothing. |
| 448 if (sync_manager_) { | 461 if (sync_manager_) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 555 |
| 543 if (reason == syncer::DISABLE_SYNC) | 556 if (reason == syncer::DISABLE_SYNC) |
| 544 DeleteSyncDataFolder(); | 557 DeleteSyncDataFolder(); |
| 545 | 558 |
| 546 host_.Reset(); | 559 host_.Reset(); |
| 547 weak_ptr_factory_.InvalidateWeakPtrs(); | 560 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 548 } | 561 } |
| 549 | 562 |
| 550 void SyncBackendHostCore::DoDestroySyncManager(syncer::ShutdownReason reason) { | 563 void SyncBackendHostCore::DoDestroySyncManager(syncer::ShutdownReason reason) { |
| 551 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 564 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 565 |
| 566 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 567 this); |
| 552 if (sync_manager_) { | 568 if (sync_manager_) { |
| 553 DisableDirectoryTypeDebugInfoForwarding(); | 569 DisableDirectoryTypeDebugInfoForwarding(); |
| 554 save_changes_timer_.reset(); | 570 save_changes_timer_.reset(); |
| 555 sync_manager_->RemoveObserver(this); | 571 sync_manager_->RemoveObserver(this); |
| 556 sync_manager_->ShutdownOnSyncThread(reason); | 572 sync_manager_->ShutdownOnSyncThread(reason); |
| 557 sync_manager_.reset(); | 573 sync_manager_.reset(); |
| 558 } | 574 } |
| 559 } | 575 } |
| 560 | 576 |
| 561 void SyncBackendHostCore::DoConfigureSyncer( | 577 void SyncBackendHostCore::DoConfigureSyncer( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 } | 711 } |
| 696 | 712 |
| 697 void SyncBackendHostCore::ClearServerDataDone( | 713 void SyncBackendHostCore::ClearServerDataDone( |
| 698 const base::Closure& frontend_callback) { | 714 const base::Closure& frontend_callback) { |
| 699 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 715 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 700 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, | 716 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, |
| 701 frontend_callback); | 717 frontend_callback); |
| 702 } | 718 } |
| 703 | 719 |
| 704 } // namespace browser_sync | 720 } // namespace browser_sync |
| OLD | NEW |