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 154903a15d0725d6c72aa594165076d4cb5bea72..b875c05416a395581ae0d587efcc503c2c965803 100644 |
--- a/components/tracing/child_trace_message_filter.cc |
+++ b/components/tracing/child_trace_message_filter.cc |
@@ -34,6 +34,12 @@ bool ChildTraceMessageFilter::OnMessageReceived(const IPC::Message& message) { |
IPC_BEGIN_MESSAGE_MAP(ChildTraceMessageFilter, message) |
IPC_MESSAGE_HANDLER(TracingMsg_BeginTracing, OnBeginTracing) |
IPC_MESSAGE_HANDLER(TracingMsg_EndTracing, OnEndTracing) |
+ IPC_MESSAGE_HANDLER(TracingMsg_BeginContinuousSamplingTracing, |
+ OnBeginContinuousSamplingTracing) |
+ IPC_MESSAGE_HANDLER(TracingMsg_EndContinuousSamplingTracing, |
+ OnEndContinuousSamplingTracing) |
+ IPC_MESSAGE_HANDLER(TracingMsg_ShowContinuousSamplingTracing, |
+ OnShowContinuousSamplingTracing) |
IPC_MESSAGE_HANDLER(TracingMsg_GetTraceBufferPercentFull, |
OnGetTraceBufferPercentFull) |
IPC_MESSAGE_HANDLER(TracingMsg_SetWatchEvent, OnSetWatchEvent) |
@@ -77,6 +83,29 @@ void ChildTraceMessageFilter::OnEndTracing() { |
channel_->Send(new TracingHostMsg_EndTracingAck(category_groups)); |
} |
+void ChildTraceMessageFilter::OnBeginContinuousSamplingTracing( |
+ base::TimeTicks browser_time) { |
+ TraceLog::GetInstance()->SetContinuousSamplingEnabled(); |
+} |
+ |
+void ChildTraceMessageFilter::OnEndContinuousSamplingTracing() { |
+ TraceLog::GetInstance()->SetContinuousSamplingDisabled(); |
+} |
+ |
+void ChildTraceMessageFilter::OnShowContinuousSamplingTracing() { |
+ // Flush will generate one or more callbacks to |
+ // OnContinuousSamplingTraceDataCollected. It's important that the last |
+ // OnContinuousSamplingTraceDataCollected gets called before |
+ // ShowContinuousSamplingTracingAck below. We are already on the IO thread, |
+ // so the OnContinuousSamplingTraceDataCollected calls will not be deferred. |
+ TraceLog::GetInstance()->FlushContinuousSamplingTracing( |
+ base::Bind(&ChildTraceMessageFilter:: |
+ OnContinuousSamplingTraceDataCollected, |
+ this)); |
+ |
+ channel_->Send(new TracingHostMsg_ShowContinuousSamplingTracingAck()); |
+} |
+ |
void ChildTraceMessageFilter::OnGetTraceBufferPercentFull() { |
float bpf = TraceLog::GetInstance()->GetBufferPercentFull(); |
@@ -105,6 +134,20 @@ void ChildTraceMessageFilter::OnTraceDataCollected( |
events_str_ptr->data())); |
} |
+void ChildTraceMessageFilter::OnContinuousSamplingTraceDataCollected( |
+ const scoped_refptr<base::RefCountedString>& events_str_ptr) { |
+ if (!ipc_message_loop_->BelongsToCurrentThread()) { |
+ ipc_message_loop_->PostTask(FROM_HERE, |
+ base::Bind(&ChildTraceMessageFilter:: |
+ OnContinuousSamplingTraceDataCollected, |
+ this, |
+ events_str_ptr)); |
+ return; |
+ } |
+ channel_->Send(new TracingHostMsg_ContinuousSamplingTraceDataCollected( |
+ events_str_ptr->data())); |
+} |
+ |
void ChildTraceMessageFilter::OnTraceNotification(int notification) { |
if (!ipc_message_loop_->BelongsToCurrentThread()) { |
ipc_message_loop_->PostTask(FROM_HERE, |