1// Copyright (C) 2020 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use size 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 * as m from 'mithril'; 16 17import {CallsiteInfo} from '../common/state'; 18import {globals} from './globals'; 19import {Panel} from './panel'; 20 21interface CpuProfileDetailsPanelAttrs {} 22 23export class CpuProfileDetailsPanel extends Panel<CpuProfileDetailsPanelAttrs> { 24 view() { 25 const sampleDetails = globals.cpuProfileDetails; 26 const header = 27 m('.details-panel-heading', m('h2', `CPU Profile Sample Details`)); 28 if (!sampleDetails || sampleDetails.id === undefined) { 29 return m('.details-panel', header); 30 } 31 32 return m( 33 '.details-panel', 34 header, 35 m('table', this.getStackText(sampleDetails.stack))); 36 } 37 38 getStackText(stack?: CallsiteInfo[]): m.Vnode[] { 39 if (!stack) return []; 40 41 const result = []; 42 for (let i = 0; i < stack.length; i++) { 43 result.push(m('tr', m('td', stack[i].name), m('td', stack[i].mapping))); 44 } 45 46 return result; 47 } 48 49 renderCanvas() {} 50} 51