aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHector Dearman <hjd@google.com>2023-07-05 13:16:19 +0100
committerHector Dearman <hjd@google.com>2023-07-05 13:16:19 +0100
commit45332e0465e8391b997f9b2278b17dfc7435fdfc (patch)
treed153645ba315c46ded6a654b956f693a80b35228
parentad2ed918f9c60723ebd602d1c40edb3b773fdf65 (diff)
downloadperfetto-45332e0465e8391b997f9b2278b17dfc7435fdfc.tar.gz
ui: Support deeplink queries
e.g. http://localhost:10000/#!/viewer?query=select%20sum(dur)%20from%20slice Bug: 289412810 Change-Id: I4d68196060f233234f7bbacdd825c8826cdb7d6e
-rw-r--r--ui/src/common/actions.ts4
-rw-r--r--ui/src/common/state.ts5
-rw-r--r--ui/src/controller/trace_controller.ts4
-rw-r--r--ui/src/frontend/index.ts2
-rw-r--r--ui/src/frontend/router.ts2
5 files changed, 14 insertions, 3 deletions
diff --git a/ui/src/common/actions.ts b/ui/src/common/actions.ts
index 19954e4da..9f791b653 100644
--- a/ui/src/common/actions.ts
+++ b/ui/src/common/actions.ts
@@ -56,6 +56,7 @@ import {
NewEngineMode,
OmniboxState,
Pagination,
+ PendingDeeplinkState,
PivotTableResult,
PrimaryTrackSortKey,
ProfileType,
@@ -479,8 +480,7 @@ export const StateActions = {
}
},
- maybeSetPendingDeeplink(
- state: StateDraft, args: {ts?: string, dur?: string, tid?: string}) {
+ maybeSetPendingDeeplink(state: StateDraft, args: PendingDeeplinkState) {
state.pendingDeeplink = args;
},
diff --git a/ui/src/common/state.ts b/ui/src/common/state.ts
index 7cdc17761..9237dd431 100644
--- a/ui/src/common/state.ts
+++ b/ui/src/common/state.ts
@@ -108,7 +108,8 @@ export const MAX_TIME = 180;
// 31. Convert all timestamps to bigints.
// 32. Add pendingDeeplink.
// 33. Add plugins state.
-export const STATE_VERSION = 33;
+// 34. Add additional pendingDeeplink fields (query, pid).
+export const STATE_VERSION = 34;
export const SCROLLING_TRACK_GROUP = 'ScrollingTracks';
@@ -525,6 +526,8 @@ export interface PendingDeeplinkState {
ts?: string;
dur?: string;
tid?: string;
+ pid?: string;
+ query?: string;
}
export interface State {
diff --git a/ui/src/controller/trace_controller.ts b/ui/src/controller/trace_controller.ts
index f78d656f8..59cf7b43a 100644
--- a/ui/src/controller/trace_controller.ts
+++ b/ui/src/controller/trace_controller.ts
@@ -63,6 +63,7 @@ import {
publishOverviewData,
publishThreads,
} from '../frontend/publish';
+import {runQueryInNewTab} from '../frontend/query_result_tab';
import {Router} from '../frontend/router';
import {
@@ -531,6 +532,9 @@ export class TraceController extends Controller<States> {
if (pendingDeeplink !== undefined) {
globals.dispatch(Actions.clearPendingDeeplink({}));
await this.selectPendingDeeplink(pendingDeeplink);
+ if (pendingDeeplink.query !== undefined) {
+ runQueryInNewTab(pendingDeeplink.query, 'Deeplink Query');
+ }
}
// If the trace was shared via a permalink, it might already have a
diff --git a/ui/src/frontend/index.ts b/ui/src/frontend/index.ts
index 3b8f9bd62..64980dabf 100644
--- a/ui/src/frontend/index.ts
+++ b/ui/src/frontend/index.ts
@@ -367,6 +367,8 @@ function onCssLoaded() {
ts: route.args.ts,
tid: route.args.tid,
dur: route.args.dur,
+ pid: route.args.dur,
+ query: route.args.query,
}));
if (!globals.embeddedMode) {
diff --git a/ui/src/frontend/router.ts b/ui/src/frontend/router.ts
index 1057d8014..54e0144af 100644
--- a/ui/src/frontend/router.ts
+++ b/ui/src/frontend/router.ts
@@ -77,6 +77,8 @@ const routeArgs = record({
ts: optStr,
dur: optStr,
tid: optStr,
+ pid: optStr,
+ query: optStr,
});
type RouteArgs = ValidatedType<typeof routeArgs>;