• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2023 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 {NamedSliceTrack} from '../../frontend/named_slice_track';
16import {SLICE_LAYOUT_FIT_CONTENT_DEFAULTS} from '../../frontend/slice_layout';
17import {NewTrackArgs} from '../../frontend/track';
18import {Slice} from '../../public';
19
20export class AsyncSliceTrack extends NamedSliceTrack {
21  constructor(
22    args: NewTrackArgs,
23    maxDepth: number,
24    private trackIds: number[],
25  ) {
26    super(args);
27    this.sliceLayout = {
28      ...SLICE_LAYOUT_FIT_CONTENT_DEFAULTS,
29      depthGuess: maxDepth,
30    };
31  }
32
33  getSqlSource(): string {
34    return `
35      select
36        ts,
37        dur,
38        layout_depth as depth,
39        ifnull(name, '[null]') as name,
40        id,
41        thread_dur as threadDur
42      from experimental_slice_layout
43      where filter_track_ids = '${this.trackIds.join(',')}'
44    `;
45  }
46
47  onUpdatedSlices(slices: Slice[]) {
48    for (const slice of slices) {
49      slice.isHighlighted = slice === this.hoveredSlice;
50    }
51  }
52}
53