xref: /aosp_15_r20/external/perfetto/ui/src/components/extensions.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 {type addDebugSliceTrack} from './tracks/debug_tracks';
16import {type addDebugCounterTrack} from './tracks/debug_tracks';
17import {type addSqlTableTab} from './details/sql_table_tab';
18import {type addVisualizedArgTracks} from './tracks/visualized_args_tracks';
19import {type addQueryResultsTab} from './query_table/query_result_tab';
20
21// TODO(primiano & stevegolton): This injection is to break the circular
22// dependency cycle that there is between various tabs and tracks.
23//
24// For example: DebugSliceTrack has a DebugSliceDetailsTab which shows details
25// about slices, which have a context menu, which allows to create a debug track
26// from it. We will break this cycle "more properly" by either:
27// 1. having a registry for context menu items for slices
28// 2. allowing plugins to expose API for the use of other plugins, and putting
29//    these extension points there instead
30
31export interface ExtensionApi {
32  addDebugSliceTrack: typeof addDebugSliceTrack;
33  addDebugCounterTrack: typeof addDebugCounterTrack;
34  addSqlTableTab: typeof addSqlTableTab;
35  addVisualizedArgTracks: typeof addVisualizedArgTracks;
36  addQueryResultsTab: typeof addQueryResultsTab;
37}
38
39export let extensions: ExtensionApi;
40
41export function configureExtensions(e: ExtensionApi) {
42  extensions = e;
43}
44