summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorelijahtaylor@chromium.org <elijahtaylor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-28 18:46:24 +0000
committerelijahtaylor@chromium.org <elijahtaylor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-28 18:46:24 +0000
commit9e10e04469b019f854ac6d3606819354e671b6c9 (patch)
treeacc97eee82f1376cb981ed11132c2cc1a13e0453 /ppapi
parent99162f6565bb19ce54cb4b1f188b1d06bcaade3c (diff)
downloadchromium_src-9e10e04469b019f854ac6d3606819354e671b6c9.zip
chromium_src-9e10e04469b019f854ac6d3606819354e671b6c9.tar.gz
chromium_src-9e10e04469b019f854ac6d3606819354e671b6c9.tar.bz2
Reland: Add trace event Pepper API
This facilitates adding trace data to chrome://tracing from plugins. - broke out trace_event.h into trace_event.h/trace_event_internal.h for easier transplanting to plugin code by eliminating dependence on base/. - inlined trace_event.cc methods (4 total) so the trace_event_internal implementation is contained in headers. - added new PPB_TraceEvent_Dev interface (implemented entirely on the plugin side) BUG=93839 TEST=base_unittests, manual for plugin testing Review URL: https://chromiumcodereview.appspot.com/12047066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179171 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/dev/ppb_trace_event_dev.idl50
-rw-r--r--ppapi/c/dev/ppb_trace_event_dev.h68
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c13
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/shared_impl/ppb_instance_shared.cc2
-rw-r--r--ppapi/shared_impl/ppb_trace_event_impl.cc74
-rw-r--r--ppapi/shared_impl/ppb_trace_event_impl.h35
-rw-r--r--ppapi/tests/all_c_includes.h5
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev.h2
10 files changed, 250 insertions, 2 deletions
diff --git a/ppapi/api/dev/ppb_trace_event_dev.idl b/ppapi/api/dev/ppb_trace_event_dev.idl
new file mode 100644
index 0000000..ff01dea
--- /dev/null
+++ b/ppapi/api/dev/ppb_trace_event_dev.idl
@@ -0,0 +1,50 @@
+/* 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.
+ */
+
+/**
+ * This file defines the <code>PPB_Trace_Event</code> interface. It is meant
+ * to be used in plugins as the API that trace macros from trace_event.h use.
+ */
+
+label Chrome {
+ M25 = 0.1
+};
+
+interface PPB_Trace_Event_Dev {
+ /**
+ * Gets a pointer to a character for identifying a category name in the
+ * tracing system as well as for being able to early exit in client-side
+ * tracing code.
+ *
+ * NB: This mem_t return value should technically be const, but return values
+ * for Pepper IDL of mem_t type are not const. The same is true for the arg
+ * |category_enabled| for AddTraceEvent.
+ */
+ mem_t GetCategoryEnabled([in] cstr_t category_name);
+
+ /**
+ * Adds a trace event to the platform tracing system. This function call is
+ * usually the result of a TRACE_* macro from trace_event.h when tracing and
+ * the category of the particular trace are enabled. It is not advisable to
+ * call this function on its own; it is really only meant to be used by the
+ * trace macros.
+ */
+ void AddTraceEvent(
+ [in] int8_t phase,
+ [in] mem_t category_enabled,
+ [in] cstr_t name,
+ [in] uint64_t id,
+ [in] uint32_t num_args,
+ [in, size_as=num_args] str_t[] arg_names,
+ [in, size_as=num_args] uint8_t[] arg_types,
+ [in, size_as=num_args] uint64_t[] arg_values,
+ [in] uint8_t flags);
+
+ /**
+ * Sets the thread name of the calling thread in the tracing system so it will
+ * show up properly in chrome://tracing.
+ */
+ void SetThreadName([in] cstr_t thread_name);
+};
diff --git a/ppapi/c/dev/ppb_trace_event_dev.h b/ppapi/c/dev/ppb_trace_event_dev.h
new file mode 100644
index 0000000..153fca8
--- /dev/null
+++ b/ppapi/c/dev/ppb_trace_event_dev.h
@@ -0,0 +1,68 @@
+/* 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.
+ */
+
+/* From dev/ppb_trace_event_dev.idl modified Wed Jan 2 16:11:35 2013. */
+
+#ifndef PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_
+#define PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_
+
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_stdint.h"
+
+#define PPB_TRACE_EVENT_DEV_INTERFACE_0_1 "PPB_Trace_Event(Dev);0.1"
+#define PPB_TRACE_EVENT_DEV_INTERFACE PPB_TRACE_EVENT_DEV_INTERFACE_0_1
+
+/**
+ * @file
+ * This file defines the <code>PPB_Trace_Event</code> interface. It is meant
+ * to be used in plugins as the API that trace macros from trace_event.h use.
+ */
+
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+struct PPB_Trace_Event_Dev_0_1 {
+ /**
+ * Gets a pointer to a character for identifying a category name in the
+ * tracing system as well as for being able to early exit in client-side
+ * tracing code.
+ *
+ * NB: This mem_t return value should technically be const, but return values
+ * for Pepper IDL of mem_t type are not const. The same is true for the arg
+ * |category_enabled| for AddTraceEvent.
+ */
+ void* (*GetCategoryEnabled)(const char* category_name);
+ /**
+ * Adds a trace event to the platform tracing system. This function call is
+ * usually the result of a TRACE_* macro from trace_event.h when tracing and
+ * the category of the particular trace are enabled. It is not advisable to
+ * call this function on its own; it is really only meant to be used by the
+ * trace macros.
+ */
+ void (*AddTraceEvent)(int8_t phase,
+ const void* category_enabled,
+ const char* name,
+ uint64_t id,
+ uint32_t num_args,
+ const char* arg_names[],
+ const uint8_t arg_types[],
+ const uint64_t arg_values[],
+ uint8_t flags);
+ /**
+ * Sets the thread name of the calling thread in the tracing system so it will
+ * show up properly in chrome://tracing.
+ */
+ void (*SetThreadName)(const char* thread_name);
+};
+
+typedef struct PPB_Trace_Event_Dev_0_1 PPB_Trace_Event_Dev;
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_ */
+
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index c1a4bb9..036d9c6 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -25,6 +25,7 @@
#include "ppapi/c/dev/ppb_scrollbar_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_text_input_dev.h"
+#include "ppapi/c/dev/ppb_trace_event_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppb_video_capture_dev.h"
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
@@ -196,6 +197,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_9;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_91;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInput_Dev_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInput_Dev_0_2;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Trace_Event_Dev_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3;
@@ -1976,6 +1978,8 @@ uint32_t Pnacl_M18_PPB_Testing_Dev_GetLiveVars(struct PP_Var live_vars[], uint32
/* Not generating wrapper methods for PPB_TextInput_Dev_0_2 */
+/* Not generating wrapper methods for PPB_Trace_Event_Dev_0_1 */
+
/* Begin wrapper methods for PPB_URLUtil_Dev_0_6 */
static __attribute__((pnaclcall))
@@ -3969,6 +3973,8 @@ struct PPB_Testing_Dev_0_91 Pnacl_Wrappers_PPB_Testing_Dev_0_91 = {
/* Not generating wrapper interface for PPB_TextInput_Dev_0_2 */
+/* Not generating wrapper interface for PPB_Trace_Event_Dev_0_1 */
+
struct PPB_URLUtil_Dev_0_6 Pnacl_Wrappers_PPB_URLUtil_Dev_0_6 = {
.Canonicalize = (struct PP_Var (*)(struct PP_Var url, struct PP_URLComponents_Dev* components))&Pnacl_M17_PPB_URLUtil_Dev_Canonicalize,
.ResolveRelativeToURL = (struct PP_Var (*)(struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev* components))&Pnacl_M17_PPB_URLUtil_Dev_ResolveRelativeToURL,
@@ -4807,6 +4813,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInput_Dev_0_2 = {
.real_iface = NULL
};
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Trace_Event_Dev_0_1 = {
+ .iface_macro = PPB_TRACE_EVENT_DEV_INTERFACE_0_1,
+ .wrapped_iface = NULL /* Still need slot for real_iface */,
+ .real_iface = NULL
+};
+
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6 = {
.iface_macro = PPB_URLUTIL_DEV_INTERFACE_0_6,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_URLUtil_Dev_0_6,
@@ -5227,6 +5239,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_Testing_Dev_0_91,
&Pnacl_WrapperInfo_PPB_TextInput_Dev_0_1,
&Pnacl_WrapperInfo_PPB_TextInput_Dev_0_2,
+ &Pnacl_WrapperInfo_PPB_Trace_Event_Dev_0_1,
&Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6,
&Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2,
&Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3,
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 54a042a..ce190cd 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -74,6 +74,8 @@
'shared_impl/ppb_opengles2_shared.h',
'shared_impl/ppb_resource_array_shared.cc',
'shared_impl/ppb_resource_array_shared.h',
+ 'shared_impl/ppb_trace_event_impl.cc',
+ 'shared_impl/ppb_trace_event_impl.h',
'shared_impl/ppb_url_util_shared.cc',
'shared_impl/ppb_url_util_shared.h',
'shared_impl/ppb_var_shared.cc',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index a0d34c1..ef3d84a 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -23,6 +23,7 @@
#include "ppapi/c/dev/ppb_resource_array_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_text_input_dev.h"
+#include "ppapi/c/dev/ppb_trace_event_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppb_video_capture_dev.h"
diff --git a/ppapi/shared_impl/ppb_instance_shared.cc b/ppapi/shared_impl/ppb_instance_shared.cc
index 8101de6..18033fc 100644
--- a/ppapi/shared_impl/ppb_instance_shared.cc
+++ b/ppapi/shared_impl/ppb_instance_shared.cc
@@ -6,6 +6,8 @@
#include <string>
+#include "base/debug/trace_event.h"
+#include "base/threading/platform_thread.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/shared_impl/ppapi_globals.h"
diff --git a/ppapi/shared_impl/ppb_trace_event_impl.cc b/ppapi/shared_impl/ppb_trace_event_impl.cc
new file mode 100644
index 0000000..439bbd44
--- /dev/null
+++ b/ppapi/shared_impl/ppb_trace_event_impl.cc
@@ -0,0 +1,74 @@
+// 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.
+
+#include "ppapi/shared_impl/ppb_trace_event_impl.h"
+
+#include "base/debug/trace_event.h"
+#include "ppapi/thunk/thunk.h"
+
+
+namespace ppapi {
+
+// PPB_Trace_Event_Dev is a shared implementation because Trace Events can be
+// sent from either the plugin process or renderer process depending on whether
+// the plugin is in- or out-of-process. Also, for NaCl plugins these functions
+// will be executed from untrusted code and handled appropriately by tracing
+// functionality in the IRT.
+
+// static
+void* TraceEventImpl::GetCategoryEnabled(const char* category_name) {
+ // This casting is here because all mem_t return types in Pepper are void* and
+ // non-const. All mem_t parameters are const void* so there is no way to
+ // return a pointer type to the caller without some const_cast. The pointer
+ // type the tracing system works with is normally unsigned char*.
+ return const_cast<void*>(static_cast<const void*>(
+ base::debug::TraceLog::GetInstance()->GetCategoryEnabled(category_name)));
+}
+
+// static
+void TraceEventImpl::AddTraceEvent(int8_t phase,
+ const void* category_enabled,
+ const char* name,
+ uint64_t id,
+ uint32_t num_args,
+ const char* arg_names[],
+ const uint8_t arg_types[],
+ const uint64_t arg_values[],
+ uint8_t flags) {
+ base::debug::TraceLog::GetInstance()->AddTraceEvent(phase,
+ static_cast<const unsigned char*>(category_enabled), name, id, num_args,
+ arg_names, arg_types,
+ // This cast is necessary for LP64 systems, where uint64_t is defined as
+ // an unsigned long int, but trace_event internals are hermetic and
+ // accepts an |unsigned long long*|. The pointer types are compatible but
+ // the compiler throws an error without an explicit cast.
+ reinterpret_cast<const unsigned long long*>(arg_values), flags);
+}
+
+// static
+void TraceEventImpl::SetThreadName(const char* thread_name) {
+ base::PlatformThread::SetName(thread_name);
+}
+
+namespace {
+
+const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = {
+ &TraceEventImpl::GetCategoryEnabled,
+ &TraceEventImpl::AddTraceEvent,
+ &TraceEventImpl::SetThreadName,
+};
+
+} // namespace ppapi
+
+} // namespace
+
+namespace ppapi {
+namespace thunk {
+
+const PPB_Trace_Event_Dev_0_1* GetPPB_Trace_Event_Dev_0_1_Thunk() {
+ return &g_ppb_trace_event_thunk;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_trace_event_impl.h b/ppapi/shared_impl/ppb_trace_event_impl.h
new file mode 100644
index 0000000..21a77ac
--- /dev/null
+++ b/ppapi/shared_impl/ppb_trace_event_impl.h
@@ -0,0 +1,35 @@
+// 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.
+
+#ifndef PPAPI_SHARED_IMPL_PPB_TRACE_EVENT_IMPL_H_
+#define PPAPI_SHARED_IMPL_PPB_TRACE_EVENT_IMPL_H_
+
+#include "ppapi/c/dev/ppb_trace_event_dev.h"
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+
+namespace ppapi {
+
+// Contains the implementation of the PPB_Trace_Event_Dev functions. Since these
+// functions are to be run from whatever plugin process/thread in which they
+// originated, the implementation lives in shared_impl.
+//
+class PPAPI_SHARED_EXPORT TraceEventImpl {
+ public:
+ static void* GetCategoryEnabled(const char* category_name);
+ static void AddTraceEvent(int8_t phase,
+ const void* category_enabled,
+ const char* name,
+ uint64_t id,
+ uint32_t num_args,
+ const char* arg_names[],
+ const uint8_t arg_types[],
+ const uint64_t arg_values[],
+ uint8_t flags);
+ static void SetThreadName(const char* thread_name);
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PPB_TRACE_EVENT_IMPL_H_
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index 3dd64ab..0ab547f 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -28,9 +28,11 @@
#include "ppapi/c/dev/ppb_scrollbar_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_text_input_dev.h"
+#include "ppapi/c/dev/ppb_trace_event_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
+#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/dev/ppb_widget_dev.h"
#include "ppapi/c/dev/ppb_zoom_dev.h"
#include "ppapi/c/dev/ppp_class_deprecated.h"
@@ -40,7 +42,6 @@
#include "ppapi/c/dev/ppp_selection_dev.h"
#include "ppapi/c/dev/ppp_text_input_dev.h"
#include "ppapi/c/dev/ppp_video_decoder_dev.h"
-#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/dev/ppp_widget_dev.h"
#include "ppapi/c/dev/ppp_zoom_dev.h"
#include "ppapi/c/pp_bool.h"
@@ -108,8 +109,8 @@
#include "ppapi/c/private/ppb_udp_socket_private.h"
#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/c/private/ppb_x509_certificate_private.h"
-#include "ppapi/c/private/ppp_instance_private.h"
#include "ppapi/c/private/ppp_content_decryptor_private.h"
+#include "ppapi/c/private/ppp_instance_private.h"
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/c/trusted/ppb_file_io_trusted.h"
#include "ppapi/c/trusted/ppb_graphics_3d_trusted.h"
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h
index 24c1642..3bd6e56 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -31,6 +31,8 @@ PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_2,
PROXIED_IFACE(NoAPIName, PPB_VIEW_DEV_INTERFACE_0_1,
PPB_View_Dev_0_1)
UNPROXIED_IFACE(PPB_Instance, PPB_ZOOM_DEV_INTERFACE_0_2, PPB_Zoom_Dev_0_2)
+PROXIED_IFACE(PPB_Instance, PPB_TRACE_EVENT_DEV_INTERFACE_0_1,
+ PPB_Trace_Event_Dev_0_1)
#if !defined(OS_NACL)
PROXIED_API(PPB_Buffer)