| Index: content/components/tracing/child_trace_message_filter.cc
|
| diff --git a/content/common/child_trace_message_filter.cc b/content/components/tracing/child_trace_message_filter.cc
|
| similarity index 63%
|
| rename from content/common/child_trace_message_filter.cc
|
| rename to content/components/tracing/child_trace_message_filter.cc
|
| index d3f434121577590c754c7100286477604784c752..453a976c2b7ffb13383f95cabf9a595020239228 100644
|
| --- a/content/common/child_trace_message_filter.cc
|
| +++ b/content/components/tracing/child_trace_message_filter.cc
|
| @@ -2,25 +2,26 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/common/child_trace_message_filter.h"
|
| +#include "content/components/tracing/child_trace_message_filter.h"
|
|
|
| -#include "base/bind.h"
|
| #include "base/debug/trace_event.h"
|
| -#include "base/message_loop.h"
|
| -#include "content/common/child_process.h"
|
| -#include "content/common/child_process_messages.h"
|
| +#include "base/message_loop_proxy.h"
|
| +#include "content/components/tracing/tracing_messages.h"
|
|
|
| using base::debug::TraceLog;
|
|
|
| namespace content {
|
|
|
| -ChildTraceMessageFilter::ChildTraceMessageFilter() : channel_(NULL) {}
|
| +ChildTraceMessageFilter::ChildTraceMessageFilter(
|
| + base::MessageLoopProxy* ipc_message_loop)
|
| + : channel_(NULL),
|
| + ipc_message_loop_(ipc_message_loop) {}
|
|
|
| void ChildTraceMessageFilter::OnFilterAdded(IPC::Channel* channel) {
|
| channel_ = channel;
|
| TraceLog::GetInstance()->SetNotificationCallback(
|
| base::Bind(&ChildTraceMessageFilter::OnTraceNotification, this));
|
| - channel_->Send(new ChildProcessHostMsg_ChildSupportsTracing());
|
| + channel_->Send(new TracingHostMsg_ChildSupportsTracing());
|
| }
|
|
|
| void ChildTraceMessageFilter::OnFilterRemoved() {
|
| @@ -31,12 +32,12 @@ void ChildTraceMessageFilter::OnFilterRemoved() {
|
| bool ChildTraceMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(ChildTraceMessageFilter, message)
|
| - IPC_MESSAGE_HANDLER(ChildProcessMsg_BeginTracing, OnBeginTracing)
|
| - IPC_MESSAGE_HANDLER(ChildProcessMsg_EndTracing, OnEndTracing)
|
| - IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTraceBufferPercentFull,
|
| + IPC_MESSAGE_HANDLER(TracingMsg_BeginTracing, OnBeginTracing)
|
| + IPC_MESSAGE_HANDLER(TracingMsg_EndTracing, OnEndTracing)
|
| + IPC_MESSAGE_HANDLER(TracingMsg_GetTraceBufferPercentFull,
|
| OnGetTraceBufferPercentFull)
|
| - IPC_MESSAGE_HANDLER(ChildProcessMsg_SetWatchEvent, OnSetWatchEvent)
|
| - IPC_MESSAGE_HANDLER(ChildProcessMsg_CancelWatchEvent, OnCancelWatchEvent)
|
| + IPC_MESSAGE_HANDLER(TracingMsg_SetWatchEvent, OnSetWatchEvent)
|
| + IPC_MESSAGE_HANDLER(TracingMsg_CancelWatchEvent, OnCancelWatchEvent)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -46,7 +47,16 @@ ChildTraceMessageFilter::~ChildTraceMessageFilter() {}
|
|
|
| void ChildTraceMessageFilter::OnBeginTracing(
|
| const std::vector<std::string>& included_categories,
|
| - const std::vector<std::string>& excluded_categories) {
|
| + const std::vector<std::string>& excluded_categories,
|
| + base::TimeTicks browser_time) {
|
| +#if defined(__native_client__)
|
| + // NaCl and system times are offset by a bit, so subtract some time from
|
| + // the captured timestamps. The value might be off by a bit due to messaging
|
| + // latency.
|
| + base::TimeDelta time_offset = base::TimeTicks::NowFromSystemTraceTime() -
|
| + browser_time;
|
| + TraceLog::GetInstance()->SetTimeOffset(time_offset);
|
| +#endif
|
| TraceLog::GetInstance()->SetEnabled(included_categories,
|
| excluded_categories);
|
| }
|
| @@ -63,13 +73,13 @@ void ChildTraceMessageFilter::OnEndTracing() {
|
|
|
| std::vector<std::string> categories;
|
| TraceLog::GetInstance()->GetKnownCategories(&categories);
|
| - channel_->Send(new ChildProcessHostMsg_EndTracingAck(categories));
|
| + channel_->Send(new TracingHostMsg_EndTracingAck(categories));
|
| }
|
|
|
| void ChildTraceMessageFilter::OnGetTraceBufferPercentFull() {
|
| float bpf = TraceLog::GetInstance()->GetBufferPercentFull();
|
|
|
| - channel_->Send(new ChildProcessHostMsg_TraceBufferPercentFullReply(bpf));
|
| + channel_->Send(new TracingHostMsg_TraceBufferPercentFullReply(bpf));
|
| }
|
|
|
| void ChildTraceMessageFilter::OnSetWatchEvent(const std::string& category_name,
|
| @@ -84,26 +94,24 @@ void ChildTraceMessageFilter::OnCancelWatchEvent() {
|
|
|
| void ChildTraceMessageFilter::OnTraceDataCollected(
|
| const scoped_refptr<base::RefCountedString>& events_str_ptr) {
|
| - if (MessageLoop::current() != ChildProcess::current()->io_message_loop()) {
|
| - ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
|
| + if (!ipc_message_loop_->BelongsToCurrentThread()) {
|
| + ipc_message_loop_->PostTask(FROM_HERE,
|
| base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this,
|
| events_str_ptr));
|
| return;
|
| }
|
| -
|
| - channel_->Send(new ChildProcessHostMsg_TraceDataCollected(
|
| + channel_->Send(new TracingHostMsg_TraceDataCollected(
|
| events_str_ptr->data()));
|
| }
|
|
|
| void ChildTraceMessageFilter::OnTraceNotification(int notification) {
|
| - if (MessageLoop::current() != ChildProcess::current()->io_message_loop()) {
|
| - ChildProcess::current()->io_message_loop()->PostTask(FROM_HERE,
|
| + if (!ipc_message_loop_->BelongsToCurrentThread()) {
|
| + ipc_message_loop_->PostTask(FROM_HERE,
|
| base::Bind(&ChildTraceMessageFilter::OnTraceNotification, this,
|
| notification));
|
| return;
|
| }
|
| -
|
| - channel_->Send(new ChildProcessHostMsg_TraceNotification(notification));
|
| + channel_->Send(new TracingHostMsg_TraceNotification(notification));
|
| }
|
|
|
| } // namespace content
|
|
|