chromium/components/translate/core/common/translate_metrics.h

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_TRANSLATE_CORE_COMMON_TRANSLATE_METRICS_H_
#define COMPONENTS_TRANSLATE_CORE_COMMON_TRANSLATE_METRICS_H_

#include "base/time/time.h"

namespace translate {

// Internals exposed for testing purposes. Should not be relied on by client
// code.
namespace metrics_internal {

// Constant string values to indicate UMA names.
extern const char kTranslateLanguageDetectionLanguageVerification[];
extern const char kTranslateTimeToBeReady[];
extern const char kTranslateTimeToLoad[];
extern const char kTranslateTimeToTranslate[];
extern const char kTranslateUserActionDuration[];
extern const char kTranslatePageScheme[];
extern const char kTranslateSimilarLanguageMatch[];
extern const char kTranslateLanguageDetectionConflict[];
extern const char kTranslateLanguageDeterminedDuration[];
extern const char kTranslatedLanguageDetectionContentLength[];
extern const char kTranslateCompactInfobarEvent[];

}  // namespace metrics_internal

// When a valid Content-Language is provided, TranslateAgent checks if a
// server provided Content-Language matches to a language the model determined.
// This enum is used for recording metrics. This enum should remain synchronized
// with the enum "TranslateLanguageVerification" in enums.xml.
enum class LanguageVerificationType {};

// Enum for the Translate.CompactInfobar.Event UMA histogram.
// Note: This enum is used to back an UMA histogram, and should be treated as
// append-only.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.infobar
// GENERATED_JAVA_CLASS_NAME_OVERRIDE: InfobarEvent
enum class InfobarEvent {};

// Called when CLD verifies Content-Language header.
void ReportLanguageVerification(LanguageVerificationType type);

// Called when the Translate Element library is ready.
void ReportTimeToBeReady(double time_in_msec);

// Called when the Translate Element library is loaded.
void ReportTimeToLoad(double time_in_msec);

// Called when a page translation is finished.
void ReportTimeToTranslate(double time_in_msec);

// Called when the page language is determined.
void ReportLanguageDeterminedDuration(base::TimeTicks begin,
                                      base::TimeTicks end);

// Called after when a translation starts.
void ReportTranslatedLanguageDetectionContentLength(size_t content_length);

// Called when the Android Messages or iOS Translate UI is shown.
void ReportCompactInfobarEvent(InfobarEvent event);

}  // namespace translate

#endif  // COMPONENTS_TRANSLATE_CORE_COMMON_TRANSLATE_METRICS_H_