optional_trace_event.h 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2020 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. #ifndef BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
  5. #define BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
  6. #include "base/trace_event/trace_event.h"
  7. #include "base/tracing_buildflags.h"
  8. #include "build/buildflag.h"
  9. // These macros are functionally equivalent to TRACE_EVENTX macros,
  10. // but they are disabled if optional_trace_events_enabled gn flag
  11. // defined in tracing.gni is false.
  12. #if BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
  13. #define OPTIONAL_TRACE_EVENT0(...) TRACE_EVENT0(__VA_ARGS__)
  14. #define OPTIONAL_TRACE_EVENT1(...) TRACE_EVENT1(__VA_ARGS__)
  15. #define OPTIONAL_TRACE_EVENT2(...) TRACE_EVENT2(__VA_ARGS__)
  16. #else // BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
  17. #define OPTIONAL_TRACE_EVENT0(category, name)
  18. #define OPTIONAL_TRACE_EVENT1(category, name, arg1_name, arg1_val)
  19. #define OPTIONAL_TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \
  20. arg2_val)
  21. #endif // BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
  22. #endif // BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_