blob: 1e5c4538e0675c3a9c9f32140888576e857d7209 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdint.h>
#include "ash/public/interfaces/process_creation_time_recorder.mojom.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace aura {
class Window;
namespace gfx {
struct PresentationFeedback;
namespace ash {
class TimeToFirstPresentRecorderTestApi;
// Used for tracking the time main started to the time the first bits make it
// the screen and logging a histogram of the time. Chrome is responsible for
// providing the start time by way of ProcessCreationTimeRecorder.
// This only logs the time to present the primary root window.
class TimeToFirstPresentRecorder : public mojom::ProcessCreationTimeRecorder {
explicit TimeToFirstPresentRecorder(aura::Window* window);
~TimeToFirstPresentRecorder() override;
void Bind(mojom::ProcessCreationTimeRecorderRequest request);
friend class TimeToFirstPresentRecorderTestApi;
// If both times are available the time to present is logged.
void LogTime();
// Callback from the compositor when it presented a valid frame.
void DidPresentCompositorFrame(const gfx::PresentationFeedback& feedback);
base::TimeDelta time_to_first_present() const {
return present_time_ - process_creation_time_;
// mojom::ProcessCreationTimeRecorder:
void SetMainProcessCreationTime(base::TimeTicks start_time) override;
base::TimeTicks process_creation_time_;
base::TimeTicks present_time_;
// Only used by tests. If valid it's Run() when both times are determined.
base::OnceClosure log_callback_;
mojo::Binding<mojom::ProcessCreationTimeRecorder> binding_{this};
} // namespace ash