Skip to content

Commit

Permalink
Add getProfileFlowInfo selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstange committed Nov 7, 2024
1 parent dbc0f75 commit 8ccc7a6
Show file tree
Hide file tree
Showing 5 changed files with 662 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/actions/profile-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,53 @@ export function showProvidedTracks(
};
}

export function showProvidedThreads(
threadsToShow: Set<ThreadIndex>
): ThunkAction<void> {
return (dispatch, getState) => {
const globalTracks = getGlobalTracks(getState());
const localTracksByPid = getLocalTracksByPid(getState());

const globalTracksToShow: Set<TrackIndex> = new Set();
const localTracksByPidToShow: Map<Pid, Set<TrackIndex>> = new Map();

for (const [globalTrackIndex, globalTrack] of globalTracks.entries()) {
if (globalTrack.type !== 'process') {
continue;
}
const { mainThreadIndex, pid } = globalTrack;
if (mainThreadIndex !== null && threadsToShow.has(mainThreadIndex)) {
globalTracksToShow.add(globalTrackIndex);
}
const localTracks = localTracksByPid.get(pid);
if (localTracks === undefined) {
continue;
}

for (const [localTrackIndex, localTrack] of localTracks.entries()) {
if (localTrack.type !== 'thread') {
continue;
}
if (threadsToShow.has(localTrack.threadIndex)) {
const localTracksToShow = localTracksByPidToShow.get(pid);
if (localTracksToShow === undefined) {
localTracksByPidToShow.set(pid, new Set([localTrackIndex]));
} else {
localTracksToShow.add(localTrackIndex);
}
globalTracksToShow.add(globalTrackIndex);
}
}
}

dispatch({
type: 'SHOW_PROVIDED_TRACKS',
globalTracksToShow,
localTracksByPidToShow,
});
};
}

/**
* This action makes the tracks that are provided hidden.
*/
Expand Down
Loading

0 comments on commit 8ccc7a6

Please sign in to comment.