event_tracer.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. // This file defines the interface for event tracing in WebRTC.
  11. //
  12. // Event log handlers are set through SetupEventTracer(). User of this API will
  13. // provide two function pointers to handle event tracing calls.
  14. //
  15. // * GetCategoryEnabledPtr
  16. // Event tracing system calls this function to determine if a particular
  17. // event category is enabled.
  18. //
  19. // * AddTraceEventPtr
  20. // Adds a tracing event. It is the user's responsibility to log the data
  21. // provided.
  22. //
  23. // Parameters for the above two functions are described in trace_event.h.
  24. #ifndef RTC_BASE_EVENT_TRACER_H_
  25. #define RTC_BASE_EVENT_TRACER_H_
  26. #include <stdio.h>
  27. namespace webrtc {
  28. typedef const unsigned char* (*GetCategoryEnabledPtr)(const char* name);
  29. typedef void (*AddTraceEventPtr)(char phase,
  30. const unsigned char* category_enabled,
  31. const char* name,
  32. unsigned long long id,
  33. int num_args,
  34. const char** arg_names,
  35. const unsigned char* arg_types,
  36. const unsigned long long* arg_values,
  37. unsigned char flags);
  38. // User of WebRTC can call this method to setup event tracing.
  39. //
  40. // This method must be called before any WebRTC methods. Functions
  41. // provided should be thread-safe.
  42. void SetupEventTracer(GetCategoryEnabledPtr get_category_enabled_ptr,
  43. AddTraceEventPtr add_trace_event_ptr);
  44. // This class defines interface for the event tracing system to call
  45. // internally. Do not call these methods directly.
  46. class EventTracer {
  47. public:
  48. static const unsigned char* GetCategoryEnabled(const char* name);
  49. static void AddTraceEvent(char phase,
  50. const unsigned char* category_enabled,
  51. const char* name,
  52. unsigned long long id,
  53. int num_args,
  54. const char** arg_names,
  55. const unsigned char* arg_types,
  56. const unsigned long long* arg_values,
  57. unsigned char flags);
  58. };
  59. } // namespace webrtc
  60. namespace rtc {
  61. namespace tracing {
  62. // Set up internal event tracer.
  63. void SetupInternalTracer();
  64. bool StartInternalCapture(const char* filename);
  65. void StartInternalCaptureToFile(FILE* file);
  66. void StopInternalCapture();
  67. // Make sure we run this, this will tear down the internal tracing.
  68. void ShutdownInternalTracer();
  69. } // namespace tracing
  70. } // namespace rtc
  71. #endif // RTC_BASE_EVENT_TRACER_H_