Index: content/common/child_trace_message_filter.cc |
diff --git a/content/common/child_trace_message_filter.cc b/content/common/child_trace_message_filter.cc |
index adc5426852c92610b1eca9753b190d8a8008e7e7..6ca3031699ffcea37c8cb247bd76f83956f3cba9 100644 |
--- a/content/common/child_trace_message_filter.cc |
+++ b/content/common/child_trace_message_filter.cc |
@@ -10,23 +10,20 @@ |
#include "content/common/child_process.h" |
#include "content/common/child_process_messages.h" |
+using base::debug::TraceLog; |
ChildTraceMessageFilter::ChildTraceMessageFilter() : channel_(NULL) {} |
void ChildTraceMessageFilter::OnFilterAdded(IPC::Channel* channel) { |
channel_ = channel; |
- base::debug::TraceLog::GetInstance()->SetOutputCallback( |
- base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this)); |
- base::debug::TraceLog::GetInstance()->SetBufferFullCallback( |
- base::Bind(&ChildTraceMessageFilter::OnTraceBufferFull, this)); |
+ TraceLog::GetInstance()->SetNotificationCallback( |
+ base::Bind(&ChildTraceMessageFilter::OnTraceNotification, this)); |
channel_->Send(new ChildProcessHostMsg_ChildSupportsTracing()); |
} |
void ChildTraceMessageFilter::OnFilterRemoved() { |
- base::debug::TraceLog::GetInstance()->SetOutputCallback( |
- base::debug::TraceLog::OutputCallback()); |
- base::debug::TraceLog::GetInstance()->SetBufferFullCallback( |
- base::debug::TraceLog::BufferFullCallback()); |
+ TraceLog::GetInstance()->SetNotificationCallback( |
+ TraceLog::NotificationCallback()); |
} |
bool ChildTraceMessageFilter::OnMessageReceived(const IPC::Message& message) { |
@@ -36,6 +33,8 @@ bool ChildTraceMessageFilter::OnMessageReceived(const IPC::Message& message) { |
IPC_MESSAGE_HANDLER(ChildProcessMsg_EndTracing, OnEndTracing) |
IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTraceBufferPercentFull, |
OnGetTraceBufferPercentFull) |
+ IPC_MESSAGE_HANDLER(ChildProcessMsg_SetWatchEvent, OnSetWatchEvent) |
+ IPC_MESSAGE_HANDLER(ChildProcessMsg_CancelWatchEvent, OnCancelWatchEvent) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |
@@ -46,29 +45,41 @@ ChildTraceMessageFilter::~ChildTraceMessageFilter() {} |
void ChildTraceMessageFilter::OnBeginTracing( |
const std::vector<std::string>& included_categories, |
const std::vector<std::string>& excluded_categories) { |
- base::debug::TraceLog::GetInstance()->SetEnabled(included_categories, |
- excluded_categories); |
+ TraceLog::GetInstance()->SetEnabled(included_categories, |
+ excluded_categories); |
} |
void ChildTraceMessageFilter::OnEndTracing() { |
- // SetDisabled may generate a callback to OnTraceDataCollected. |
- // It's important that the last OnTraceDataCollected gets called before |
- // EndTracingAck below. |
- // We are already on the IO thread, so it is guaranteed that |
- // OnTraceDataCollected is not deferred. |
- base::debug::TraceLog::GetInstance()->SetDisabled(); |
+ TraceLog::GetInstance()->SetDisabled(); |
+ |
+ // Flush will generate one or more callbacks to OnTraceDataCollected. It's |
+ // important that the last OnTraceDataCollected gets called before |
+ // EndTracingAck below. We are already on the IO thread, so the |
+ // OnTraceDataCollected calls will not be deferred. |
+ TraceLog::GetInstance()->Flush( |
+ base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this)); |
std::vector<std::string> categories; |
- base::debug::TraceLog::GetInstance()->GetKnownCategories(&categories); |
+ TraceLog::GetInstance()->GetKnownCategories(&categories); |
channel_->Send(new ChildProcessHostMsg_EndTracingAck(categories)); |
} |
void ChildTraceMessageFilter::OnGetTraceBufferPercentFull() { |
- float bpf = base::debug::TraceLog::GetInstance()->GetBufferPercentFull(); |
+ float bpf = TraceLog::GetInstance()->GetBufferPercentFull(); |
channel_->Send(new ChildProcessHostMsg_TraceBufferPercentFullReply(bpf)); |
} |
+void ChildTraceMessageFilter::OnSetWatchEvent(const std::string& category_name, |
+ const std::string& event_name) { |
+ TraceLog::GetInstance()->SetWatchEvent(category_name.c_str(), |
+ event_name.c_str()); |
+} |
+ |
+void ChildTraceMessageFilter::OnCancelWatchEvent() { |
+ TraceLog::GetInstance()->CancelWatchEvent(); |
+} |
+ |
void ChildTraceMessageFilter::OnTraceDataCollected( |
const scoped_refptr<base::RefCountedString>& events_str_ptr) { |
if (MessageLoop::current() != ChildProcess::current()->io_message_loop()) { |
@@ -79,16 +90,16 @@ void ChildTraceMessageFilter::OnTraceDataCollected( |
} |
channel_->Send(new ChildProcessHostMsg_TraceDataCollected( |
- events_str_ptr->data())); |
+ events_str_ptr->data())); |
} |
-void ChildTraceMessageFilter::OnTraceBufferFull() { |
+void ChildTraceMessageFilter::OnTraceNotification(int notification) { |
if (MessageLoop::current() != ChildProcess::current()->io_message_loop()) { |
ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE, |
- base::Bind(&ChildTraceMessageFilter::OnTraceBufferFull, this)); |
+ base::Bind(&ChildTraceMessageFilter::OnTraceNotification, this, |
+ notification)); |
return; |
} |
- channel_->Send(new ChildProcessHostMsg_TraceBufferFull()); |
+ channel_->Send(new ChildProcessHostMsg_TraceNotification(notification)); |
} |
- |