Home | History | Annotate | Download | only in dev
      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
      3  * found in the LICENSE file.
      4  */
      5 
      6 /* From dev/ppb_trace_event_dev.idl modified Tue Jun 25 16:12:08 2013. */
      7 
      8 #ifndef PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_
      9 #define PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_
     10 
     11 #include "ppapi/c/pp_macros.h"
     12 #include "ppapi/c/pp_stdint.h"
     13 
     14 #define PPB_TRACE_EVENT_DEV_INTERFACE_0_1 "PPB_Trace_Event(Dev);0.1"
     15 #define PPB_TRACE_EVENT_DEV_INTERFACE_0_2 "PPB_Trace_Event(Dev);0.2"
     16 #define PPB_TRACE_EVENT_DEV_INTERFACE PPB_TRACE_EVENT_DEV_INTERFACE_0_2
     17 
     18 /**
     19  * @file
     20  * This file defines the <code>PPB_Trace_Event</code> interface. It is meant
     21  * to be used in plugins as the API that trace macros from trace_event.h use.
     22  */
     23 
     24 
     25 /**
     26  * @addtogroup Typedefs
     27  * @{
     28  */
     29 /**
     30  * A trace event timestamp.
     31  */
     32 typedef int64_t PP_TraceEventTime;
     33 /**
     34  * @}
     35  */
     36 
     37 /**
     38  * @addtogroup Interfaces
     39  * @{
     40  */
     41 struct PPB_Trace_Event_Dev_0_2 {
     42   /**
     43    * Gets a pointer to a character for identifying a category name in the
     44    * tracing system as well as for being able to early exit in client-side
     45    * tracing code.
     46    *
     47    * NB: This mem_t return value should technically be const, but return values
     48    * for Pepper IDL of mem_t type are not const.  The same is true for the arg
     49    * |category_enabled| for AddTraceEvent.
     50    */
     51   void* (*GetCategoryEnabled)(const char* category_name);
     52   /**
     53    * Adds a trace event to the platform tracing system. This function call is
     54    * usually the result of a TRACE_* macro from trace_event.h when tracing and
     55    * the category of the particular trace are enabled. It is not advisable to
     56    * call this function on its own; it is really only meant to be used by the
     57    * trace macros.
     58    */
     59   void (*AddTraceEvent)(int8_t phase,
     60                         const void* category_enabled,
     61                         const char* name,
     62                         uint64_t id,
     63                         uint32_t num_args,
     64                         const char* arg_names[],
     65                         const uint8_t arg_types[],
     66                         const uint64_t arg_values[],
     67                         uint8_t flags);
     68   /**
     69    * Version of the above interface that allows specifying a custom thread id
     70    * and timestamp. This is useful for when tracing data cannot be registered
     71    * in real time. For example, this could be used by storing timestamps
     72    * internally and then registering the events retroactively.
     73    */
     74   void (*AddTraceEventWithThreadIdAndTimestamp)(int8_t phase,
     75                                                 const void* category_enabled,
     76                                                 const char* name,
     77                                                 uint64_t id,
     78                                                 int32_t thread_id,
     79                                                 PP_TraceEventTime timestamp,
     80                                                 uint32_t num_args,
     81                                                 const char* arg_names[],
     82                                                 const uint8_t arg_types[],
     83                                                 const uint64_t arg_values[],
     84                                                 uint8_t flags);
     85   /**
     86    * Get the current clock value. Since this uses the same function as the trace
     87    * events use internally, it can be used to create events with explicit time
     88    * stamps.
     89    */
     90   PP_TraceEventTime (*Now)(void);
     91   /**
     92    * Sets the thread name of the calling thread in the tracing system so it will
     93    * show up properly in chrome://tracing.
     94    */
     95   void (*SetThreadName)(const char* thread_name);
     96 };
     97 
     98 typedef struct PPB_Trace_Event_Dev_0_2 PPB_Trace_Event_Dev;
     99 
    100 struct PPB_Trace_Event_Dev_0_1 {
    101   void* (*GetCategoryEnabled)(const char* category_name);
    102   void (*AddTraceEvent)(int8_t phase,
    103                         const void* category_enabled,
    104                         const char* name,
    105                         uint64_t id,
    106                         uint32_t num_args,
    107                         const char* arg_names[],
    108                         const uint8_t arg_types[],
    109                         const uint64_t arg_values[],
    110                         uint8_t flags);
    111   void (*SetThreadName)(const char* thread_name);
    112 };
    113 /**
    114  * @}
    115  */
    116 
    117 #endif  /* PPAPI_C_DEV_PPB_TRACE_EVENT_DEV_H_ */
    118 
    119