def GetTimeStampEventNameAndProcess(browser_process, surface_flinger_process,
                                    gpu_process):
  """ Returns the name of the event used to count frame timestamps, and the
      process that produced the events.
  """
  if surface_flinger_process:
    return 'vsync_before', surface_flinger_process

  drm_event_name = 'DrmEventFlipComplete'
  display_rendering_stats = 'BenchmarkInstrumentation::DisplayRenderingStats'
  if gpu_process:
    # Look for Drm events first. If there are no Drm events, then look for
    # display rendering stats (which lives in the gpu process with viz).
    for event_name in (drm_event_name, display_rendering_stats):
      for event in gpu_process.IterAllSlicesOfName(event_name):
        if 'data' in event.args and event.args['data']['frame_count'] == 1:
          return event_name, gpu_process

  return display_rendering_stats, browser_process