Chromium Code Reviews| Index: ppapi/shared_impl/ppb_trace_event_impl.cc |
| diff --git a/ppapi/shared_impl/ppb_trace_event_impl.cc b/ppapi/shared_impl/ppb_trace_event_impl.cc |
| index 6803fc6d36d8b30f676d98a12c519193dfda71c4..26ebb47c436d7b4acdcdf5c50e9c86618fe6362f 100644 |
| --- a/ppapi/shared_impl/ppb_trace_event_impl.cc |
| +++ b/ppapi/shared_impl/ppb_trace_event_impl.cc |
| @@ -4,6 +4,7 @@ |
| #include "ppapi/shared_impl/ppb_trace_event_impl.h" |
| +#include "base/basictypes.h" |
| #include "base/debug/trace_event.h" |
| #include "ppapi/thunk/thunk.h" |
| @@ -28,15 +29,19 @@ void* TraceEventImpl::GetCategoryEnabled(const char* 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) { |
| +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) { |
| + |
| + COMPILE_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t), msg); |
| + |
| base::debug::TraceLog::GetInstance()->AddTraceEvent(phase, |
| static_cast<const unsigned char*>(category_enabled), name, id, num_args, |
| arg_names, arg_types, |
| @@ -48,15 +53,54 @@ void TraceEventImpl::AddTraceEvent(int8_t phase, |
| } |
| // static |
| +void TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp( |
| + int8_t phase, |
| + const void* category_enabled, |
| + const char* name, |
| + uint64_t id, |
| + int32_t thread_id, |
| + int64_t timestamp, |
| + 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()->AddTraceEventWithThreadIdAndTimestamp( |
| + phase, |
| + static_cast<const unsigned char*>(category_enabled), name, id, |
| + thread_id, |
| + base::TimeTicks::FromInternalValue(timestamp), |
| + 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), NULL, flags); |
| +} |
| + |
| +// static |
| +int64_t TraceEventImpl::Now() { |
| + return base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); |
| +} |
| + |
| +// static |
| void TraceEventImpl::SetThreadName(const char* thread_name) { |
| base::PlatformThread::SetName(thread_name); |
| } |
| namespace { |
| +const PPB_Trace_Event_Dev_0_1 g_ppb_trace_event_thunk_0_1 = { |
| + &TraceEventImpl::GetCategoryEnabled, |
| + &TraceEventImpl::AddTraceEvent, |
| + &TraceEventImpl::SetThreadName, |
| +}; |
| + |
| const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = { |
|
dmichael (off chromium)
2013/06/25 22:19:27
Please use the versioned struct (PPB_Trace_Event_D
grosse
2013/06/25 23:16:39
Done.
|
| &TraceEventImpl::GetCategoryEnabled, |
| &TraceEventImpl::AddTraceEvent, |
| + &TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp, |
| + &TraceEventImpl::Now, |
| &TraceEventImpl::SetThreadName, |
| }; |
| @@ -68,6 +112,10 @@ namespace ppapi { |
| namespace thunk { |
| const PPB_Trace_Event_Dev_0_1* GetPPB_Trace_Event_Dev_0_1_Thunk() { |
| + return &g_ppb_trace_event_thunk_0_1; |
| +} |
| + |
| +const PPB_Trace_Event_Dev_0_2* GetPPB_Trace_Event_Dev_0_2_Thunk() { |
| return &g_ppb_trace_event_thunk; |
| } |