blob: 7c6de3d9b4e7c233f65bd3ea21125d6953555843 [file] [edit]
// Copyright (C) 2026 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import {ensureExists} from '../../base/assert';
import type {PerfettoPlugin} from '../../public/plugin';
import type {Trace} from '../../public/trace';
import {type CustomDimensions, loadCustomDimensions} from './custom_dimensions';
export default class TrackDimensionsPlugin implements PerfettoPlugin {
static readonly id = 'dev.perfetto.TrackDimensions';
static readonly description = `
Loads the custom dimensions of trace processor tracks, making them
available to the plugins that create tracks so they can show them as
chips.
`;
private dimensions?: CustomDimensions;
async onTraceLoad(trace: Trace): Promise<void> {
this.dimensions = await loadCustomDimensions(trace.engine);
}
getCustomDimensions(): CustomDimensions {
return ensureExists(this.dimensions);
}
}