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 {sqlTableRegistry} from '../../components/widgets/sql/table/sql_table_registry'; 16import {Trace} from '../../public/trace'; 17import {PerfettoPlugin} from '../../public/plugin'; 18import { 19 getThreadTable, 20 getProcessTable, 21 getSliceTable, 22 getAndroidLogsTable, 23 getSchedTable, 24 getThreadStateTable, 25} from './tables'; 26import {extensions} from '../../components/extensions'; 27 28export default class implements PerfettoPlugin { 29 static readonly id = 'org.Chromium.OpenTableCommands'; 30 31 async onTraceLoad(ctx: Trace) { 32 sqlTableRegistry['slice'] = getSliceTable(); 33 ctx.commands.registerCommand({ 34 id: 'perfetto.ShowTable.slice', 35 name: 'Open table: slice', 36 callback: () => { 37 extensions.addLegacySqlTableTab(ctx, { 38 table: getSliceTable(), 39 }); 40 }, 41 }); 42 43 sqlTableRegistry['thread'] = getThreadTable(); 44 ctx.commands.registerCommand({ 45 id: 'perfetto.ShowTable.thread', 46 name: 'Open table: thread', 47 callback: () => { 48 extensions.addLegacySqlTableTab(ctx, { 49 table: getThreadTable(), 50 }); 51 }, 52 }); 53 54 sqlTableRegistry['process'] = getThreadTable(); 55 ctx.commands.registerCommand({ 56 id: 'perfetto.ShowTable.process', 57 name: 'Open table: process', 58 callback: () => { 59 extensions.addLegacySqlTableTab(ctx, { 60 table: getProcessTable(), 61 }); 62 }, 63 }); 64 65 sqlTableRegistry['sched'] = getSchedTable(); 66 ctx.commands.registerCommand({ 67 id: 'perfetto.ShowTable.sched', 68 name: 'Open table: sched', 69 callback: () => { 70 extensions.addLegacySqlTableTab(ctx, { 71 table: getSchedTable(), 72 }); 73 }, 74 }); 75 76 sqlTableRegistry['thread_state'] = getThreadStateTable(); 77 ctx.commands.registerCommand({ 78 id: 'perfetto.ShowTable.thread_state', 79 name: 'Open table: thread_state', 80 callback: () => { 81 extensions.addLegacySqlTableTab(ctx, { 82 table: getThreadStateTable(), 83 }); 84 }, 85 }); 86 87 sqlTableRegistry['android_logs'] = getAndroidLogsTable(); 88 ctx.commands.registerCommand({ 89 id: 'perfetto.ShowTable.android_logs', 90 name: 'Open table: android_logs', 91 callback: () => { 92 extensions.addLegacySqlTableTab(ctx, { 93 table: getAndroidLogsTable(), 94 }); 95 }, 96 }); 97 } 98} 99