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

Side by Side Diff: components/sync_driver/glue/sync_backend_host_core.cc

Issue 2084243004: [WIP][tracing] Add memory dump provider for sync Directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add visitors for memory. Created 4 years, 5 months 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/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/trace_event/memory_dump_manager.h"
13 #include "components/data_use_measurement/core/data_use_user_data.h" 14 #include "components/data_use_measurement/core/data_use_user_data.h"
14 #include "components/invalidation/public/invalidation_util.h" 15 #include "components/invalidation/public/invalidation_util.h"
15 #include "components/invalidation/public/object_id_invalidation_map.h" 16 #include "components/invalidation/public/object_id_invalidation_map.h"
16 #include "components/sync_driver/glue/sync_backend_registrar.h" 17 #include "components/sync_driver/glue/sync_backend_registrar.h"
17 #include "components/sync_driver/invalidation_adapter.h" 18 #include "components/sync_driver/invalidation_adapter.h"
18 #include "components/sync_driver/local_device_info_provider_impl.h" 19 #include "components/sync_driver/local_device_info_provider_impl.h"
19 #include "sync/internal_api/public/events/protocol_event.h" 20 #include "sync/internal_api/public/events/protocol_event.h"
20 #include "sync/internal_api/public/http_post_provider_factory.h" 21 #include "sync/internal_api/public/http_post_provider_factory.h"
21 #include "sync/internal_api/public/internal_components_factory.h" 22 #include "sync/internal_api/public/internal_components_factory.h"
22 #include "sync/internal_api/public/sessions/commit_counters.h" 23 #include "sync/internal_api/public/sessions/commit_counters.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 forward_protocol_events_(false), 123 forward_protocol_events_(false),
123 forward_type_info_(false), 124 forward_type_info_(false),
124 weak_ptr_factory_(this) { 125 weak_ptr_factory_(this) {
125 DCHECK(backend.get()); 126 DCHECK(backend.get());
126 } 127 }
127 128
128 SyncBackendHostCore::~SyncBackendHostCore() { 129 SyncBackendHostCore::~SyncBackendHostCore() {
129 DCHECK(!sync_manager_.get()); 130 DCHECK(!sync_manager_.get());
130 } 131 }
131 132
133 bool SyncBackendHostCore::OnMemoryDump(
134 const base::trace_event::MemoryDumpArgs& args,
135 base::trace_event::ProcessMemoryDump* pmd) {
136 DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
137 if (!sync_manager_)
138 return false;
139 sync_manager_->OnMemoryDump(pmd);
140 return true;
141 }
142
132 void SyncBackendHostCore::OnSyncCycleCompleted( 143 void SyncBackendHostCore::OnSyncCycleCompleted(
133 const syncer::sessions::SyncSessionSnapshot& snapshot) { 144 const syncer::sessions::SyncSessionSnapshot& snapshot) {
134 if (!sync_loop_) 145 if (!sync_loop_)
135 return; 146 return;
136 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 147 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
137 148
138 host_.Call( 149 host_.Call(
139 FROM_HERE, 150 FROM_HERE,
140 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop, 151 &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop,
141 snapshot); 152 snapshot);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 options->restored_keystore_key_for_bootstrapping; 463 options->restored_keystore_key_for_bootstrapping;
453 args.internal_components_factory = 464 args.internal_components_factory =
454 std::move(options->internal_components_factory); 465 std::move(options->internal_components_factory);
455 args.encryptor = &encryptor_; 466 args.encryptor = &encryptor_;
456 args.unrecoverable_error_handler = options->unrecoverable_error_handler; 467 args.unrecoverable_error_handler = options->unrecoverable_error_handler;
457 args.report_unrecoverable_error_function = 468 args.report_unrecoverable_error_function =
458 options->report_unrecoverable_error_function; 469 options->report_unrecoverable_error_function;
459 args.cancelation_signal = &stop_syncing_signal_; 470 args.cancelation_signal = &stop_syncing_signal_;
460 args.saved_nigori_state = std::move(options->saved_nigori_state); 471 args.saved_nigori_state = std::move(options->saved_nigori_state);
461 sync_manager_->Init(&args); 472 sync_manager_->Init(&args);
473 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
474 this, "SyncDirectory", sync_loop_->task_runner());
462 } 475 }
463 476
464 void SyncBackendHostCore::DoUpdateCredentials( 477 void SyncBackendHostCore::DoUpdateCredentials(
465 const syncer::SyncCredentials& credentials) { 478 const syncer::SyncCredentials& credentials) {
466 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 479 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
467 // UpdateCredentials can be called during backend initialization, possibly 480 // UpdateCredentials can be called during backend initialization, possibly
468 // when backend initialization has failed but hasn't notified the UI thread 481 // when backend initialization has failed but hasn't notified the UI thread
469 // yet. In that case, the sync manager may have been destroyed on the sync 482 // yet. In that case, the sync manager may have been destroyed on the sync
470 // thread before this task was executed, so we do nothing. 483 // thread before this task was executed, so we do nothing.
471 if (sync_manager_) { 484 if (sync_manager_) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 581
569 if (reason == syncer::DISABLE_SYNC) 582 if (reason == syncer::DISABLE_SYNC)
570 DeleteSyncDataFolder(); 583 DeleteSyncDataFolder();
571 584
572 host_.Reset(); 585 host_.Reset();
573 weak_ptr_factory_.InvalidateWeakPtrs(); 586 weak_ptr_factory_.InvalidateWeakPtrs();
574 } 587 }
575 588
576 void SyncBackendHostCore::DoDestroySyncManager(syncer::ShutdownReason reason) { 589 void SyncBackendHostCore::DoDestroySyncManager(syncer::ShutdownReason reason) {
577 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 590 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
591
592 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
593 this);
578 if (sync_manager_) { 594 if (sync_manager_) {
579 DisableDirectoryTypeDebugInfoForwarding(); 595 DisableDirectoryTypeDebugInfoForwarding();
580 save_changes_timer_.reset(); 596 save_changes_timer_.reset();
581 sync_manager_->RemoveObserver(this); 597 sync_manager_->RemoveObserver(this);
582 sync_manager_->ShutdownOnSyncThread(reason); 598 sync_manager_->ShutdownOnSyncThread(reason);
583 sync_manager_.reset(); 599 sync_manager_.reset();
584 } 600 }
585 } 601 }
586 602
587 void SyncBackendHostCore::DoConfigureSyncer( 603 void SyncBackendHostCore::DoConfigureSyncer(
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 778
763 void SyncBackendHostCore::ClearServerDataDone( 779 void SyncBackendHostCore::ClearServerDataDone(
764 const base::Closure& frontend_callback) { 780 const base::Closure& frontend_callback) {
765 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); 781 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
766 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, 782 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
767 frontend_callback); 783 frontend_callback);
768 } 784 }
769 785
770 786
771 } // namespace browser_sync 787 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698