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

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 2819413002: [memory-infra] Remove MemoryDumpManagerDelegate (Closed)
Patch Set: rebase. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_dump_manager.cc
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc
index 10e5d1b13f6c6e22756b73e5e4da0c73dd1533a8..02f2a6a8d45665abd5e89bd19d6736ab771bb999 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -181,7 +181,8 @@ void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) {
}
MemoryDumpManager::MemoryDumpManager()
- : memory_tracing_enabled_(0),
+ : is_coordinator_(false),
+ memory_tracing_enabled_(0),
tracing_process_id_(kInvalidTracingProcessId),
dumper_registrations_ignored_for_testing_(false),
heap_profiling_enabled_(false) {
@@ -237,12 +238,14 @@ void MemoryDumpManager::EnableHeapProfilingIfNeeded() {
}
void MemoryDumpManager::Initialize(
- std::unique_ptr<MemoryDumpManagerDelegate> delegate) {
+ RequestGlobalDumpFunction request_dump_function,
+ bool is_coordinator) {
{
AutoLock lock(lock_);
- DCHECK(delegate);
- DCHECK(!delegate_);
- delegate_ = std::move(delegate);
+ DCHECK(!request_dump_function.is_null());
+ DCHECK(request_dump_function_.is_null());
+ request_dump_function_ = request_dump_function;
+ is_coordinator_ = is_coordinator;
EnableHeapProfilingIfNeeded();
}
@@ -456,10 +459,10 @@ void MemoryDumpManager::RequestGlobalDump(
MemoryDumpLevelOfDetailToString(level_of_detail));
GlobalMemoryDumpCallback wrapped_callback = Bind(&OnGlobalDumpDone, callback);
- // The delegate will coordinate the IPC broadcast and at some point invoke
+ // The embedder will coordinate the IPC broadcast and at some point invoke
// CreateProcessDump() to get a dump for the current process.
MemoryDumpRequestArgs args = {guid, dump_type, level_of_detail};
- delegate_->RequestGlobalMemoryDump(args, wrapped_callback);
+ request_dump_function_.Run(args, wrapped_callback);
}
void MemoryDumpManager::GetDumpProvidersForPolling(
@@ -823,7 +826,8 @@ void MemoryDumpManager::Enable(
AutoLock lock(lock_);
- DCHECK(delegate_); // At this point we must have a delegate.
+ // At this point we must have the ability to request global dumps.
+ DCHECK(!request_dump_function_.is_null());
session_state_ = session_state;
DCHECK(!dump_thread_);
@@ -863,7 +867,7 @@ void MemoryDumpManager::Enable(
// When peak detection is enabled, trigger a dump straight away as it
// gives a good reference point for analyzing the trace.
- if (delegate_->IsCoordinator()) {
+ if (is_coordinator_) {
dump_thread_->task_runner()->PostTask(
FROM_HERE, BindRepeating(&OnPeakDetected, trigger.level_of_detail));
}
@@ -871,7 +875,7 @@ void MemoryDumpManager::Enable(
}
// Only coordinator process triggers periodic global memory dumps.
- if (delegate_->IsCoordinator() && !periodic_config.triggers.empty()) {
+ if (is_coordinator_ && !periodic_config.triggers.empty()) {
MemoryDumpScheduler::GetInstance()->Start(periodic_config,
dump_thread_->task_runner());
}
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698