12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/**
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * This file defines the <code>PPB_Trace_Event</code> interface. It is meant
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * to be used in plugins as the API that trace macros from trace_event.h use.
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)label Chrome {
12eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  M25 = 0.1,
13eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  M29 = 0.2
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch/**
17eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch * A trace event timestamp.
18eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch */
19eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochtypedef int64_t PP_TraceEventTime;
20eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)interface PPB_Trace_Event_Dev {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Gets a pointer to a character for identifying a category name in the
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * tracing system as well as for being able to early exit in client-side
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * tracing code.
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * NB: This mem_t return value should technically be const, but return values
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * for Pepper IDL of mem_t type are not const.  The same is true for the arg
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * |category_enabled| for AddTraceEvent.
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  mem_t GetCategoryEnabled([in] cstr_t category_name);
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Adds a trace event to the platform tracing system. This function call is
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * usually the result of a TRACE_* macro from trace_event.h when tracing and
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * the category of the particular trace are enabled. It is not advisable to
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * call this function on its own; it is really only meant to be used by the
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * trace macros.
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void AddTraceEvent(
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in] int8_t phase,
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in] mem_t category_enabled,
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in] cstr_t name,
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in] uint64_t id,
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in] uint32_t num_args,
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in, size_as=num_args] str_t[] arg_names,
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in, size_as=num_args] uint8_t[] arg_types,
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in, size_as=num_args] uint64_t[] arg_values,
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      [in] uint8_t flags);
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
52eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * Version of the above interface that allows specifying a custom thread id
53eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * and timestamp. This is useful for when tracing data cannot be registered
54eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * in real time. For example, this could be used by storing timestamps
55eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * internally and then registering the events retroactively.
56eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   */
57eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  [version=0.2]
58eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void AddTraceEventWithThreadIdAndTimestamp(
59eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] int8_t phase,
60eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] mem_t category_enabled,
61eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] cstr_t name,
62eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] uint64_t id,
63eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] int32_t thread_id,
64eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] PP_TraceEventTime timestamp,
65eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] uint32_t num_args,
66eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in, size_as=num_args] str_t[] arg_names,
67eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in, size_as=num_args] uint8_t[] arg_types,
68eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in, size_as=num_args] uint64_t[] arg_values,
69eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch      [in] uint8_t flags);
70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
71eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  /**
72eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * Get the current clock value. Since this uses the same function as the trace
73eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * events use internally, it can be used to create events with explicit time
74eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * stamps.
75eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   */
76eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  [version=0.2]
77eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  PP_TraceEventTime Now();
78eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
79eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  /**
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Sets the thread name of the calling thread in the tracing system so it will
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * show up properly in chrome://tracing.
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetThreadName([in] cstr_t thread_name);
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
85