xref: /aosp_15_r20/external/perfetto/ui/src/core/trace_source.ts (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1// Copyright (C) 2024 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import {SerializedAppState} from './state_serialization_schema';
16
17export type TraceSource =
18  | TraceFileSource
19  | TraceArrayBufferSource
20  | TraceUrlSource
21  | TraceHttpRpcSource;
22
23export interface TraceFileSource {
24  type: 'FILE';
25  file: File;
26}
27
28export interface TraceUrlSource {
29  type: 'URL';
30  url: string;
31
32  // When loading from a permalink, the permalink might supply also the app
33  // state alongside the URL of the trace.
34  serializedAppState?: SerializedAppState;
35}
36
37export interface TraceHttpRpcSource {
38  type: 'HTTP_RPC';
39}
40
41export interface TraceArrayBufferSource extends PostedTrace {
42  type: 'ARRAY_BUFFER';
43  // See PostedTrace (which this interface extends).
44}
45
46export interface PostedTrace {
47  buffer: ArrayBuffer;
48  title: string;
49  fileName?: string;
50  url?: string;
51
52  // |uuid| is set only when loading via ?local_cache_key=1234. When set,
53  // this matches global.state.traceUuid, with the exception of the following
54  // time window: When a trace T1 is loaded and the user loads another trace T2,
55  // this |uuid| will be == T2, but the globals.state.traceUuid will be
56  // temporarily == T1 until T2 has been loaded (consistently to what happens
57  // with all other state fields).
58  uuid?: string;
59
60  // if |localOnly| is true then the trace should not be shared or downloaded.
61  localOnly?: boolean;
62  keepApiOpen?: boolean;
63
64  // Allows to pass extra arguments to plugins. This can be read by plugins
65  // onTraceLoad() and can be used to trigger plugin-specific-behaviours (e.g.
66  // allow dashboards like APC to pass extra data to materialize onto tracks).
67  // The format is the following:
68  // pluginArgs: {
69  //   'dev.perfetto.PluginFoo': { 'key1': 'value1', 'key2': 1234 }
70  //   'dev.perfetto.PluginBar': { 'key3': '...', 'key4': ... }
71  // }
72  pluginArgs?: {[pluginId: string]: {[key: string]: unknown}};
73}
74