blob: 3a2330998bafa6259cf685ead2acef82839681f6 [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.
#ifndef CHROME_BROWSER_VR_METRICS_HELPER_H_
#define CHROME_BROWSER_VR_METRICS_HELPER_H_
#include <string>
#include "base/optional.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"
#include "chrome/browser/vr/assets_component_update_status.h"
#include "chrome/browser/vr/assets_load_status.h"
#include "chrome/browser/vr/mode.h"
namespace base {
class Version;
} // namespace base
namespace vr {
// Helper to collect VR UMA metrics.
//
// For thread-safety, all functions must be called in sequence.
class MetricsHelper {
public:
MetricsHelper();
~MetricsHelper();
void OnComponentReady(const base::Version& version);
void OnEnter(Mode mode);
void OnRegisteredComponent();
void OnComponentUpdated(AssetsComponentUpdateStatus status,
const base::Optional<base::Version>& version);
void OnAssetsLoaded(AssetsLoadStatus status,
const base::Version& component_version);
void OnChromeStarted();
private:
base::Optional<base::Time>& GetEnterTime(Mode mode);
void LogLatencyIfWaited(Mode mode, const base::Time& now);
base::Optional<base::Time> enter_vr_time_;
base::Optional<base::Time> enter_vr_browsing_time_;
base::Optional<base::Time> enter_web_vr_time_;
base::Optional<base::Time> chrome_start_time_;
bool logged_ready_duration_on_chrome_start_ = false;
bool component_ready_ = false;
SEQUENCE_CHECKER(sequence_checker_);
};
} // namespace vr
#endif // CHROME_BROWSER_VR_METRICS_HELPER_H_