1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef TRACING_PERFETTO_INTERNAL_H
18 #define TRACING_PERFETTO_INTERNAL_H
19 
20 #include <stdint.h>
21 
22 #include "include/trace_result.h"
23 #include "perfetto/public/te_category_macros.h"
24 
25 namespace tracing_perfetto {
26 
27 namespace internal {
28 
29 bool isPerfettoRegistered();
30 
31 struct PerfettoTeCategory* toPerfettoCategory(uint64_t category);
32 
33 void registerWithPerfetto(bool test = false);
34 
35 Result perfettoTraceBegin(const struct PerfettoTeCategory& category, const char* name);
36 
37 Result perfettoTraceEnd(const struct PerfettoTeCategory& category);
38 
39 Result perfettoTraceAsyncBegin(const struct PerfettoTeCategory& category, const char* name,
40                                uint64_t cookie);
41 
42 Result perfettoTraceAsyncEnd(const struct PerfettoTeCategory& category, const char* name,
43                              uint64_t cookie);
44 
45 Result perfettoTraceAsyncBeginForTrack(const struct PerfettoTeCategory& category, const char* name,
46                                        const char* trackName, uint64_t cookie);
47 
48 Result perfettoTraceAsyncEndForTrack(const struct PerfettoTeCategory& category,
49                                      const char* trackName, uint64_t cookie);
50 
51 Result perfettoTraceInstant(const struct PerfettoTeCategory& category, const char* name);
52 
53 Result perfettoTraceInstantForTrack(const struct PerfettoTeCategory& category,
54                                     const char* trackName, const char* name);
55 
56 Result perfettoTraceCounter(const struct PerfettoTeCategory& category, const char* name,
57                             int64_t value);
58 
59 uint64_t getDefaultCategories();
60 
61 }  // namespace internal
62 
63 }  // namespace tracing_perfetto
64 
65 #endif  // TRACING_PERFETTO_INTERNAL_H
66