summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-08 01:55:07 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-08 01:55:07 +0000
commit92fe610ca9b3a745c00f5d172fa8d955004fcecc (patch)
treed12d523dbd564090fbfb3d51ca59700bb156d007
parent54947031f1b6094498f16b49009a5abceba3d401 (diff)
downloadchromium_src-92fe610ca9b3a745c00f5d172fa8d955004fcecc.zip
chromium_src-92fe610ca9b3a745c00f5d172fa8d955004fcecc.tar.gz
chromium_src-92fe610ca9b3a745c00f5d172fa8d955004fcecc.tar.bz2
Add tracing support to NaCl
Add Ppapi IPC messages and a handler inside of the NaCl IRT to enable, disable, and send the result of tracing. BUG=93839 Review URL: https://codereview.chromium.org/11411118 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171911 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/debug/trace_event_impl.cc6
-rw-r--r--base/debug/trace_event_impl.h6
-rw-r--r--content/browser/DEPS1
-rw-r--r--content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc2
-rw-r--r--content/browser/trace_message_filter.cc25
-rw-r--r--content/common/DEPS1
-rw-r--r--content/common/child_process_messages.h38
-rw-r--r--content/common/child_thread.cc5
-rw-r--r--content/components/tracing/DEPS9
-rw-r--r--content/components/tracing/OWNERS2
-rw-r--r--content/components/tracing/child_trace_message_filter.cc (renamed from content/common/child_trace_message_filter.cc)54
-rw-r--r--content/components/tracing/child_trace_message_filter.h (renamed from content/common/child_trace_message_filter.h)22
-rw-r--r--content/components/tracing/tracing_messages.cc34
-rw-r--r--content/components/tracing/tracing_messages.h56
-rw-r--r--content/content_common.gypi3
-rw-r--r--content/content_components_tracing.gyp27
-rw-r--r--content/content_components_tracing_untrusted.gyp41
-rw-r--r--gpu/command_buffer/common/trace_event.h2
-rw-r--r--ipc/ipc_message_start.h1
-rw-r--r--ppapi/native_client/native_client.gyp9
-rw-r--r--ppapi/ppapi_ipc_proxy_untrusted.gyp1
-rw-r--r--ppapi/ppapi_ipc_untrusted.gyp1
-rw-r--r--ppapi/proxy/DEPS1
-rw-r--r--ppapi/proxy/plugin_main_nacl.cc3
24 files changed, 261 insertions, 89 deletions
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index 823acbe..6687218 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -627,7 +627,7 @@ int TraceLog::AddTraceEvent(char phase,
num_args, arg_names, arg_types, arg_values);
#endif
- TimeTicks now = TimeTicks::NowFromSystemTraceTime();
+ TimeTicks now = TimeTicks::NowFromSystemTraceTime() - time_offset_;
NotificationHelper notifier(this);
int ret_begin_id = -1;
{
@@ -804,5 +804,9 @@ void TraceLog::SetProcessID(int process_id) {
process_id_hash_ = (offset_basis ^ pid) * fnv_prime;
}
+void TraceLog::SetTimeOffset(TimeDelta offset) {
+ time_offset_ = offset;
+}
+
} // namespace debug
} // namespace base
diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h
index 33e782c..8ef4531 100644
--- a/base/debug/trace_event_impl.h
+++ b/base/debug/trace_event_impl.h
@@ -310,6 +310,10 @@ class BASE_EXPORT TraceLog {
void SetProcessID(int process_id);
+ // Allow setting an offset between the current TimeTicks time and the time
+ // that should be reported.
+ void SetTimeOffset(TimeDelta offset);
+
private:
// This allows constructor and destructor to be private and usable only
// by the Singleton class.
@@ -385,6 +389,8 @@ class BASE_EXPORT TraceLog {
int process_id_;
+ TimeDelta time_offset_;
+
// Allow tests to wake up when certain events occur.
const unsigned char* watch_category_;
std::string watch_event_name_;
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 32bbc89..8a06869 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+content/components/tracing",
"+content/gpu", # For gpu_info_collector.h and in-process GPU
"+content/port/browser",
"+content/public/browser",
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
index 4dcb18d..2b79f3b 100644
--- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
+++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
@@ -5,6 +5,7 @@
#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
#include "content/browser/renderer_host/pepper/pepper_message_filter.h"
+#include "content/browser/trace_message_filter.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "ipc/ipc_message_macros.h"
@@ -37,6 +38,7 @@ BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess(
render_process_id,
render_view_id));
channel->AddFilter(browser_ppapi_host->message_filter());
+ channel->AddFilter(new TraceMessageFilter());
return browser_ppapi_host;
}
diff --git a/content/browser/trace_message_filter.cc b/content/browser/trace_message_filter.cc
index 65bc842..a2586a1 100644
--- a/content/browser/trace_message_filter.cc
+++ b/content/browser/trace_message_filter.cc
@@ -5,7 +5,7 @@
#include "content/browser/trace_message_filter.h"
#include "content/browser/trace_controller_impl.h"
-#include "content/common/child_process_messages.h"
+#include "content/components/tracing/tracing_messages.h"
namespace content {
@@ -40,14 +40,14 @@ bool TraceMessageFilter::OnMessageReceived(const IPC::Message& message,
// Always on IO thread (BrowserMessageFilter guarantee).
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(TraceMessageFilter, message, *message_was_ok)
- IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildSupportsTracing,
+ IPC_MESSAGE_HANDLER(TracingHostMsg_ChildSupportsTracing,
OnChildSupportsTracing)
- IPC_MESSAGE_HANDLER(ChildProcessHostMsg_EndTracingAck, OnEndTracingAck)
- IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceDataCollected,
+ IPC_MESSAGE_HANDLER(TracingHostMsg_EndTracingAck, OnEndTracingAck)
+ IPC_MESSAGE_HANDLER(TracingHostMsg_TraceDataCollected,
OnTraceDataCollected)
- IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceNotification,
+ IPC_MESSAGE_HANDLER(TracingHostMsg_TraceNotification,
OnTraceNotification)
- IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceBufferPercentFullReply,
+ IPC_MESSAGE_HANDLER(TracingHostMsg_TraceBufferPercentFullReply,
OnTraceBufferPercentFullReply)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -58,31 +58,32 @@ void TraceMessageFilter::SendBeginTracing(
const std::vector<std::string>& included_categories,
const std::vector<std::string>& excluded_categories) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- Send(new ChildProcessMsg_BeginTracing(included_categories,
- excluded_categories));
+ Send(new TracingMsg_BeginTracing(included_categories,
+ excluded_categories,
+ base::TimeTicks::NowFromSystemTraceTime()));
}
void TraceMessageFilter::SendEndTracing() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!is_awaiting_end_ack_);
is_awaiting_end_ack_ = true;
- Send(new ChildProcessMsg_EndTracing);
+ Send(new TracingMsg_EndTracing);
}
void TraceMessageFilter::SendGetTraceBufferPercentFull() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!is_awaiting_buffer_percent_full_ack_);
is_awaiting_buffer_percent_full_ack_ = true;
- Send(new ChildProcessMsg_GetTraceBufferPercentFull);
+ Send(new TracingMsg_GetTraceBufferPercentFull);
}
void TraceMessageFilter::SendSetWatchEvent(const std::string& category_name,
const std::string& event_name) {
- Send(new ChildProcessMsg_SetWatchEvent(category_name, event_name));
+ Send(new TracingMsg_SetWatchEvent(category_name, event_name));
}
void TraceMessageFilter::SendCancelWatchEvent() {
- Send(new ChildProcessMsg_CancelWatchEvent);
+ Send(new TracingMsg_CancelWatchEvent);
}
TraceMessageFilter::~TraceMessageFilter() {}
diff --git a/content/common/DEPS b/content/common/DEPS
index 2d409fc..3a97cab 100644
--- a/content/common/DEPS
+++ b/content/common/DEPS
@@ -2,4 +2,5 @@ include_rules = [
"+cc",
"+media/base",
"+sandbox/linux/seccomp-legacy",
+ "+content/components/tracing",
]
diff --git a/content/common/child_process_messages.h b/content/common/child_process_messages.h
index 93c5578..0cf2a3a 100644
--- a/content/common/child_process_messages.h
+++ b/content/common/child_process_messages.h
@@ -72,25 +72,6 @@ IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled,
bool /* on or off */)
#endif
-// Sent to all child processes to enable trace event recording.
-IPC_MESSAGE_CONTROL2(ChildProcessMsg_BeginTracing,
- std::vector<std::string> /* included_categories */,
- std::vector<std::string> /* excluded_categories */)
-
-// Sent to all child processes to disable trace event recording.
-IPC_MESSAGE_CONTROL0(ChildProcessMsg_EndTracing)
-
-// Sent to all child processes to get trace buffer fullness.
-IPC_MESSAGE_CONTROL0(ChildProcessMsg_GetTraceBufferPercentFull)
-
-// Sent to all child processes to set watch event.
-IPC_MESSAGE_CONTROL2(ChildProcessMsg_SetWatchEvent,
- std::string /* category_name */,
- std::string /* event_name */)
-
-// Sent to all child processes to clear watch event.
-IPC_MESSAGE_CONTROL0(ChildProcessMsg_CancelWatchEvent)
-
// Tell the child process to enable or disable the profiler status.
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProfilerStatus,
tracked_objects::ThreadData::Status /* profiler status */)
@@ -117,25 +98,6 @@ IPC_MESSAGE_CONTROL0(ChildProcessMsg_GetTcmallocStats)
IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest)
-// Notify the browser that this child process supports tracing.
-IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ChildSupportsTracing)
-
-// Reply from child processes acking ChildProcessMsg_TraceChangeStatus(false).
-IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_EndTracingAck,
- std::vector<std::string> /* known_categories */)
-
-// Sent if the trace buffer becomes full.
-IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TraceNotification,
- int /* base::debug::TraceLog::Notification */)
-
-// Child processes send trace data back in JSON chunks.
-IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TraceDataCollected,
- std::string /*json trace data*/)
-
-// Reply to ChildProcessMsg_GetTraceBufferPercentFull.
-IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TraceBufferPercentFullReply,
- float /*trace buffer percent full*/)
-
// Send back profiler data (ThreadData in tracked_objects).
IPC_MESSAGE_CONTROL2(ChildProcessHostMsg_ChildProfilerData,
int, /* sequence_number */
diff --git a/content/common/child_thread.cc b/content/common/child_thread.cc
index 17e201d..8b1b000 100644
--- a/content/common/child_thread.cc
+++ b/content/common/child_thread.cc
@@ -14,11 +14,11 @@
#include "content/common/child_histogram_message_filter.h"
#include "content/common/child_process.h"
#include "content/common/child_process_messages.h"
-#include "content/common/child_trace_message_filter.h"
#include "content/common/fileapi/file_system_dispatcher.h"
#include "content/common/quota_dispatcher.h"
#include "content/common/resource_dispatcher.h"
#include "content/common/socket_stream_dispatcher.h"
+#include "content/components/tracing/child_trace_message_filter.h"
#include "content/public/common/content_switches.h"
#include "ipc/ipc_logging.h"
#include "ipc/ipc_switches.h"
@@ -115,7 +115,8 @@ void ChildThread::Init() {
channel_->AddFilter(histogram_message_filter_.get());
channel_->AddFilter(sync_message_filter_.get());
- channel_->AddFilter(new ChildTraceMessageFilter());
+ channel_->AddFilter(new ChildTraceMessageFilter(
+ ChildProcess::current()->io_message_loop_proxy()));
#if defined(OS_POSIX)
// Check that --process-type is specified so we don't do this in unit tests
diff --git a/content/components/tracing/DEPS b/content/components/tracing/DEPS
new file mode 100644
index 0000000..7330946
--- /dev/null
+++ b/content/components/tracing/DEPS
@@ -0,0 +1,9 @@
+include_rules = [
+ "+base",
+ "+ipc",
+
+ # This component will be compiled into NaCl, so it shouldn't depend on
+ # anything else in content.
+ "-content",
+ "+content/components/tracing",
+]
diff --git a/content/components/tracing/OWNERS b/content/components/tracing/OWNERS
new file mode 100644
index 0000000..ba7dc1b
--- /dev/null
+++ b/content/components/tracing/OWNERS
@@ -0,0 +1,2 @@
+jbauman@chromium.org
+nduca@chromium.org
diff --git a/content/common/child_trace_message_filter.cc b/content/components/tracing/child_trace_message_filter.cc
index d3f4341..453a976 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
diff --git a/content/common/child_trace_message_filter.h b/content/components/tracing/child_trace_message_filter.h
index 061a6eb..c6a72e2 100644
--- a/content/common/child_trace_message_filter.h
+++ b/content/components/tracing/child_trace_message_filter.h
@@ -2,21 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_COMMON_CHILD_TRACE_MESSAGE_FILTER_H_
-#define CONTENT_COMMON_CHILD_TRACE_MESSAGE_FILTER_H_
+#ifndef CONTENT_COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_
+#define CONTENT_COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_
-#include <string>
-
-#include "base/debug/trace_event.h"
-#include "base/process.h"
#include "ipc/ipc_channel_proxy.h"
+namespace base {
+class MessageLoopProxy;
+}
+
namespace content {
// This class sends and receives trace messages on child processes.
class ChildTraceMessageFilter : public IPC::ChannelProxy::MessageFilter {
public:
- ChildTraceMessageFilter();
+ explicit ChildTraceMessageFilter(base::MessageLoopProxy* ipc_message_loop);
// IPC::ChannelProxy::MessageFilter implementation.
virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
@@ -29,7 +29,8 @@ class ChildTraceMessageFilter : public IPC::ChannelProxy::MessageFilter {
private:
// Message handlers.
void 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);
void OnEndTracing();
void OnGetTraceBufferPercentFull();
void OnSetWatchEvent(const std::string& category_name,
@@ -42,10 +43,11 @@ class ChildTraceMessageFilter : public IPC::ChannelProxy::MessageFilter {
void OnTraceNotification(int notification);
IPC::Channel* channel_;
+ base::MessageLoopProxy* ipc_message_loop_;
DISALLOW_COPY_AND_ASSIGN(ChildTraceMessageFilter);
};
-} // namespace content
+} // namespace content
-#endif // CONTENT_COMMON_CHILD_TRACE_MESSAGE_FILTER_H_
+#endif // CONTENT_COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_
diff --git a/content/components/tracing/tracing_messages.cc b/content/components/tracing/tracing_messages.cc
new file mode 100644
index 0000000..df41fad
--- /dev/null
+++ b/content/components/tracing/tracing_messages.cc
@@ -0,0 +1,34 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Get basic type definitions.
+#define IPC_MESSAGE_IMPL
+#include "content/components/tracing/tracing_messages.h"
+
+// Generate constructors.
+#include "ipc/struct_constructor_macros.h"
+#include "content/components/tracing/tracing_messages.h"
+
+// Generate destructors.
+#include "ipc/struct_destructor_macros.h"
+#include "content/components/tracing/tracing_messages.h"
+
+// Generate param traits write methods.
+#include "ipc/param_traits_write_macros.h"
+namespace IPC {
+#include "content/components/tracing/tracing_messages.h"
+} // namespace IPC
+
+// Generate param traits read methods.
+#include "ipc/param_traits_read_macros.h"
+namespace IPC {
+#include "content/components/tracing/tracing_messages.h"
+} // namespace IPC
+
+// Generate param traits log methods.
+#include "ipc/param_traits_log_macros.h"
+namespace IPC {
+#include "content/components/tracing/tracing_messages.h"
+} // namespace IPC
+
diff --git a/content/components/tracing/tracing_messages.h b/content/components/tracing/tracing_messages.h
new file mode 100644
index 0000000..792c476
--- /dev/null
+++ b/content/components/tracing/tracing_messages.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Multiply-included message header, no traditional include guard.
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/sync_socket.h"
+#include "ipc/ipc_channel_handle.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_message_utils.h"
+#include "ipc/ipc_platform_file.h"
+
+#define IPC_MESSAGE_START TracingMsgStart
+
+// Sent to all child processes to enable trace event recording.
+IPC_MESSAGE_CONTROL3(TracingMsg_BeginTracing,
+ std::vector<std::string> /* included_categories */,
+ std::vector<std::string> /* excluded_categories */,
+ base::TimeTicks /* browser_time */)
+
+// Sent to all child processes to disable trace event recording.
+IPC_MESSAGE_CONTROL0(TracingMsg_EndTracing)
+
+// Sent to all child processes to get trace buffer fullness.
+IPC_MESSAGE_CONTROL0(TracingMsg_GetTraceBufferPercentFull)
+
+// Sent to all child processes to set watch event.
+IPC_MESSAGE_CONTROL2(TracingMsg_SetWatchEvent,
+ std::string /* category_name */,
+ std::string /* event_name */)
+
+// Sent to all child processes to clear watch event.
+IPC_MESSAGE_CONTROL0(TracingMsg_CancelWatchEvent)
+
+// Notify the browser that this child process supports tracing.
+IPC_MESSAGE_CONTROL0(TracingHostMsg_ChildSupportsTracing)
+
+// Reply from child processes acking ChildProcessMsg_TraceChangeStatus(false).
+IPC_MESSAGE_CONTROL1(TracingHostMsg_EndTracingAck,
+ std::vector<std::string> /* known_categories */)
+
+// Sent if the trace buffer becomes full.
+IPC_MESSAGE_CONTROL1(TracingHostMsg_TraceNotification,
+ int /* base::debug::TraceLog::Notification */)
+
+// Child processes send trace data back in JSON chunks.
+IPC_MESSAGE_CONTROL1(TracingHostMsg_TraceDataCollected,
+ std::string /*json trace data*/)
+
+// Reply to TracingMsg_GetTraceBufferPercentFull.
+IPC_MESSAGE_CONTROL1(TracingHostMsg_TraceBufferPercentFullReply,
+ float /*trace buffer percent full*/)
+
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 3a7f550..3f74f0b 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -12,6 +12,7 @@
'../third_party/icu/icu.gyp:icuuc',
'../ui/ui.gyp:ui',
'../webkit/support/webkit_support.gyp:user_agent',
+ 'content_components_tracing.gyp:tracing',
],
'include_dirs': [
'..',
@@ -140,8 +141,6 @@
'common/child_process_sandbox_support_impl_shm_linux.cc',
'common/child_thread.cc',
'common/child_thread.h',
- 'common/child_trace_message_filter.cc',
- 'common/child_trace_message_filter.h',
'common/clipboard_messages.cc',
'common/clipboard_messages.h',
'common/content_constants_internal.cc',
diff --git a/content/content_components_tracing.gyp b/content/content_components_tracing.gyp
new file mode 100644
index 0000000..c9537b1
--- /dev/null
+++ b/content/content_components_tracing.gyp
@@ -0,0 +1,27 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets' : [
+ {
+ 'target_name': 'tracing',
+ 'type': 'static_library',
+ 'defines!': ['CONTENT_IMPLEMENTATION'],
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../ipc/ipc.gyp:ipc',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'components/tracing/child_trace_message_filter.cc',
+ 'components/tracing/child_trace_message_filter.h',
+ 'components/tracing/tracing_messages.cc',
+ 'components/tracing/tracing_messages.h',
+ ],
+ },
+ ],
+}
diff --git a/content/content_components_tracing_untrusted.gyp b/content/content_components_tracing_untrusted.gyp
new file mode 100644
index 0000000..701d9f3
--- /dev/null
+++ b/content/content_components_tracing_untrusted.gyp
@@ -0,0 +1,41 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'includes': [
+ '../build/common_untrusted.gypi',
+ ],
+ 'conditions': [
+ ['disable_nacl==0 and disable_nacl_untrusted==0', {
+ 'targets': [
+ {
+ 'target_name': 'tracing_untrusted',
+ 'type': 'none',
+ 'defines!': ['CONTENT_IMPLEMENTATION'],
+ 'dependencies': [
+ '../base/base_untrusted.gyp:base_untrusted',
+ '../native_client/tools.gyp:prep_toolchain',
+ '../ipc/ipc.gyp:ipc',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'variables': {
+ 'nacl_untrusted_build': 1,
+ 'nlib_target': 'libtracing_untrusted.a',
+ 'build_glibc': 0,
+ 'build_newlib': 1,
+ },
+ 'sources': [
+ 'components/tracing/child_trace_message_filter.cc',
+ 'components/tracing/child_trace_message_filter.h',
+ 'components/tracing/tracing_messages.cc',
+ 'components/tracing/tracing_messages.h',
+ ],
+ },
+ ],
+ }],
+ ],
+}
diff --git a/gpu/command_buffer/common/trace_event.h b/gpu/command_buffer/common/trace_event.h
index 2c727ba..cd1ab26 100644
--- a/gpu/command_buffer/common/trace_event.h
+++ b/gpu/command_buffer/common/trace_event.h
@@ -5,7 +5,7 @@
#ifndef GPU_COMMAND_BUFFER_COMMON_TRACE_EVENT_H_
#define GPU_COMMAND_BUFFER_COMMON_TRACE_EVENT_H_
-#if !defined(__native_client__)
+#if defined(NACL_PPAPI_IPC_PROXY) || !defined(__native_client__)
#include "base/debug/trace_event.h"
diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h
index 2db6616..baaebf6 100644
--- a/ipc/ipc_message_start.h
+++ b/ipc/ipc_message_start.h
@@ -71,6 +71,7 @@ enum IPCMessageStart {
MetroViewerMsgStart,
CCMsgStart,
MediaPlayerMsgStart,
+ TracingMsgStart,
LastIPCMsgStart // Must come last.
};
diff --git a/ppapi/native_client/native_client.gyp b/ppapi/native_client/native_client.gyp
index b2aaaee..19bc4f7 100644
--- a/ppapi/native_client/native_client.gyp
+++ b/ppapi/native_client/native_client.gyp
@@ -247,6 +247,7 @@
'-lgles2_utils_untrusted',
'-lcommand_buffer_client_untrusted',
'-lcommand_buffer_common_untrusted',
+ '-ltracing_untrusted',
'-lgpu_ipc_untrusted',
'-lipc_untrusted',
'-lbase_untrusted',
@@ -305,6 +306,7 @@
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libcommand_buffer_client_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libcommand_buffer_common_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgpu_ipc_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libtracing_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgles2_cmd_helper_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgles2_utils_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libipc_untrusted.a',
@@ -324,6 +326,7 @@
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libcommand_buffer_client_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libcommand_buffer_common_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgpu_ipc_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libtracing_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgles2_cmd_helper_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgles2_utils_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libipc_untrusted.a',
@@ -343,6 +346,7 @@
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libcommand_buffer_client_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libcommand_buffer_common_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgpu_ipc_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libtracing_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgles2_cmd_helper_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libgles2_utils_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib64/libipc_untrusted.a',
@@ -362,6 +366,7 @@
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libcommand_buffer_client_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libcommand_buffer_common_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgpu_ipc_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libtracing_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgles2_cmd_helper_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libgles2_utils_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/lib32/libipc_untrusted.a',
@@ -381,6 +386,7 @@
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libcommand_buffer_client_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libcommand_buffer_common_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libgpu_ipc_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libtracing_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libgles2_cmd_helper_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libgles2_utils_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib64/libipc_untrusted.a',
@@ -400,6 +406,7 @@
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libcommand_buffer_client_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libcommand_buffer_common_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libgpu_ipc_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libtracing_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libgles2_cmd_helper_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libgles2_utils_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_glibc/lib32/libipc_untrusted.a',
@@ -419,6 +426,7 @@
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libcommand_buffer_client_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libcommand_buffer_common_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libgpu_ipc_untrusted.a',
+ '<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libtracing_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libgles2_cmd_helper_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libgles2_utils_untrusted.a',
'<(SHARED_INTERMEDIATE_DIR)/tc_newlib/libarm/libipc_untrusted.a',
@@ -441,6 +449,7 @@
'../../gpu/gpu_untrusted.gyp:gles2_implementation_untrusted',
'../../gpu/gpu_untrusted.gyp:gles2_cmd_helper_untrusted',
'../../gpu/gpu_untrusted.gyp:gpu_ipc_untrusted',
+ '../../content/content_components_tracing_untrusted.gyp:tracing_untrusted',
'../../ipc/ipc_untrusted.gyp:ipc_untrusted',
'../../base/base_untrusted.gyp:base_untrusted',
'../../media/media_untrusted.gyp:shared_memory_support_untrusted',
diff --git a/ppapi/ppapi_ipc_proxy_untrusted.gyp b/ppapi/ppapi_ipc_proxy_untrusted.gyp
index 781c086..ea9d8d2 100644
--- a/ppapi/ppapi_ipc_proxy_untrusted.gyp
+++ b/ppapi/ppapi_ipc_proxy_untrusted.gyp
@@ -50,6 +50,7 @@
'../ppapi/ppapi_shared_untrusted.gyp:ppapi_shared_untrusted',
'../ppapi/ppapi_ipc_untrusted.gyp:ppapi_ipc_untrusted',
'../third_party/khronos/khronos.gyp:khronos_headers',
+ '../content/content_components_tracing_untrusted.gyp:tracing_untrusted',
],
},
],
diff --git a/ppapi/ppapi_ipc_untrusted.gyp b/ppapi/ppapi_ipc_untrusted.gyp
index 1f5c3c9..2e1382f 100644
--- a/ppapi/ppapi_ipc_untrusted.gyp
+++ b/ppapi/ppapi_ipc_untrusted.gyp
@@ -39,6 +39,7 @@
'../gpu/gpu_untrusted.gyp:gpu_ipc_untrusted',
'../ipc/ipc_untrusted.gyp:ipc_untrusted',
'../ppapi/ppapi_shared_untrusted.gyp:ppapi_shared_untrusted',
+ '../content/content_components_tracing_untrusted.gyp:tracing_untrusted',
],
},
],
diff --git a/ppapi/proxy/DEPS b/ppapi/proxy/DEPS
index 1a3c174..ded8bf6 100644
--- a/ppapi/proxy/DEPS
+++ b/ppapi/proxy/DEPS
@@ -5,6 +5,7 @@ include_rules = [
"+media/audio",
"+skia",
"+ui/surface",
+ "+content/components/tracing",
# We don't want the proxy to depend on the C++ layer, which is appropriate
# for plugins only. However, the completion callback factory is a very useful
diff --git a/ppapi/proxy/plugin_main_nacl.cc b/ppapi/proxy/plugin_main_nacl.cc
index 0fd689b..d3886f6 100644
--- a/ppapi/proxy/plugin_main_nacl.cc
+++ b/ppapi/proxy/plugin_main_nacl.cc
@@ -14,6 +14,7 @@
#include "base/message_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
+#include "content/components/tracing/child_trace_message_filter.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_logging.h"
#include "ipc/ipc_message.h"
@@ -104,6 +105,8 @@ PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop)
IPC::ChannelHandle channel_handle(
"NaCl IPC", base::FileDescriptor(NACL_IPC_FD, false));
InitWithChannel(this, channel_handle, false); // Channel is server.
+ channel()->AddFilter(
+ new content::ChildTraceMessageFilter(message_loop_));
}
base::MessageLoopProxy* PpapiDispatcher::GetIPCMessageLoop() {