diff options
author | primiano <primiano@chromium.org> | 2015-04-01 10:58:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-01 17:59:41 +0000 |
commit | 04f9de655915bfaf9fa2c90ee4848452ca71d89f (patch) | |
tree | 56c562213786d4045e0f3630a5e7c13c7d27d9cb /components/tracing | |
parent | 4542844b847c18f51a4da24aa2cf7a1229e67012 (diff) | |
download | chromium_src-04f9de655915bfaf9fa2c90ee4848452ca71d89f.zip chromium_src-04f9de655915bfaf9fa2c90ee4848452ca71d89f.tar.gz chromium_src-04f9de655915bfaf9fa2c90ee4848452ca71d89f.tar.bz2 |
[tracing] IPC messages and stubs for inter-process memory dumps
This CL introduces the four IPC messages and the message filter stubs
that will be used by the upcoming CLs to coordinate memory dumps
across processes.
The global coordination policy is simple: all the global dumps must
be orchestrated and handled by the browser process' MemoryDumpManager.
Memory dumps initiated by a child process must be routed through the
browser's MDM.
In other words this reads as: all the Chrome processes have a MDM,
but the browser's MDM is a more senior and responsible manager.
This CL introduces a total of four IPC messages:
(request, response) x (process, global), as follows:
Request local (i.e. current process) dumps to children:
(browser -> child) TracingMsg_ProcessMemoryDumpRequest
(child -> browser) TracingHostMsg_ProcessMemoryDumpResponse
Initiate global dumps from a child process:
(child -> browser) TracingHostMsg_GlobalMemoryDumpRequest
(browser -> child) TracingMsg_GlobalMemoryDumpResponse
If the global dump is initiated by the browser process, a total of
N_children x 2 (req/resp) IPC messages occur to perform the dump.
If the global dump is initiated by a child process, a further couple
of IPC messages (GlobalMemoryDump{Request,Response}) is required in
order to, respectively, tell the browser's MDM to initiate the dump
and get the final result back (all the child processes succeed / the
global dump was aborted because another one was in progress).
More context and design doc are available in the attached BUG.
BUG=462930
Review URL: https://codereview.chromium.org/1042723002
Cr-Commit-Position: refs/heads/master@{#323284}
Diffstat (limited to 'components/tracing')
-rw-r--r-- | components/tracing/child_trace_message_filter.cc | 33 | ||||
-rw-r--r-- | components/tracing/child_trace_message_filter.h | 8 | ||||
-rw-r--r-- | components/tracing/tracing_messages.h | 29 |
3 files changed, 70 insertions, 0 deletions
diff --git a/components/tracing/child_trace_message_filter.cc b/components/tracing/child_trace_message_filter.cc index 197d22f..d20ba7b 100644 --- a/components/tracing/child_trace_message_filter.cc +++ b/components/tracing/child_trace_message_filter.cc @@ -39,6 +39,10 @@ bool ChildTraceMessageFilter::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(TracingMsg_GetTraceLogStatus, OnGetTraceLogStatus) IPC_MESSAGE_HANDLER(TracingMsg_SetWatchEvent, OnSetWatchEvent) IPC_MESSAGE_HANDLER(TracingMsg_CancelWatchEvent, OnCancelWatchEvent) + IPC_MESSAGE_HANDLER(TracingMsg_ProcessMemoryDumpRequest, + OnProcessMemoryDumpRequest) + IPC_MESSAGE_HANDLER(TracingMsg_GlobalMemoryDumpResponse, + OnGlobalMemoryDumpResponse) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -168,4 +172,33 @@ void ChildTraceMessageFilter::OnMonitoringTraceDataCollected( sender_->Send(new TracingHostMsg_CaptureMonitoringSnapshotAck()); } +// Sent by the Browser's MemoryDumpManager when coordinating a global dump. +void ChildTraceMessageFilter::OnProcessMemoryDumpRequest( + const base::trace_event::MemoryDumpRequestArgs& args) { + // TODO(primiano): create local dump and send a response back to the browser. + NOTIMPLEMENTED(); +} + +// Initiates a dump request, asking the Browser's MemoryDumpManager to +// coordinate a global memory dump. The Browser's MDM will answer back with a +// MemoryDumpResponse when all the child processes (including this one) have +// dumped, or with a NACK (|success| == false) if the dump failed (e.g., due to +// a collision with a concurrent request from another child process). +void ChildTraceMessageFilter::SendGlobalMemoryDumpRequest( + const base::trace_event::MemoryDumpRequestArgs& args, + const base::trace_event::MemoryDumpCallback& callback) { + // TODO(primiano): implement the logic to send the request to the browser + // process and keep track of that. + NOTIMPLEMENTED(); +} + +// Sent by the Browser's MemoryDumpManager in response of a dump request +// initiated by this child process. +void ChildTraceMessageFilter::OnGlobalMemoryDumpResponse(uint64 dump_guid, + bool success) { + // TODO(primiano): implement the logic to handle the global response from + // the browser and clear up the bookkeeping. + NOTIMPLEMENTED(); +} + } // namespace tracing diff --git a/components/tracing/child_trace_message_filter.h b/components/tracing/child_trace_message_filter.h index 75ab067..d3d934097 100644 --- a/components/tracing/child_trace_message_filter.h +++ b/components/tracing/child_trace_message_filter.h @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/memory/ref_counted_memory.h" +#include "base/trace_event/memory_dump_request_args.h" #include "ipc/message_filter.h" namespace base { @@ -25,6 +26,10 @@ class ChildTraceMessageFilter : public IPC::MessageFilter { void OnFilterRemoved() override; bool OnMessageReceived(const IPC::Message& message) override; + void SendGlobalMemoryDumpRequest( + const base::trace_event::MemoryDumpRequestArgs& args, + const base::trace_event::MemoryDumpCallback& callback); + protected: ~ChildTraceMessageFilter() override; @@ -44,6 +49,9 @@ class ChildTraceMessageFilter : public IPC::MessageFilter { const std::string& event_name); void OnCancelWatchEvent(); void OnWatchEventMatched(); + void OnProcessMemoryDumpRequest( + const base::trace_event::MemoryDumpRequestArgs& args); + void OnGlobalMemoryDumpResponse(uint64 dump_guid, bool success); // Callback from trace subsystem. void OnTraceDataCollected( diff --git a/components/tracing/tracing_messages.h b/components/tracing/tracing_messages.h index 6cd6b27..d9ba630 100644 --- a/components/tracing/tracing_messages.h +++ b/components/tracing/tracing_messages.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/sync_socket.h" +#include "base/trace_event/memory_dump_request_args.h" #include "base/trace_event/trace_event_impl.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_message_macros.h" @@ -21,6 +22,15 @@ IPC_STRUCT_TRAITS_MEMBER(event_capacity) IPC_STRUCT_TRAITS_MEMBER(event_count) IPC_STRUCT_TRAITS_END() +IPC_STRUCT_TRAITS_BEGIN(base::trace_event::MemoryDumpRequestArgs) +IPC_STRUCT_TRAITS_MEMBER(dump_guid) +IPC_STRUCT_TRAITS_MEMBER(dump_type) +IPC_STRUCT_TRAITS_END() + +IPC_ENUM_TRAITS_MAX_VALUE( + base::trace_event::MemoryDumpType, + static_cast<int>(base::trace_event::MemoryDumpType::LAST)) + // Sent to all child processes to enable trace event recording. IPC_MESSAGE_CONTROL3(TracingMsg_BeginTracing, std::string /* category_filter_str */, @@ -53,6 +63,16 @@ IPC_MESSAGE_CONTROL2(TracingMsg_SetWatchEvent, // Sent to all child processes to clear watch event. IPC_MESSAGE_CONTROL0(TracingMsg_CancelWatchEvent) +// Sent to all child processes to request a local (current process) memory dump. +IPC_MESSAGE_CONTROL1(TracingMsg_ProcessMemoryDumpRequest, + base::trace_event::MemoryDumpRequestArgs) + +// Reply to TracingHostMsg_GlobalMemoryDumpRequest, sent by the browser process. +// This is to get the result of a global dump initiated by a child process. +IPC_MESSAGE_CONTROL2(TracingMsg_GlobalMemoryDumpResponse, + uint64 /* dump_guid */, + bool /* success */) + // Sent everytime when a watch event is matched. IPC_MESSAGE_CONTROL0(TracingHostMsg_WatchEventMatched) @@ -79,3 +99,12 @@ IPC_MESSAGE_CONTROL1(TracingHostMsg_MonitoringTraceDataCollected, IPC_MESSAGE_CONTROL1( TracingHostMsg_TraceLogStatusReply, base::trace_event::TraceLogStatus /*status of the trace log*/) + +// Sent to the browser to initiate a global memory dump from a child process. +IPC_MESSAGE_CONTROL1(TracingHostMsg_GlobalMemoryDumpRequest, + base::trace_event::MemoryDumpRequestArgs) + +// Reply to TracingMsg_ProcessMemoryDumpRequest. +IPC_MESSAGE_CONTROL2(TracingHostMsg_ProcessMemoryDumpResponse, + uint64 /* dump_guid */, + bool /* success */) |