• 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 {DatasetSliceTrack} from '../../components/tracks/dataset_slice_track';
16import {Trace} from '../../public/trace';
17import {SourceDataset} from '../../trace_processor/dataset';
18import {LONG, NUM, STR} from '../../trace_processor/query_result';
19import {ScrollDetailsPanel} from './scroll_details_panel';
20
21export function createTopLevelScrollTrack(trace: Trace, uri: string) {
22  return new DatasetSliceTrack({
23    trace,
24    uri,
25    dataset: new SourceDataset({
26      schema: {
27        id: NUM,
28        rawId: LONG,
29        ts: LONG,
30        dur: LONG,
31        name: STR,
32      },
33      src: `
34        SELECT
35          ROW_NUMBER() OVER (ORDER BY ts) as id,
36          id as rawId,
37          printf("Scroll %s", CAST(id AS STRING)) AS name,
38          ts,
39          dur
40        FROM chrome_scrolls
41        -- If the scroll has started before the trace started, we won't have
42        -- an id for it, so skip it to ensure that we can show the remaining
43        -- traces.
44        WHERE id IS NOT NULL
45      `,
46    }),
47    detailsPanel: (row) => new ScrollDetailsPanel(trace, row.rawId),
48  });
49}
50