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

Unified Diff: content/common/child_trace_message_filter.cc

Issue 10837082: implement SetWatchEvent and WaitForEvent for trace-based-tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update / merge -- no change Created 8 years, 4 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 | « content/common/child_trace_message_filter.h ('k') | content/public/browser/trace_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
}
-
« no previous file with comments | « content/common/child_trace_message_filter.h ('k') | content/public/browser/trace_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698