xref: /aosp_15_r20/external/cronet/base/trace_event/optional_trace_event.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2020 The Chromium Authors
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 BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
6 #define BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
7 
8 #include "base/trace_event/trace_event.h"
9 #include "base/tracing_buildflags.h"
10 #include "build/buildflag.h"
11 
12 // These macros are functionally equivalent to TRACE_EVENTX macros,
13 // but they are disabled if optional_trace_events_enabled gn flag
14 // defined in tracing.gni is false.
15 
16 #if BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
17 
18 #define OPTIONAL_TRACE_EVENT0(...) TRACE_EVENT0(__VA_ARGS__)
19 #define OPTIONAL_TRACE_EVENT1(...) TRACE_EVENT1(__VA_ARGS__)
20 #define OPTIONAL_TRACE_EVENT2(...) TRACE_EVENT2(__VA_ARGS__)
21 
22 #else  // BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
23 
24 #define OPTIONAL_TRACE_EVENT0(category, name)
25 #define OPTIONAL_TRACE_EVENT1(category, name, arg1_name, arg1_val)
26 #define OPTIONAL_TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \
27                               arg2_val)
28 
29 #endif  // BUILDFLAG(OPTIONAL_TRACE_EVENTS_ENABLED)
30 
31 #endif  // BASE_TRACE_EVENT_OPTIONAL_TRACE_EVENT_H_
32