Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/shared_impl/ppb_trace_event_impl.h" | 5 #include "ppapi/shared_impl/ppb_trace_event_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "ppapi/thunk/thunk.h" | 8 #include "ppapi/thunk/thunk.h" |
| 9 | 9 |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 // This casting is here because all mem_t return types in Pepper are void* and | 21 // This casting is here because all mem_t return types in Pepper are void* and |
| 22 // non-const. All mem_t parameters are const void* so there is no way to | 22 // non-const. All mem_t parameters are const void* so there is no way to |
| 23 // return a pointer type to the caller without some const_cast. The pointer | 23 // return a pointer type to the caller without some const_cast. The pointer |
| 24 // type the tracing system works with is normally unsigned char*. | 24 // type the tracing system works with is normally unsigned char*. |
| 25 return const_cast<void*>(static_cast<const void*>( | 25 return const_cast<void*>(static_cast<const void*>( |
| 26 base::debug::TraceLog::GetInstance()->GetCategoryGroupEnabled( | 26 base::debug::TraceLog::GetInstance()->GetCategoryGroupEnabled( |
| 27 category_name))); | 27 category_name))); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 void TraceEventImpl::AddTraceEvent(int8_t phase, | 31 void TraceEventImpl::AddTraceEvent( |
| 32 const void* category_enabled, | 32 int8_t phase, |
| 33 const char* name, | 33 const void* category_enabled, |
| 34 uint64_t id, | 34 const char* name, |
| 35 uint32_t num_args, | 35 uint64_t id, |
| 36 const char* arg_names[], | 36 uint32_t num_args, |
| 37 const uint8_t arg_types[], | 37 const char* arg_names[], |
| 38 const uint64_t arg_values[], | 38 const uint8_t arg_types[], |
| 39 uint8_t flags) { | 39 const uint64_t arg_values[], |
| 40 uint8_t flags) { | |
| 40 base::debug::TraceLog::GetInstance()->AddTraceEvent(phase, | 41 base::debug::TraceLog::GetInstance()->AddTraceEvent(phase, |
| 41 static_cast<const unsigned char*>(category_enabled), name, id, num_args, | 42 static_cast<const unsigned char*>(category_enabled), name, id, num_args, |
| 42 arg_names, arg_types, | 43 arg_names, arg_types, |
| 43 // This cast is necessary for LP64 systems, where uint64_t is defined as | 44 // This cast is necessary for LP64 systems, where uint64_t is defined as |
| 44 // an unsigned long int, but trace_event internals are hermetic and | 45 // an unsigned long int, but trace_event internals are hermetic and |
| 45 // accepts an |unsigned long long*|. The pointer types are compatible but | 46 // accepts an |unsigned long long*|. The pointer types are compatible but |
| 46 // the compiler throws an error without an explicit cast. | 47 // the compiler throws an error without an explicit cast. |
| 47 reinterpret_cast<const unsigned long long*>(arg_values), NULL, flags); | 48 reinterpret_cast<const unsigned long long*>(arg_values), NULL, flags); |
|
dmichael (off chromium)
2013/06/24 17:43:42
maybe overkill, but you could COMPILE_ASSERT(sizeo
grosse
2013/06/24 23:16:46
Done.
| |
| 48 } | 49 } |
| 49 | 50 |
| 50 // static | 51 // static |
| 52 void TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp( | |
| 53 int8_t phase, | |
| 54 const void* category_enabled, | |
| 55 const char* name, | |
| 56 uint64_t id, | |
| 57 int32_t thread_id, | |
| 58 int64_t timestamp, | |
| 59 uint32_t num_args, | |
| 60 const char* arg_names[], | |
| 61 const uint8_t arg_types[], | |
| 62 const uint64_t arg_values[], | |
| 63 uint8_t flags) { | |
| 64 base::debug::TraceLog::GetInstance()->AddTraceEventWithThreadIdAndTimestamp( | |
| 65 phase, | |
| 66 static_cast<const unsigned char*>(category_enabled), name, id, | |
| 67 thread_id, | |
| 68 base::TimeTicks::FromInternalValue(timestamp), | |
| 69 num_args, arg_names, arg_types, | |
| 70 // This cast is necessary for LP64 systems, where uint64_t is defined as | |
| 71 // an unsigned long int, but trace_event internals are hermetic and | |
| 72 // accepts an |unsigned long long*|. The pointer types are compatible but | |
| 73 // the compiler throws an error without an explicit cast. | |
| 74 reinterpret_cast<const unsigned long long*>(arg_values), NULL, flags); | |
| 75 } | |
| 76 | |
| 77 // static | |
| 78 int64_t TraceEventImpl::Now() { | |
| 79 return base::TimeTicks::Now().ToInternalValue(); | |
| 80 } | |
| 81 | |
| 82 // static | |
| 51 void TraceEventImpl::SetThreadName(const char* thread_name) { | 83 void TraceEventImpl::SetThreadName(const char* thread_name) { |
| 52 base::PlatformThread::SetName(thread_name); | 84 base::PlatformThread::SetName(thread_name); |
| 53 } | 85 } |
| 54 | 86 |
| 55 namespace { | 87 namespace { |
| 56 | 88 |
| 57 const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = { | 89 const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = { |
| 58 &TraceEventImpl::GetCategoryEnabled, | 90 &TraceEventImpl::GetCategoryEnabled, |
| 59 &TraceEventImpl::AddTraceEvent, | 91 &TraceEventImpl::AddTraceEvent, |
| 92 &TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp, | |
| 93 &TraceEventImpl::Now, | |
| 60 &TraceEventImpl::SetThreadName, | 94 &TraceEventImpl::SetThreadName, |
| 61 }; | 95 }; |
| 62 | 96 |
| 63 } // namespace ppapi | 97 } // namespace ppapi |
| 64 | 98 |
| 65 } // namespace | 99 } // namespace |
| 66 | 100 |
| 67 namespace ppapi { | 101 namespace ppapi { |
| 68 namespace thunk { | 102 namespace thunk { |
| 69 | 103 |
| 70 const PPB_Trace_Event_Dev_0_1* GetPPB_Trace_Event_Dev_0_1_Thunk() { | 104 const PPB_Trace_Event_Dev_0_2* GetPPB_Trace_Event_Dev_0_2_Thunk() { |
| 71 return &g_ppb_trace_event_thunk; | 105 return &g_ppb_trace_event_thunk; |
| 72 } | 106 } |
| 73 | 107 |
| 74 } // namespace thunk | 108 } // namespace thunk |
| 75 } // namespace ppapi | 109 } // namespace ppapi |
| OLD | NEW |