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

Unified Diff: components/tracing/child_trace_message_filter.cc

Issue 1039963003: [tracing] child-process-side impl for inter-process memory dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_3_messages
Patch Set: Add temporary workaround for crbug.com/474973 Created 5 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 | « components/tracing/child_trace_message_filter.h ('k') | components/tracing_nacl.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/tracing/child_trace_message_filter.cc
diff --git a/components/tracing/child_trace_message_filter.cc b/components/tracing/child_trace_message_filter.cc
index d20ba7b1b04da69eae5823588fdd8b222b84053f..3594dcef856c7cc1c8e9a849cd1a53b746412a3f 100644
--- a/components/tracing/child_trace_message_filter.cc
+++ b/components/tracing/child_trace_message_filter.cc
@@ -6,6 +6,7 @@
#include "base/message_loop/message_loop_proxy.h"
#include "base/trace_event/trace_event.h"
+#include "components/tracing/child_memory_dump_manager_delegate_impl.h"
#include "components/tracing/tracing_messages.h"
#include "ipc/ipc_channel.h"
@@ -16,14 +17,20 @@ namespace tracing {
ChildTraceMessageFilter::ChildTraceMessageFilter(
base::MessageLoopProxy* ipc_message_loop)
: sender_(NULL),
- ipc_message_loop_(ipc_message_loop) {}
+ ipc_message_loop_(ipc_message_loop),
+ pending_memory_dump_guid_(0) {
+}
void ChildTraceMessageFilter::OnFilterAdded(IPC::Sender* sender) {
sender_ = sender;
sender_->Send(new TracingHostMsg_ChildSupportsTracing());
+ ChildMemoryDumpManagerDelegateImpl::GetInstance()->SetChildTraceMessageFilter(
+ this);
}
void ChildTraceMessageFilter::OnFilterRemoved() {
+ ChildMemoryDumpManagerDelegateImpl::GetInstance()->SetChildTraceMessageFilter(
+ nullptr);
sender_ = NULL;
}
@@ -175,8 +182,9 @@ void ChildTraceMessageFilter::OnMonitoringTraceDataCollected(
// 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();
+ base::trace_event::MemoryDumpManager::GetInstance()->CreateProcessDump(args);
+ sender_->Send(
+ new TracingHostMsg_ProcessMemoryDumpResponse(args.dump_guid, true));
}
// Initiates a dump request, asking the Browser's MemoryDumpManager to
@@ -187,18 +195,28 @@ void ChildTraceMessageFilter::OnProcessMemoryDumpRequest(
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();
+ // If there is already another dump request pending from this child process,
+ // there is no point bothering the Browser's MemoryDumpManager.
+ if (pending_memory_dump_guid_) {
+ if (!callback.is_null())
+ callback.Run(args.dump_guid, false);
+ return;
+ }
+
+ pending_memory_dump_guid_ = args.dump_guid;
+ pending_memory_dump_callback_ = callback;
+ sender_->Send(new TracingHostMsg_GlobalMemoryDumpRequest(args));
}
// 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();
+ DCHECK_NE(0U, pending_memory_dump_guid_);
+ pending_memory_dump_guid_ = 0;
+ if (pending_memory_dump_callback_.is_null())
+ return;
+ pending_memory_dump_callback_.Run(dump_guid, success);
}
} // namespace tracing
« no previous file with comments | « components/tracing/child_trace_message_filter.h ('k') | components/tracing_nacl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698