OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_CPP_DEV_TRACE_EVENT_DEV_H_ |
| 6 #define PPAPI_CPP_DEV_TRACE_EVENT_DEV_H_ |
| 7 |
| 8 #include "ppapi/c/pp_stdint.h" |
| 9 |
| 10 /// @file |
| 11 /// This file defines the API for Pepper plugins to add trace events. Only |
| 12 /// <code>SetThreadName</code> is meant to be called directly by a developer, |
| 13 /// the other functions are only used by the macros in trace_event_internal.h. |
| 14 /// For details on how to instrument code, see: |
| 15 /// http://www.chromium.org/developers/how-tos/trace-event-profiling-tool/tracin
g-event-instrumentation |
| 16 |
| 17 namespace pp { |
| 18 |
| 19 class Trace_Events { |
| 20 public: |
| 21 /// Sets the current thread's name. This name will show up in trace captures |
| 22 /// in chrome://tracing |
| 23 static void SetThreadName(const char* name); |
| 24 |
| 25 /// This function returns a pointer to a variable indicated if a particular |
| 26 /// category is enabled. See comments in trace_event_internal.h for more |
| 27 /// details. |
| 28 static const unsigned char* GetCategoryEnabled(const char* category_name); |
| 29 |
| 30 /// Add a trace event entry. See comments in trace_event_internal.h for more |
| 31 /// details. |
| 32 static void AddTraceEvent(int8_t phase, |
| 33 const void* category_enabled, |
| 34 const char* name, |
| 35 uint64_t id, |
| 36 uint32_t num_args, |
| 37 const char* arg_names[], |
| 38 const uint8_t arg_types[], |
| 39 const uint64_t arg_values[], |
| 40 uint8_t flags); |
| 41 |
| 42 }; |
| 43 |
| 44 } // namespace pp |
| 45 |
| 46 // This header is modified from Chromium's base/debug/trace_event.h to provide |
| 47 // tracing through the PPB_Trace_Event_Dev interface. |
| 48 |
| 49 #define TRACE_EVENT_API_GET_CATEGORY_ENABLED \ |
| 50 pp::Trace_Events::GetCategoryEnabled |
| 51 |
| 52 // void TRACE_EVENT_API_ADD_TRACE_EVENT( |
| 53 // char phase, |
| 54 // const unsigned char* category_enabled, |
| 55 // const char* name, |
| 56 // unsigned long long id, |
| 57 // int num_args, |
| 58 // const char** arg_names, |
| 59 // const unsigned char* arg_types, |
| 60 // const unsigned long long* arg_values, |
| 61 // unsigned char flags) |
| 62 #define TRACE_EVENT_API_ADD_TRACE_EVENT pp::Trace_Events::AddTraceEvent |
| 63 |
| 64 // Defines atomic operations used internally by the tracing system. |
| 65 // Per comments in trace_event_internal.h these require no memory barrier, |
| 66 // and the Chromium gcc versions are defined as plain int load/store. |
| 67 #define TRACE_EVENT_API_ATOMIC_WORD intptr_t |
| 68 #define TRACE_EVENT_API_ATOMIC_LOAD(var) (var) |
| 69 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) ((var) = (value)) |
| 70 |
| 71 // Defines visibility for classes in trace_event_internal.h. |
| 72 #define TRACE_EVENT_API_CLASS_EXPORT |
| 73 |
| 74 #include "base/debug/trace_event_internal.h" |
| 75 |
| 76 #endif // PPAPI_CPP_DEV_TRACE_EVENT_DEV_H_ |
OLD | NEW |