//
// Copyright (C) 2019 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// @generated by protoc-gen-es v2.2.2 with parameter "target=ts"
// @generated from file protos/perfetto/trace/track_event/track_descriptor.proto (package perfetto.protos, syntax proto2)
/* eslint-disable */

import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv1";
import type { ChromeProcessDescriptor } from "./chrome_process_descriptor_pb";
import { file_protos_perfetto_trace_track_event_chrome_process_descriptor } from "./chrome_process_descriptor_pb";
import type { ChromeThreadDescriptor } from "./chrome_thread_descriptor_pb";
import { file_protos_perfetto_trace_track_event_chrome_thread_descriptor } from "./chrome_thread_descriptor_pb";
import type { ProcessDescriptor } from "./process_descriptor_pb";
import { file_protos_perfetto_trace_track_event_process_descriptor } from "./process_descriptor_pb";
import type { ThreadDescriptor } from "./thread_descriptor_pb";
import { file_protos_perfetto_trace_track_event_thread_descriptor } from "./thread_descriptor_pb";
import type { CounterDescriptor } from "./counter_descriptor_pb";
import { file_protos_perfetto_trace_track_event_counter_descriptor } from "./counter_descriptor_pb";
import type { Message } from "@bufbuild/protobuf";

/**
 * Describes the file protos/perfetto/trace/track_event/track_descriptor.proto.
 */
export const file_protos_perfetto_trace_track_event_track_descriptor: GenFile = /*@__PURE__*/
  fileDesc("Cjhwcm90b3MvcGVyZmV0dG8vdHJhY2UvdHJhY2tfZXZlbnQvdHJhY2tfZGVzY3JpcHRvci5wcm90bxIPcGVyZmV0dG8ucHJvdG9zIpoFCg9UcmFja0Rlc2NyaXB0b3ISDAoEdXVpZBgBIAEoBBITCgtwYXJlbnRfdXVpZBgFIAEoBBIOCgRuYW1lGAIgASgJSAASFQoLc3RhdGljX25hbWUYCiABKAlIABIVCgthdHJhY2VfbmFtZRgNIAEoCUgAEjMKB3Byb2Nlc3MYAyABKAsyIi5wZXJmZXR0by5wcm90b3MuUHJvY2Vzc0Rlc2NyaXB0b3ISQAoOY2hyb21lX3Byb2Nlc3MYBiABKAsyKC5wZXJmZXR0by5wcm90b3MuQ2hyb21lUHJvY2Vzc0Rlc2NyaXB0b3ISMQoGdGhyZWFkGAQgASgLMiEucGVyZmV0dG8ucHJvdG9zLlRocmVhZERlc2NyaXB0b3ISPgoNY2hyb21lX3RocmVhZBgHIAEoCzInLnBlcmZldHRvLnByb3Rvcy5DaHJvbWVUaHJlYWREZXNjcmlwdG9yEjMKB2NvdW50ZXIYCCABKAsyIi5wZXJmZXR0by5wcm90b3MuQ291bnRlckRlc2NyaXB0b3ISKwojZGlzYWxsb3dfbWVyZ2luZ193aXRoX3N5c3RlbV90cmFja3MYCSABKAgSTAoOY2hpbGRfb3JkZXJpbmcYCyABKA4yNC5wZXJmZXR0by5wcm90b3MuVHJhY2tEZXNjcmlwdG9yLkNoaWxkVHJhY2tzT3JkZXJpbmcSGgoSc2libGluZ19vcmRlcl9yYW5rGAwgASgFIlYKE0NoaWxkVHJhY2tzT3JkZXJpbmcSCwoHVU5LTk9XThAAEhEKDUxFWElDT0dSQVBISUMQARIRCg1DSFJPTk9MT0dJQ0FMEAISDAoIRVhQTElDSVQQA0IYChZzdGF0aWNfb3JfZHluYW1pY19uYW1l", [file_protos_perfetto_trace_track_event_chrome_process_descriptor, file_protos_perfetto_trace_track_event_chrome_thread_descriptor, file_protos_perfetto_trace_track_event_process_descriptor, file_protos_perfetto_trace_track_event_thread_descriptor, file_protos_perfetto_trace_track_event_counter_descriptor]);

/**
 * Defines a track for TrackEvents. Slices and instant events on the same track
 * will be nested based on their timestamps, see TrackEvent::Type.
 *
 * A TrackDescriptor only needs to be emitted by one trace writer / producer and
 * is valid for the entirety of the trace. To ensure the descriptor isn't lost
 * when the ring buffer wraps, it should be reemitted whenever incremental state
 * is cleared.
 *
 * As a fallback, TrackEvents emitted without an explicit track association will
 * be associated with an implicit trace-global track (uuid = 0), see also
 * |TrackEvent::track_uuid|. It is possible but not necessary to emit a
 * TrackDescriptor for this implicit track.
 *
 * Next id: 14.
 *
 * @generated from message perfetto.protos.TrackDescriptor
 */
export type TrackDescriptor = Message<"perfetto.protos.TrackDescriptor"> & {
  /**
   * Unique ID that identifies this track. This ID is global to the whole trace.
   * Producers should ensure that it is unlikely to clash with IDs emitted by
   * other producers. A value of 0 denotes the implicit trace-global track.
   *
   * For example, legacy TRACE_EVENT macros may use a hash involving the async
   * event id + id_scope, pid, and/or tid to compute this ID.
   *
   * @generated from field: optional uint64 uuid = 1;
   */
  uuid: bigint;

  /**
   * A parent track reference can be used to describe relationships between
   * tracks. For example, to define an asynchronous track which is scoped to a
   * specific process, specify the uuid for that process's process track here.
   * Similarly, to associate a COUNTER_THREAD_TIME_NS counter track with a
   * thread, specify the uuid for that thread's thread track here.
   *
   * @generated from field: optional uint64 parent_uuid = 5;
   */
  parentUuid: bigint;

  /**
   * Name of the track. Optional - if unspecified, it may be derived from the
   * process/thread name (process/thread tracks), the first event's name (async
   * tracks), or counter name (counter tracks).
   *
   * @generated from oneof perfetto.protos.TrackDescriptor.static_or_dynamic_name
   */
  staticOrDynamicName: {
    /**
     * @generated from field: string name = 2;
     */
    value: string;
    case: "name";
  } | {
    /**
     * This field is only set by the SDK when perfetto::StaticString is
     * provided.
     *
     * @generated from field: string static_name = 10;
     */
    value: string;
    case: "staticName";
  } | {
    /**
     * Equivalent to name, used just to mark that the data is coming from
     * android.os.Trace.
     *
     * @generated from field: string atrace_name = 13;
     */
    value: string;
    case: "atraceName";
  } | { case: undefined; value?: undefined };

  /**
   * Associate the track with a process, making it the process-global track.
   * There should only be one such track per process (usually for instant
   * events; trace processor uses this fact to detect pid reuse). If you need
   * more (e.g. for asynchronous events), create child tracks using parent_uuid.
   *
   * Trace processor will merge events on a process track with slice-type events
   * from other sources (e.g. ftrace) for the same process into a single
   * timeline view.
   *
   * @generated from field: optional perfetto.protos.ProcessDescriptor process = 3;
   */
  process?: ProcessDescriptor;

  /**
   * @generated from field: optional perfetto.protos.ChromeProcessDescriptor chrome_process = 6;
   */
  chromeProcess?: ChromeProcessDescriptor;

  /**
   * Associate the track with a thread, indicating that the track's events
   * describe synchronous code execution on the thread. There should only be one
   * such track per thread (trace processor uses this fact to detect tid reuse).
   *
   * Trace processor will merge events on a thread track with slice-type events
   * from other sources (e.g. ftrace) for the same thread into a single timeline
   * view.
   *
   * @generated from field: optional perfetto.protos.ThreadDescriptor thread = 4;
   */
  thread?: ThreadDescriptor;

  /**
   * @generated from field: optional perfetto.protos.ChromeThreadDescriptor chrome_thread = 7;
   */
  chromeThread?: ChromeThreadDescriptor;

  /**
   * Descriptor for a counter track. If set, the track will only support
   * TYPE_COUNTER TrackEvents (and values provided via TrackEvent's
   * |extra_counter_values|).
   *
   * @generated from field: optional perfetto.protos.CounterDescriptor counter = 8;
   */
  counter?: CounterDescriptor;

  /**
   * If true, forces Trace Processor to use separate tracks for track events
   * and system events for the same thread.
   * Track events timestamps in Chrome have microsecond resolution, while
   * system events use nanoseconds. It results in broken event nesting when
   * track events and system events share a track.
   *
   * @generated from field: optional bool disallow_merging_with_system_tracks = 9;
   */
  disallowMergingWithSystemTracks: boolean;

  /**
   * @generated from field: optional perfetto.protos.TrackDescriptor.ChildTracksOrdering child_ordering = 11;
   */
  childOrdering: TrackDescriptor_ChildTracksOrdering;

  /**
   * An opaque value which allows specifying how two sibling tracks should be
   * ordered relative to each other: tracks with lower ranks will appear before
   * tracks with higher ranks. An unspecified rank will be treated as a rank of
   * 0.
   *
   * @generated from field: optional int32 sibling_order_rank = 12;
   */
  siblingOrderRank: number;
};

/**
 * Describes the message perfetto.protos.TrackDescriptor.
 * Use `create(TrackDescriptorSchema)` to create a new message.
 */
export const TrackDescriptorSchema: GenMessage<TrackDescriptor> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_trace_track_event_track_descriptor, 0);

/**
 * Specifies how the UI should display child tracks of this track (i.e. tracks
 * where `parent_uuid` is specified to this track `uuid`). Note that this
 * value is simply a *hint* to the UI: the UI is not guarnateed to respect
 * this if it has a good reason not to do so.
 *
 * @generated from enum perfetto.protos.TrackDescriptor.ChildTracksOrdering
 */
export enum TrackDescriptor_ChildTracksOrdering {
  /**
   * The default ordering, with no bearing on how the UI will visualise the
   * tracks.
   *
   * @generated from enum value: UNKNOWN = 0;
   */
  UNKNOWN = 0,

  /**
   * Order tracks by `name` or `static_name` depending on which one has been
   * specified.
   *
   * @generated from enum value: LEXICOGRAPHIC = 1;
   */
  LEXICOGRAPHIC = 1,

  /**
   * Order tracks by the first `ts` event in a track.
   *
   * @generated from enum value: CHRONOLOGICAL = 2;
   */
  CHRONOLOGICAL = 2,

  /**
   * Order tracks by `sibling_order_rank` of child tracks. Child tracks with
   * the lower values will be shown before tracks with higher values. Tracks
   * with no value will be treated as having 0 rank.
   *
   * @generated from enum value: EXPLICIT = 3;
   */
  EXPLICIT = 3,
}

/**
 * Describes the enum perfetto.protos.TrackDescriptor.ChildTracksOrdering.
 */
export const TrackDescriptor_ChildTracksOrderingSchema: GenEnum<TrackDescriptor_ChildTracksOrdering> = /*@__PURE__*/
  enumDesc(file_protos_perfetto_trace_track_event_track_descriptor, 0, 0);

