1 /*
2  * Copyright 2025 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 package androidx.tracing.driver
18 
19 import androidx.annotation.RestrictTo
20 
21 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public const val TRACK_DESCRIPTOR_TYPE_COUNTER: Int = 1
22 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public const val TRACK_DESCRIPTOR_TYPE_THREAD: Int = 2
23 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public const val TRACK_DESCRIPTOR_TYPE_PROCESS: Int = 3
24 
25 /** Low level representation of a Track, written once to the Trace. */
26 public class TrackDescriptor(
27     /** Display name of the Track in the trace. */
28     public var name: String,
29     /**
30      * Unique ID of the Track - each corresponding [TraceEvent] in the trace will set
31      * [TraceEvent.trackUuid] to this value.
32      */
33     public var uuid: Long,
34     /**
35      * If set, this Track will be nested inside of the parent track (for example, when a
36      * [ThreadTrack] is a child of a [ProcessTrack]).
37      */
38     public var parentUuid: Long,
39     /**
40      * One of [TRACK_DESCRIPTOR_TYPE_THREAD], [TRACK_DESCRIPTOR_TYPE_COUNTER],
41      * [TRACK_DESCRIPTOR_TYPE_PROCESS]
42      */
43     public var type: Int,
44     /** If type == [TRACK_DESCRIPTOR_TYPE_PROCESS], represents the PID of the process. */
45     public var pid: Int,
46     /** If type == [TRACK_DESCRIPTOR_TYPE_THREAD], represents the TID of the thread. */
47     public var tid: Int,
48 )
49