Index: ppapi/shared_impl/ppb_instance_shared.cc |
diff --git a/ppapi/shared_impl/ppb_instance_shared.cc b/ppapi/shared_impl/ppb_instance_shared.cc |
index dd46bec3a70d849c4741c020eac0051f8cf6b37e..35307536bf258baa18523e0e3e5b7da8f5b95219 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" |
@@ -58,6 +60,45 @@ int32_t PPB_Instance_Shared::ValidateRequestInputEvents( |
return PP_OK; |
} |
+// PPB_Trace_Events 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. This will not currently work in NaCl |
+// because this code assumes we are in a chrome process space at this point. In |
+// order to make it work in NaCl, we will probably need some proxy-side |
+// management to make this work quickly without requiring IPCs for every call, |
jbauman
2012/12/14 00:36:07
This isn't true anymore.
elijahtaylor1
2012/12/18 20:40:31
Done.
|
+// and possibly a small re-write to the API. |
+void* PPB_Instance_Shared::GetCategoryEnabled(PP_Instance instance, |
+ 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*>(reinterpret_cast<const void*>( |
+ base::debug::TraceLog::GetInstance()->GetCategoryEnabled(category_name))); |
+} |
+ |
+int32_t PPB_Instance_Shared::AddTraceEvent(PP_Instance instance, |
+ 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[], |
+ int32_t threshold_begin_id, |
+ int64_t threshold, |
+ uint8_t flags) { |
+ return base::debug::TraceLog::GetInstance()->AddTraceEvent(phase, |
+ (const unsigned char*)category_enabled, name, id, num_args, arg_names, |
+ arg_types, arg_values, threshold_begin_id, threshold, flags); |
+} |
+ |
+void PPB_Instance_Shared::SetThreadName(PP_Instance instance, |
+ const char* thread_name) { |
+ base::PlatformThread::SetName(thread_name); |
+} |
+ |
bool PPB_Instance_Shared::ValidateSetCursorParams(PP_MouseCursor_Type type, |
PP_Resource image, |
const PP_Point* hot_spot) { |