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

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 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 56cc9023a8191174801dd6686b4999639eb3b992..35b27d9a03a0a0212b0f807e83068881f3d4395b 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -11,6 +11,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
+#include "base/memory/ptr_util.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
@@ -81,7 +82,7 @@ void OnGlobalDumpDone(MemoryDumpCallback wrapped_callback,
// Proxy class which wraps a ConvertableToTraceFormat owned by the
// |session_state| into a proxy object that can be added to the trace event log.
// This is to solve the problem that the MemoryDumpSessionState is refcounted
-// but the tracing subsystem wants a scoped_ptr<ConvertableToTraceFormat>.
+// but the tracing subsystem wants a std::unique_ptr<ConvertableToTraceFormat>.
template <typename T>
struct SessionStateConvertableProxy : public ConvertableToTraceFormat {
using GetterFunctPtr = T* (MemoryDumpSessionState::*)() const;
@@ -267,14 +268,14 @@ void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) {
}
void MemoryDumpManager::UnregisterAndDeleteDumpProviderSoon(
- scoped_ptr<MemoryDumpProvider> mdp) {
+ std::unique_ptr<MemoryDumpProvider> mdp) {
UnregisterDumpProviderInternal(mdp.release(), true /* delete_async */);
}
void MemoryDumpManager::UnregisterDumpProviderInternal(
MemoryDumpProvider* mdp,
bool take_mdp_ownership_and_delete_async) {
- scoped_ptr<MemoryDumpProvider> owned_mdp;
+ std::unique_ptr<MemoryDumpProvider> owned_mdp;
if (take_mdp_ownership_and_delete_async)
owned_mdp.reset(mdp);
@@ -370,7 +371,7 @@ void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(kTraceCategory, "ProcessMemoryDump",
TRACE_ID_MANGLE(args.dump_guid));
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state;
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state;
{
AutoLock lock(lock_);
// |dump_thread_| can be nullptr is tracing was disabled before reaching
@@ -400,7 +401,7 @@ void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
// |lock_| is used in these functions purely to ensure consistency w.r.t.
// (un)registrations of |dump_providers_|.
void MemoryDumpManager::SetupNextMemoryDump(
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
// Initalizes the ThreadLocalEventBuffer to guarantee that the TRACE_EVENTs
// in the PostTask below don't end up registering their own dump providers
// (for discounting trace memory overhead) while holding the |lock_|.
@@ -482,7 +483,7 @@ void MemoryDumpManager::InvokeOnMemoryDump(
// Unfortunately, PostTask() destroys the scoped_ptr arguments upon failure
// to prevent accidental leaks. Using a scoped_ptr would prevent us to to
// skip the hop and move on. Hence the manual naked -> scoped ptr juggling.
- auto pmd_async_state = make_scoped_ptr(owned_pmd_async_state);
+ auto pmd_async_state = WrapUnique(owned_pmd_async_state);
owned_pmd_async_state = nullptr;
// Read MemoryDumpProviderInfo thread safety considerations in
@@ -535,7 +536,7 @@ void MemoryDumpManager::InvokeOnMemoryDump(
// static
void MemoryDumpManager::FinalizeDumpAndAddToTrace(
- scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
+ std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
DCHECK(pmd_async_state->pending_dump_providers.empty());
const uint64_t dump_guid = pmd_async_state->req_args.dump_guid;
if (!pmd_async_state->callback_task_runner->BelongsToCurrentThread()) {
@@ -554,7 +555,7 @@ void MemoryDumpManager::FinalizeDumpAndAddToTrace(
for (const auto& kv : pmd_async_state->process_dumps) {
ProcessId pid = kv.first; // kNullProcessId for the current process.
ProcessMemoryDump* process_memory_dump = kv.second.get();
- scoped_ptr<TracedValue> traced_value(new TracedValue);
+ std::unique_ptr<TracedValue> traced_value(new TracedValue);
process_memory_dump->AsValueInto(traced_value.get());
traced_value->SetString("level_of_detail",
MemoryDumpLevelOfDetailToString(
@@ -562,7 +563,8 @@ void MemoryDumpManager::FinalizeDumpAndAddToTrace(
const char* const event_name =
MemoryDumpTypeToString(pmd_async_state->req_args.dump_type);
- scoped_ptr<ConvertableToTraceFormat> event_value(std::move(traced_value));
+ std::unique_ptr<ConvertableToTraceFormat> event_value(
+ std::move(traced_value));
TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_PROCESS_ID(
TRACE_EVENT_PHASE_MEMORY_DUMP,
TraceLog::GetCategoryGroupEnabled(kTraceCategory), event_name,
@@ -598,7 +600,7 @@ void MemoryDumpManager::OnTraceLogEnabled() {
TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported();
// Spin-up the thread used to invoke unbound dump providers.
- scoped_ptr<Thread> dump_thread(new Thread("MemoryInfra"));
+ std::unique_ptr<Thread> dump_thread(new Thread("MemoryInfra"));
if (!dump_thread->Start()) {
LOG(ERROR) << "Failed to start the memory-infra thread for tracing";
return;
@@ -614,15 +616,15 @@ void MemoryDumpManager::OnTraceLogEnabled() {
// deduplicator will be in use. Add a metadata events to write the frames
// and type IDs.
session_state_->SetStackFrameDeduplicator(
- make_scoped_ptr(new StackFrameDeduplicator));
+ WrapUnique(new StackFrameDeduplicator));
session_state_->SetTypeNameDeduplicator(
- make_scoped_ptr(new TypeNameDeduplicator));
+ WrapUnique(new TypeNameDeduplicator));
TRACE_EVENT_API_ADD_METADATA_EVENT(
TraceLog::GetCategoryGroupEnabled("__metadata"), "stackFrames",
"stackFrames",
- make_scoped_ptr(
+ WrapUnique(
new SessionStateConvertableProxy<StackFrameDeduplicator>(
session_state_,
&MemoryDumpSessionState::stack_frame_deduplicator)));
@@ -630,7 +632,7 @@ void MemoryDumpManager::OnTraceLogEnabled() {
TRACE_EVENT_API_ADD_METADATA_EVENT(
TraceLog::GetCategoryGroupEnabled("__metadata"), "typeNames",
"typeNames",
- make_scoped_ptr(new SessionStateConvertableProxy<TypeNameDeduplicator>(
+ WrapUnique(new SessionStateConvertableProxy<TypeNameDeduplicator>(
session_state_, &MemoryDumpSessionState::type_name_deduplicator)));
}
@@ -682,7 +684,7 @@ void MemoryDumpManager::OnTraceLogDisabled() {
// ensure that the MDM state which depends on the tracing enabled / disabled
// state is always accessed by the dumping methods holding the |lock_|.
subtle::NoBarrier_Store(&memory_tracing_enabled_, 0);
- scoped_ptr<Thread> dump_thread;
+ std::unique_ptr<Thread> dump_thread;
{
AutoLock lock(lock_);
dump_thread = std::move(dump_thread_);
@@ -749,7 +751,8 @@ ProcessMemoryDump* MemoryDumpManager::ProcessMemoryDumpAsyncState::
GetOrCreateMemoryDumpContainerForProcess(ProcessId pid) {
auto iter = process_dumps.find(pid);
if (iter == process_dumps.end()) {
- scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state));
+ std::unique_ptr<ProcessMemoryDump> new_pmd(
+ new ProcessMemoryDump(session_state));
iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
}
return iter->second.get();
« 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