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 */ 16 17import {Traces} from 'trace/traces'; 18import {TracePosition} from 'trace/trace_position'; 19import {TraceType} from 'trace/trace_type'; 20import {View, Viewer, ViewType} from 'viewers/viewer'; 21import {Events} from './events'; 22import {Presenter} from './presenter'; 23import {UiData} from './ui_data'; 24 25class ViewerTransactions implements Viewer { 26 constructor(traces: Traces) { 27 this.htmlElement = document.createElement('viewer-transactions'); 28 29 this.presenter = new Presenter(traces, (data: UiData) => { 30 (this.htmlElement as any).inputData = data; 31 }); 32 33 this.htmlElement.addEventListener(Events.VSyncIdFilterChanged, (event) => { 34 this.presenter.onVSyncIdFilterChanged((event as CustomEvent).detail); 35 }); 36 37 this.htmlElement.addEventListener(Events.PidFilterChanged, (event) => { 38 this.presenter.onPidFilterChanged((event as CustomEvent).detail); 39 }); 40 41 this.htmlElement.addEventListener(Events.UidFilterChanged, (event) => { 42 this.presenter.onUidFilterChanged((event as CustomEvent).detail); 43 }); 44 45 this.htmlElement.addEventListener(Events.TypeFilterChanged, (event) => { 46 this.presenter.onTypeFilterChanged((event as CustomEvent).detail); 47 }); 48 49 this.htmlElement.addEventListener(Events.LayerIdFilterChanged, (event) => { 50 this.presenter.onLayerIdFilterChanged((event as CustomEvent).detail); 51 }); 52 53 this.htmlElement.addEventListener(Events.WhatSearchStringChanged, (event) => { 54 this.presenter.onWhatSearchStringChanged((event as CustomEvent).detail); 55 }); 56 57 this.htmlElement.addEventListener(Events.IdFilterChanges, (event) => { 58 this.presenter.onIdFilterChanged((event as CustomEvent).detail); 59 }); 60 61 this.htmlElement.addEventListener(Events.EntryClicked, (event) => { 62 this.presenter.onEntryClicked((event as CustomEvent).detail); 63 }); 64 } 65 66 async onTracePositionUpdate(position: TracePosition) { 67 await this.presenter.onTracePositionUpdate(position); 68 } 69 70 getViews(): View[] { 71 return [ 72 new View( 73 ViewType.TAB, 74 this.getDependencies(), 75 this.htmlElement, 76 'Transactions', 77 TraceType.TRANSACTIONS 78 ), 79 ]; 80 } 81 82 getDependencies(): TraceType[] { 83 return ViewerTransactions.DEPENDENCIES; 84 } 85 86 static readonly DEPENDENCIES: TraceType[] = [TraceType.TRANSACTIONS]; 87 private htmlElement: HTMLElement; 88 private presenter: Presenter; 89} 90 91export {ViewerTransactions}; 92