class CpuProfilerStage extends StreamingStage implements CodeNavigator.Listener {

  public void setAndSelectCapture(long traceId) {
    // This workflow is called when a capture is clicked in the UI.
    if (getStudioProfilers().getIdeServices().getFeatureConfig().isCpuCaptureStageEnabled()) {
      // TODO (b/132268755): Request / Get Trace file if cached for CpuCaptureStage. Consider if we need to change how this is triggered.
      // Not implemented due to not yet parsing / loading traces in the CpuCaptureStage.
      goToCaptureStage(traceId);
    }
    else {
      CompletableFuture<CpuCapture> future = getCaptureFuture(traceId);
      if (future == null) {
        setCaptureState(myInProgressTraceInfo.equals(Cpu.CpuTraceInfo.getDefaultInstance()) ? CaptureState.IDLE : CaptureState.CAPTURING);
      }
      else {
        future.handleAsync((capture, exception) -> {
          setCaptureState(myInProgressTraceInfo.equals(Cpu.CpuTraceInfo.getDefaultInstance()) ? CaptureState.IDLE : CaptureState.CAPTURING);
          if (capture != null) {
            setAndSelectCapture(capture);
            setCaptureDetails(DEFAULT_CAPTURE_DETAILS);
          }
          return capture;
        }, getStudioProfilers().getIdeServices().getMainExecutor());
      }
    }
  }

  public  CpuProfilerStage(@NotNull StudioProfilers profilers);
  public  CpuProfilerStage(@NotNull StudioProfilers profilers, @Nullable File importedTrace);
  @VisibleForTesting  CpuProfilerStage(@NotNull StudioProfilers profilers, @Nullable File importedTrace, @NotNull CpuCaptureParser captureParser);

}