xref: /aosp_15_r20/development/tools/winscope/src/viewers/viewer.ts (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
1/*
2 * Copyright (C) 2022 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 */
16import {WinscopeEvent} from 'messaging/winscope_event';
17import {
18  EmitEvent,
19  WinscopeEventEmitter,
20} from 'messaging/winscope_event_emitter';
21import {WinscopeEventListener} from 'messaging/winscope_event_listener';
22import {Trace} from 'trace/trace';
23
24enum ViewType {
25  TRACE_TAB,
26  OVERLAY,
27  GLOBAL_SEARCH,
28}
29
30class View {
31  constructor(
32    public type: ViewType,
33    public traces: Array<Trace<object>>,
34    public htmlElement: HTMLElement,
35    public title: string,
36  ) {}
37}
38
39interface Viewer extends WinscopeEventListener, WinscopeEventEmitter {
40  onWinscopeEvent(event: WinscopeEvent): Promise<void>;
41  setEmitEvent(callback: EmitEvent): void;
42  getViews(): View[];
43  getTraces(): Array<Trace<object>>;
44}
45
46export {Viewer, View, ViewType};
47