diff options
author | primiano <primiano@chromium.org> | 2015-04-18 06:35:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-18 13:36:02 +0000 |
commit | 34ba094217686108e18600a7e5c45ade7ec39023 (patch) | |
tree | 83a5e958b4dc88a6b567d80c4f1dfc67835ca094 /base | |
parent | 727a854fe8f30ceee2fd738572a2cf05dbeeebd3 (diff) | |
download | chromium_src-34ba094217686108e18600a7e5c45ade7ec39023.zip chromium_src-34ba094217686108e18600a7e5c45ade7ec39023.tar.gz chromium_src-34ba094217686108e18600a7e5c45ade7ec39023.tar.bz2 |
[tracing] Prepare for internal async handling of ProcessMemoryDump(s)
So far the internal interface between MemoryDumpManager and its
delegates (TracingControllerImpl on the browser side and
ChildTraceMessageFilter on the child side) has been synchronous,
in the sense that all the MDP.DumpInto() calls were performed
in the current call stack.
The MemoryDumpProviders contract, however, is going to change in the
upcoming CLs to support posting the DumpInto() on other threads.
This requires to change the internal CreateProcessDump() method to
be asynchronous and requires the corresponding bookkeeping.
BUG=478008
Review URL: https://codereview.chromium.org/1089493003
Cr-Commit-Position: refs/heads/master@{#325779}
Diffstat (limited to 'base')
-rw-r--r-- | base/trace_event/memory_dump_manager.cc | 16 | ||||
-rw-r--r-- | base/trace_event/memory_dump_manager.h | 12 | ||||
-rw-r--r-- | base/trace_event/memory_dump_manager_unittest.cc | 2 |
3 files changed, 21 insertions, 9 deletions
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc index f59b3ec..d6bfa6f 100644 --- a/base/trace_event/memory_dump_manager.cc +++ b/base/trace_event/memory_dump_manager.cc @@ -49,11 +49,13 @@ const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type) { class ProcessMemoryDumpHolder : public RefCountedThreadSafe<ProcessMemoryDumpHolder> { public: - ProcessMemoryDumpHolder(MemoryDumpRequestArgs req_args) - : req_args(req_args) {} + ProcessMemoryDumpHolder(MemoryDumpRequestArgs req_args, + MemoryDumpCallback callback) + : req_args(req_args), callback(callback) {} ProcessMemoryDump process_memory_dump; const MemoryDumpRequestArgs req_args; + MemoryDumpCallback callback; private: friend class RefCountedThreadSafe<ProcessMemoryDumpHolder>; @@ -75,6 +77,11 @@ void FinalizeDumpAndAddToTrace( pmd_holder->req_args.dump_guid, kTraceEventNumArgs, kTraceEventArgNames, kTraceEventArgTypes, nullptr /* arg_values */, &event_value, TRACE_EVENT_FLAG_HAS_ID); + + if (!pmd_holder->callback.is_null()) { + pmd_holder->callback.Run(pmd_holder->req_args.dump_guid, true); + pmd_holder->callback.Reset(); + } } } // namespace @@ -164,9 +171,10 @@ void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type) { } // Creates a memory dump for the current process and appends it to the trace. -void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args) { +void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args, + const MemoryDumpCallback& callback) { scoped_refptr<ProcessMemoryDumpHolder> pmd_holder( - new ProcessMemoryDumpHolder(args)); + new ProcessMemoryDumpHolder(args, callback)); ProcessMemoryDump* pmd = &pmd_holder->process_memory_dump; bool did_any_provider_dump = false; diff --git a/base/trace_event/memory_dump_manager.h b/base/trace_event/memory_dump_manager.h index 9490169..26cebc9 100644 --- a/base/trace_event/memory_dump_manager.h +++ b/base/trace_event/memory_dump_manager.h @@ -52,7 +52,7 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { void RequestGlobalDump(MemoryDumpType dump_type, const MemoryDumpCallback& callback); - // Same as above, but without callback. + // Same as above (still asynchronous), but without callback. void RequestGlobalDump(MemoryDumpType dump_type); // TraceLog::EnabledStateObserver implementation. @@ -78,7 +78,10 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { // Internal, used only by MemoryDumpManagerDelegate. // Creates a memory dump for the current process and appends it to the trace. - void CreateProcessDump(const MemoryDumpRequestArgs& args); + // |callback| will be invoked upon completion on the same thread on which + // CreateProcessDump() was called. + void CreateProcessDump(const MemoryDumpRequestArgs& args, + const MemoryDumpCallback& callback); bool InvokeDumpProviderLocked(MemoryDumpProvider* mdp, ProcessMemoryDump* pmd); @@ -113,8 +116,9 @@ class BASE_EXPORT MemoryDumpManagerDelegate { MemoryDumpManagerDelegate() {} virtual ~MemoryDumpManagerDelegate() {} - void CreateProcessDump(const MemoryDumpRequestArgs& args) { - MemoryDumpManager::GetInstance()->CreateProcessDump(args); + void CreateProcessDump(const MemoryDumpRequestArgs& args, + const MemoryDumpCallback& callback) { + MemoryDumpManager::GetInstance()->CreateProcessDump(args, callback); } private: diff --git a/base/trace_event/memory_dump_manager_unittest.cc b/base/trace_event/memory_dump_manager_unittest.cc index f7ad195..659a06c 100644 --- a/base/trace_event/memory_dump_manager_unittest.cc +++ b/base/trace_event/memory_dump_manager_unittest.cc @@ -23,7 +23,7 @@ class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate { void RequestGlobalMemoryDump( const base::trace_event::MemoryDumpRequestArgs& args, const MemoryDumpCallback& callback) override { - CreateProcessDump(args); + CreateProcessDump(args, callback); } }; |