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/base/invalidation_adapter.h" | 18 #include "components/sync/base/invalidation_adapter.h" |
18 #include "components/sync/device_info/local_device_info_provider_impl.h" | 19 #include "components/sync/device_info/local_device_info_provider_impl.h" |
19 #include "components/sync/driver/glue/sync_backend_registrar.h" | 20 #include "components/sync/driver/glue/sync_backend_registrar.h" |
20 #include "components/sync/engine/cycle/commit_counters.h" | 21 #include "components/sync/engine/cycle/commit_counters.h" |
21 #include "components/sync/engine/cycle/status_counters.h" | 22 #include "components/sync/engine/cycle/status_counters.h" |
22 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 23 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
23 #include "components/sync/engine/cycle/update_counters.h" | 24 #include "components/sync/engine/cycle/update_counters.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 forward_protocol_events_(false), | 122 forward_protocol_events_(false), |
122 forward_type_info_(false), | 123 forward_type_info_(false), |
123 weak_ptr_factory_(this) { | 124 weak_ptr_factory_(this) { |
124 DCHECK(backend.get()); | 125 DCHECK(backend.get()); |
125 } | 126 } |
126 | 127 |
127 SyncBackendHostCore::~SyncBackendHostCore() { | 128 SyncBackendHostCore::~SyncBackendHostCore() { |
128 DCHECK(!sync_manager_.get()); | 129 DCHECK(!sync_manager_.get()); |
129 } | 130 } |
130 | 131 |
| 132 bool SyncBackendHostCore::OnMemoryDump( |
| 133 const base::trace_event::MemoryDumpArgs& args, |
| 134 base::trace_event::ProcessMemoryDump* pmd) { |
| 135 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 136 if (!sync_manager_) |
| 137 return false; |
| 138 sync_manager_->OnMemoryDump(pmd); |
| 139 return true; |
| 140 } |
| 141 |
131 void SyncBackendHostCore::OnSyncCycleCompleted( | 142 void SyncBackendHostCore::OnSyncCycleCompleted( |
132 const SyncCycleSnapshot& snapshot) { | 143 const SyncCycleSnapshot& snapshot) { |
133 if (!sync_loop_) | 144 if (!sync_loop_) |
134 return; | 145 return; |
135 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 146 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
136 | 147 |
137 host_.Call(FROM_HERE, | 148 host_.Call(FROM_HERE, |
138 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop, | 149 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop, |
139 snapshot); | 150 snapshot); |
140 } | 151 } |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 options->restored_keystore_key_for_bootstrapping; | 435 options->restored_keystore_key_for_bootstrapping; |
425 args.engine_components_factory = | 436 args.engine_components_factory = |
426 std::move(options->engine_components_factory); | 437 std::move(options->engine_components_factory); |
427 args.encryptor = &encryptor_; | 438 args.encryptor = &encryptor_; |
428 args.unrecoverable_error_handler = options->unrecoverable_error_handler; | 439 args.unrecoverable_error_handler = options->unrecoverable_error_handler; |
429 args.report_unrecoverable_error_function = | 440 args.report_unrecoverable_error_function = |
430 options->report_unrecoverable_error_function; | 441 options->report_unrecoverable_error_function; |
431 args.cancelation_signal = &stop_syncing_signal_; | 442 args.cancelation_signal = &stop_syncing_signal_; |
432 args.saved_nigori_state = std::move(options->saved_nigori_state); | 443 args.saved_nigori_state = std::move(options->saved_nigori_state); |
433 sync_manager_->Init(&args); | 444 sync_manager_->Init(&args); |
| 445 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 446 this, "SyncDirectory", sync_loop_->task_runner()); |
434 } | 447 } |
435 | 448 |
436 void SyncBackendHostCore::DoUpdateCredentials( | 449 void SyncBackendHostCore::DoUpdateCredentials( |
437 const SyncCredentials& credentials) { | 450 const SyncCredentials& credentials) { |
438 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 451 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
439 // UpdateCredentials can be called during backend initialization, possibly | 452 // UpdateCredentials can be called during backend initialization, possibly |
440 // when backend initialization has failed but hasn't notified the UI thread | 453 // when backend initialization has failed but hasn't notified the UI thread |
441 // yet. In that case, the sync manager may have been destroyed on the sync | 454 // yet. In that case, the sync manager may have been destroyed on the sync |
442 // thread before this task was executed, so we do nothing. | 455 // thread before this task was executed, so we do nothing. |
443 if (sync_manager_) { | 456 if (sync_manager_) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 | 550 |
538 if (reason == DISABLE_SYNC) | 551 if (reason == DISABLE_SYNC) |
539 DeleteSyncDataFolder(); | 552 DeleteSyncDataFolder(); |
540 | 553 |
541 host_.Reset(); | 554 host_.Reset(); |
542 weak_ptr_factory_.InvalidateWeakPtrs(); | 555 weak_ptr_factory_.InvalidateWeakPtrs(); |
543 } | 556 } |
544 | 557 |
545 void SyncBackendHostCore::DoDestroySyncManager(ShutdownReason reason) { | 558 void SyncBackendHostCore::DoDestroySyncManager(ShutdownReason reason) { |
546 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 559 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
| 560 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 561 this); |
547 if (sync_manager_) { | 562 if (sync_manager_) { |
548 DisableDirectoryTypeDebugInfoForwarding(); | 563 DisableDirectoryTypeDebugInfoForwarding(); |
549 save_changes_timer_.reset(); | 564 save_changes_timer_.reset(); |
550 sync_manager_->RemoveObserver(this); | 565 sync_manager_->RemoveObserver(this); |
551 sync_manager_->ShutdownOnSyncThread(reason); | 566 sync_manager_->ShutdownOnSyncThread(reason); |
552 sync_manager_.reset(); | 567 sync_manager_.reset(); |
553 } | 568 } |
554 } | 569 } |
555 | 570 |
556 void SyncBackendHostCore::DoConfigureSyncer( | 571 void SyncBackendHostCore::DoConfigureSyncer( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 } | 703 } |
689 | 704 |
690 void SyncBackendHostCore::ClearServerDataDone( | 705 void SyncBackendHostCore::ClearServerDataDone( |
691 const base::Closure& frontend_callback) { | 706 const base::Closure& frontend_callback) { |
692 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 707 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
693 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, | 708 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, |
694 frontend_callback); | 709 frontend_callback); |
695 } | 710 } |
696 | 711 |
697 } // namespace syncer | 712 } // namespace syncer |
OLD | NEW |