aboutsummaryrefslogtreecommitdiff
path: root/ui/src/tracks/visualised_args/index.ts
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-09 01:08:02 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-09 01:08:02 +0000
commit46f6fd64738807a563b4efc1646a12dbf277046e (patch)
tree9a89c03408da6dc51e44efc0d1d1f870afc391e3 /ui/src/tracks/visualised_args/index.ts
parent3b971a8771e2297882f37fa34b601e294d47c95b (diff)
parent53dd8e309607e80ba27c58bc91106b1c6fb1a30d (diff)
downloadperfetto-46f6fd64738807a563b4efc1646a12dbf277046e.tar.gz
Snap for 11819063 from 53dd8e309607e80ba27c58bc91106b1c6fb1a30d to sdk-release
Change-Id: Ifaed9e18e83c145cf5e132e252366d4b2799cf86
Diffstat (limited to 'ui/src/tracks/visualised_args/index.ts')
-rw-r--r--ui/src/tracks/visualised_args/index.ts98
1 files changed, 7 insertions, 91 deletions
diff --git a/ui/src/tracks/visualised_args/index.ts b/ui/src/tracks/visualised_args/index.ts
index 9e34de3f1..459a7ad4a 100644
--- a/ui/src/tracks/visualised_args/index.ts
+++ b/ui/src/tracks/visualised_args/index.ts
@@ -12,98 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import m from 'mithril';
-import {v4 as uuidv4} from 'uuid';
-
-import {Actions} from '../../common/actions';
-import {globals} from '../../frontend/globals';
-import {
- EngineProxy,
- Plugin,
- PluginContextTrace,
- PluginDescriptor,
- TrackContext,
-} from '../../public';
-import {ChromeSliceTrack} from '../chrome_slices';
+import {Plugin, PluginContextTrace, PluginDescriptor} from '../../public';
import {
VISUALISED_ARGS_SLICE_TRACK_URI,
VisualisedArgsState,
} from '../../frontend/visualized_args_tracks';
-import {Button} from '../../widgets/button';
-import {Icons} from '../../base/semantic_icons';
-
-export class VisualisedArgsTrack extends ChromeSliceTrack {
- private helperViewName: string;
-
- constructor(
- engine: EngineProxy,
- maxDepth: number,
- trackKey: string,
- trackId: number,
- private argName: string,
- ) {
- const uuid = uuidv4();
- const namespace = `__arg_visualisation_helper_${argName}_${uuid}`;
- const escapedNamespace = namespace.replace(/[^a-zA-Z]/g, '_');
- super(engine, maxDepth, trackKey, trackId, escapedNamespace);
- this.helperViewName = `${escapedNamespace}_slice`;
- }
-
- async onCreate(_ctx: TrackContext): Promise<void> {
- // Create the helper view - just one which is relevant to this slice
- await this.engine.query(`
- create view ${this.helperViewName} as
- with slice_with_arg as (
- select
- slice.id,
- slice.track_id,
- slice.ts,
- slice.dur,
- slice.thread_dur,
- NULL as cat,
- args.display_value as name
- from slice
- join args using (arg_set_id)
- where args.key='${this.argName}'
- )
- select
- *,
- (select count()
- from ancestor_slice(s1.id) s2
- join slice_with_arg s3 on s2.id=s3.id
- ) as depth
- from slice_with_arg s1
- order by id;
- `);
- }
-
- async onDestroy(): Promise<void> {
- if (this.engine.isAlive) {
- await this.engine.query(`drop view ${this.helperViewName}`);
- }
- }
-
- getFont() {
- return 'italic 11px Roboto';
- }
-
- getTrackShellButtons(): m.Children {
- return m(Button, {
- onclick: () => {
- // This behavior differs to the original behavior a little.
- // Originally, hitting the close button on a single track removed ALL
- // tracks with this argName, whereas this one only closes the single
- // track.
- // This will be easily fixable once we transition to using dynamic
- // tracks instead of this "initial state" approach to add these tracks.
- globals.dispatch(Actions.removeTracks({trackKeys: [this.trackKey]}));
- },
- icon: Icons.Close,
- title: 'Close',
- compact: true,
- });
- }
-}
+import {VisualisedArgsTrack} from './visualized_args_track';
class VisualisedArgsPlugin implements Plugin {
async onTraceLoad(ctx: PluginContextTrace): Promise<void> {
@@ -117,10 +31,12 @@ class VisualisedArgsPlugin implements Plugin {
// worse than the situation we had before with track config.
const params = trackCtx.params as VisualisedArgsState;
return new VisualisedArgsTrack(
- ctx.engine,
- params.maxDepth,
- trackCtx.trackKey,
+ {
+ engine: ctx.engine,
+ trackKey: trackCtx.trackKey,
+ },
params.trackId,
+ params.maxDepth,
params.argName,
);
},