Chromium Code Reviews| Index: ppapi/shared_impl/ppb_trace_event_shared.cc |
| diff --git a/ppapi/shared_impl/ppb_trace_event_shared.cc b/ppapi/shared_impl/ppb_trace_event_shared.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0990691fc07202c1101284fc2e64dbb6893bcc09 |
| --- /dev/null |
| +++ b/ppapi/shared_impl/ppb_trace_event_shared.cc |
| @@ -0,0 +1,45 @@ |
| +// 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_shared.h" |
| + |
| +#include "base/debug/trace_event.h" |
| + |
| +namespace ppapi { |
| + |
| +// 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. Also, for NaCl plugins these functions will |
| +// be executed from untrusted code and handled appropriately by tracing |
| +// functionality in the IRT. |
| +void* PPB_Trace_Event_Shared::GetCategoryEnabled(const char* category_name) { |
|
brettw
2012/12/19 22:29:25
These should have "static" comments.
elijahtaylor1
2012/12/21 00:59:16
Done.
|
| + // 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*>( |
|
brettw
2012/12/19 22:29:25
reinterpret_cast -> I think you can static_cast po
elijahtaylor1
2012/12/21 00:59:16
Done.
|
| + base::debug::TraceLog::GetInstance()->GetCategoryEnabled(category_name))); |
| +} |
| + |
| +int32_t PPB_Trace_Event_Shared::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[], |
| + 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, |
|
brettw
2012/12/19 22:29:25
C++ cast
elijahtaylor1
2012/12/21 00:59:16
Done.
|
| + arg_types, arg_values, threshold_begin_id, threshold, flags); |
| +} |
| + |
| +void PPB_Trace_Event_Shared::SetThreadName(const char* thread_name) { |
| + base::PlatformThread::SetName(thread_name); |
| +} |
| + |
| +} // namespace ppapi |