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 246a5aadcafddcd92ca15c4e96e871fc5763905c..a8cf194210656996310e09c952ddc183f0b40dad 100644 |
--- a/base/trace_event/memory_dump_manager.cc |
+++ b/base/trace_event/memory_dump_manager.cc |
@@ -152,9 +152,7 @@ void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) { |
} |
MemoryDumpManager::MemoryDumpManager() |
- : delegate_(nullptr), |
- is_coordinator_(false), |
- memory_tracing_enabled_(0), |
+ : memory_tracing_enabled_(0), |
tracing_process_id_(kInvalidTracingProcessId), |
dumper_registrations_ignored_for_testing_(false), |
heap_profiling_enabled_(false) { |
@@ -209,14 +207,13 @@ void MemoryDumpManager::EnableHeapProfilingIfNeeded() { |
heap_profiling_enabled_ = true; |
} |
-void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
- bool is_coordinator) { |
+void MemoryDumpManager::Initialize( |
+ std::unique_ptr<MemoryDumpManagerDelegate> delegate) { |
{ |
AutoLock lock(lock_); |
DCHECK(delegate); |
DCHECK(!delegate_); |
- delegate_ = delegate; |
- is_coordinator_ = is_coordinator; |
+ delegate_.swap(delegate); |
EnableHeapProfilingIfNeeded(); |
} |
@@ -447,21 +444,10 @@ void MemoryDumpManager::RequestGlobalDump( |
TRACE_ID_MANGLE(guid)); |
MemoryDumpCallback wrapped_callback = Bind(&OnGlobalDumpDone, callback); |
- // Technically there is no need to grab the |lock_| here as the delegate is |
- // long-lived and can only be set by Initialize(), which is locked and |
- // necessarily happens before memory_tracing_enabled_ == true. |
- // Not taking the |lock_|, though, is lakely make TSan barf and, at this point |
- // (memory-infra is enabled) we're not in the fast-path anymore. |
- MemoryDumpManagerDelegate* delegate; |
- { |
- AutoLock lock(lock_); |
- delegate = delegate_; |
- } |
- |
// The delegate 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); |
+ delegate_->RequestGlobalMemoryDump(args, wrapped_callback); |
} |
void MemoryDumpManager::RequestGlobalDump( |
@@ -807,7 +793,7 @@ void MemoryDumpManager::OnTraceLogEnabled() { |
subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); |
- if (!is_coordinator_) |
+ if (!delegate_->IsCoordinator()) |
return; |
} |
@@ -853,8 +839,12 @@ bool MemoryDumpManager::IsDumpModeAllowed(MemoryDumpLevelOfDetail dump_mode) { |
dump_mode) != 0; |
} |
-uint64_t MemoryDumpManager::GetTracingProcessId() const { |
- return delegate_->GetTracingProcessId(); |
+uint64_t MemoryDumpManager::tracing_process_id() const { |
+ return tracing_process_id_; |
+} |
+ |
+void MemoryDumpManager::set_tracing_process_id(uint64_t tracing_process_id) { |
+ tracing_process_id_ = tracing_process_id; |
} |
MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( |