Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: components/sync/driver/glue/sync_backend_host_core.cc

Issue 2452713003: [Sync] Implement MemoryDumpProvider. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 forward_protocol_events_(false), 118 forward_protocol_events_(false),
118 forward_type_info_(false), 119 forward_type_info_(false),
119 weak_ptr_factory_(this) { 120 weak_ptr_factory_(this) {
120 DCHECK(backend.get()); 121 DCHECK(backend.get());
121 } 122 }
122 123
123 SyncBackendHostCore::~SyncBackendHostCore() { 124 SyncBackendHostCore::~SyncBackendHostCore() {
124 DCHECK(!sync_manager_.get()); 125 DCHECK(!sync_manager_.get());
125 } 126 }
126 127
128 bool SyncBackendHostCore::OnMemoryDump(
129 const base::trace_event::MemoryDumpArgs& args,
130 base::trace_event::ProcessMemoryDump* pmd) {
131 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
132 if (!sync_manager_)
133 return false;
134 sync_manager_->OnMemoryDump(pmd);
135 return true;
136 }
137
127 void SyncBackendHostCore::OnSyncCycleCompleted( 138 void SyncBackendHostCore::OnSyncCycleCompleted(
128 const SyncCycleSnapshot& snapshot) { 139 const SyncCycleSnapshot& snapshot) {
129 if (!sync_loop_) 140 if (!sync_loop_)
130 return; 141 return;
131 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 142 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
132 143
133 host_.Call(FROM_HERE, 144 host_.Call(FROM_HERE,
134 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop, 145 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop,
135 snapshot); 146 snapshot);
136 } 147 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 options->restored_keystore_key_for_bootstrapping; 429 options->restored_keystore_key_for_bootstrapping;
419 args.engine_components_factory = 430 args.engine_components_factory =
420 std::move(options->engine_components_factory); 431 std::move(options->engine_components_factory);
421 args.encryptor = &encryptor_; 432 args.encryptor = &encryptor_;
422 args.unrecoverable_error_handler = options->unrecoverable_error_handler; 433 args.unrecoverable_error_handler = options->unrecoverable_error_handler;
423 args.report_unrecoverable_error_function = 434 args.report_unrecoverable_error_function =
424 options->report_unrecoverable_error_function; 435 options->report_unrecoverable_error_function;
425 args.cancelation_signal = &stop_syncing_signal_; 436 args.cancelation_signal = &stop_syncing_signal_;
426 args.saved_nigori_state = std::move(options->saved_nigori_state); 437 args.saved_nigori_state = std::move(options->saved_nigori_state);
427 sync_manager_->Init(&args); 438 sync_manager_->Init(&args);
439 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
440 this, "SyncDirectory", sync_loop_->task_runner());
428 } 441 }
429 442
430 void SyncBackendHostCore::DoUpdateCredentials( 443 void SyncBackendHostCore::DoUpdateCredentials(
431 const SyncCredentials& credentials) { 444 const SyncCredentials& credentials) {
432 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 445 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
433 // UpdateCredentials can be called during backend initialization, possibly 446 // UpdateCredentials can be called during backend initialization, possibly
434 // when backend initialization has failed but hasn't notified the UI thread 447 // when backend initialization has failed but hasn't notified the UI thread
435 // yet. In that case, the sync manager may have been destroyed on the sync 448 // yet. In that case, the sync manager may have been destroyed on the sync
436 // thread before this task was executed, so we do nothing. 449 // thread before this task was executed, so we do nothing.
437 if (sync_manager_) { 450 if (sync_manager_) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 544
532 if (reason == DISABLE_SYNC) 545 if (reason == DISABLE_SYNC)
533 DeleteSyncDataFolder(); 546 DeleteSyncDataFolder();
534 547
535 host_.Reset(); 548 host_.Reset();
536 weak_ptr_factory_.InvalidateWeakPtrs(); 549 weak_ptr_factory_.InvalidateWeakPtrs();
537 } 550 }
538 551
539 void SyncBackendHostCore::DoDestroySyncManager(ShutdownReason reason) { 552 void SyncBackendHostCore::DoDestroySyncManager(ShutdownReason reason) {
540 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 553 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
554 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
555 this);
541 if (sync_manager_) { 556 if (sync_manager_) {
542 DisableDirectoryTypeDebugInfoForwarding(); 557 DisableDirectoryTypeDebugInfoForwarding();
543 save_changes_timer_.reset(); 558 save_changes_timer_.reset();
544 sync_manager_->RemoveObserver(this); 559 sync_manager_->RemoveObserver(this);
545 sync_manager_->ShutdownOnSyncThread(reason); 560 sync_manager_->ShutdownOnSyncThread(reason);
546 sync_manager_.reset(); 561 sync_manager_.reset();
547 } 562 }
548 } 563 }
549 564
550 void SyncBackendHostCore::DoConfigureSyncer( 565 void SyncBackendHostCore::DoConfigureSyncer(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 697 }
683 698
684 void SyncBackendHostCore::ClearServerDataDone( 699 void SyncBackendHostCore::ClearServerDataDone(
685 const base::Closure& frontend_callback) { 700 const base::Closure& frontend_callback) {
686 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 701 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
687 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, 702 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
688 frontend_callback); 703 frontend_callback);
689 } 704 }
690 705
691 } // namespace syncer 706 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698