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

Unified Diff: base/trace_event/memory_dump_manager.h

Issue 1430073002: [tracing] Allow asynchronous unregistration of unbound dump providers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: avoid repeating messages Created 4 years, 12 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 | « no previous file | base/trace_event/memory_dump_manager.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.h
diff --git a/base/trace_event/memory_dump_manager.h b/base/trace_event/memory_dump_manager.h
index f9774634ad037c5bdf5677a4ffa30263f99b3b08..b3880afdf478e4f7abbadd119515f832427fe749 100644
--- a/base/trace_event/memory_dump_manager.h
+++ b/base/trace_event/memory_dump_manager.h
@@ -84,6 +84,15 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
const MemoryDumpProvider::Options& options);
void UnregisterDumpProvider(MemoryDumpProvider* mdp);
+ // Unregisters an unbound dump provider and takes care about its deletion
+ // asynchronously. Can be used only for for dump providers with no
+ // task-runner affinity.
+ // This method takes ownership of the dump provider and guarantees that:
+ // - The |mdp| will be deleted at some point in the near future.
+ // - Its deletion will not happen concurrently with the OnMemoryDump() call.
+ // Note that OnMemoryDump() calls can still happen after this method returns.
+ void UnregisterAndDeleteDumpProviderSoon(scoped_ptr<MemoryDumpProvider> mdp);
+
// Requests a memory dump. The dump might happen or not depending on the
// filters and categories specified when enabling tracing.
// The optional |callback| is executed asynchronously, on an arbitrary thread,
@@ -142,8 +151,7 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// the ProcessMemoryDumpAsyncState. This is to allow removal (see below).
// - When the MDP.OnMemoryDump() is invoked, the corresponding MDPInfo copy
// inside ProcessMemoryDumpAsyncState is removed.
- // - In nominal conditions, the MDPInfo is destroyed in the
- // UnregisterDumpProvider() call.
+ // - In most cases, the MDPInfo is destroyed within UnregisterDumpProvider().
// - If UnregisterDumpProvider() is called while a dump is in progress, the
// MDPInfo is destroyed in the epilogue of ContinueAsyncProcessDump(), when
// the copy inside ProcessMemoryDumpAsyncState is erase()-d.
@@ -168,6 +176,10 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
MemoryDumpProvider* const dump_provider;
+ // Used to transfer ownership for UnregisterAndDeleteDumpProviderSoon().
+ // nullptr in all other cases.
+ scoped_ptr<MemoryDumpProvider> owned_dump_provider;
+
// Human readable name, for debugging and testing. Not necessarily unique.
const char* const name;
@@ -264,6 +276,10 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
void ContinueAsyncProcessDump(
ProcessMemoryDumpAsyncState* owned_pmd_async_state);
+ // Helper for the public UnregisterDumpProvider* functions.
+ void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp,
+ bool take_mdp_ownership_and_delete_async);
+
// An ordererd set of registered MemoryDumpProviderInfo(s), sorted by thread
// affinity (MDPs belonging to the same thread are adjacent).
MemoryDumpProviderInfo::OrderedSet dump_providers_;
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698