• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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 * as m from 'mithril';
16
17import {Actions} from '../../common/actions';
18import {globals} from '../../frontend/globals';
19import {NewTrackArgs, Track} from '../../frontend/track';
20import {TrackButton, TrackButtonAttrs} from '../../frontend/track_panel';
21import {trackRegistry} from '../../frontend/track_registry';
22import {ChromeSliceTrack} from '../chrome_slices/frontend';
23
24import {DEBUG_SLICE_TRACK_KIND} from './common';
25
26export class DebugSliceTrack extends ChromeSliceTrack {
27  static readonly kind = DEBUG_SLICE_TRACK_KIND;
28  static create(args: NewTrackArgs): Track {
29    return new DebugSliceTrack(args);
30  }
31
32  getTrackShellButtons(): Array<m.Vnode<TrackButtonAttrs>> {
33    const buttons: Array<m.Vnode<TrackButtonAttrs>> = [];
34    buttons.push(m(TrackButton, {
35      action: () => {
36        globals.dispatch(Actions.requestTrackReload({}));
37      },
38      i: 'refresh',
39      tooltip: 'Refresh tracks',
40      showButton: true,
41    }));
42    buttons.push(m(TrackButton, {
43      action: () => {
44        globals.dispatch(Actions.removeDebugTrack({}));
45      },
46      i: 'close',
47      tooltip: 'Close',
48      showButton: true,
49    }));
50    return buttons;
51  }
52}
53
54trackRegistry.register(DebugSliceTrack);
55