ProjectingObserverChromeos: Drop DBusThreadManager dependency for better testing.
[chromium-blink-merge.git] / components / translate / core / common / translate_metrics.h
blobb6cc184de39d612d62cfd561790730699f9b699f
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_TRANSLATE_CORE_COMMON_TRANSLATE_METRICS_H_
6 #define COMPONENTS_TRANSLATE_CORE_COMMON_TRANSLATE_METRICS_H_
8 #include <string>
10 #include "base/time/time.h"
12 namespace translate {
14 // An indexing type to query each UMA entry name via GetMetricsName() function.
15 // Note: |kMetricsEntries| should be updated when a new entry is added here.
16 enum MetricsNameIndex {
17 UMA_LANGUAGE_DETECTION,
18 UMA_CONTENT_LANGUAGE,
19 UMA_HTML_LANG,
20 UMA_LANGUAGE_VERIFICATION,
21 UMA_TIME_TO_BE_READY,
22 UMA_TIME_TO_LOAD,
23 UMA_TIME_TO_TRANSLATE,
24 UMA_USER_ACTION_DURATION,
25 UMA_PAGE_SCHEME,
26 UMA_SIMILAR_LANGUAGE_MATCH,
27 UMA_MAX,
30 // A page may provide a Content-Language HTTP header or a META tag.
31 // TranslateHelper checks if a server provides a valid Content-Language.
32 enum LanguageCheckType {
33 LANGUAGE_NOT_PROVIDED,
34 LANGUAGE_VALID,
35 LANGUAGE_INVALID,
36 LANGUAGE_MAX,
39 // When a valid Content-Language is provided, TranslateHelper checks if a
40 // server provided Content-Language matches to a language CLD determined.
41 enum LanguageVerificationType {
42 LANGUAGE_VERIFICATION_CLD_DISABLED, // obsolete
43 LANGUAGE_VERIFICATION_CLD_ONLY,
44 LANGUAGE_VERIFICATION_UNKNOWN,
45 LANGUAGE_VERIFICATION_CLD_AGREE,
46 LANGUAGE_VERIFICATION_CLD_DISAGREE,
47 LANGUAGE_VERIFICATION_TRUST_CLD,
48 LANGUAGE_VERIFICATION_CLD_COMPLEMENT_SUB_CODE,
49 LANGUAGE_VERIFICATION_MAX,
52 // Scheme type of pages Chrome is going to translate.
53 enum SchemeType {
54 SCHEME_HTTP,
55 SCHEME_HTTPS,
56 SCHEME_OTHERS,
57 SCHEME_MAX,
60 // Called after TranslateHelper verifies a server providing Content-Language
61 // header. |provided_code| contains a Content-Language header value which a
62 // server provides. It can be empty string when a server doesn't provide it.
63 // |revised_code| is a value modified by format error corrector.
64 void ReportContentLanguage(const std::string& provided_code,
65 const std::string& revised_code);
67 // Called after TranslateHelper verifies a page providing html lang attribute.
68 // |provided_code| contains a html lang attribute which a page provides. It can
69 // be empty string when a page doesn't provide it. |revised_code| is a value
70 // modified by format error corrector.
71 void ReportHtmlLang(const std::string& provided_code,
72 const std::string& revised_code);
74 // Called when CLD verifies Content-Language header.
75 void ReportLanguageVerification(LanguageVerificationType type);
77 // Called when the Translate Element library is ready.
78 void ReportTimeToBeReady(double time_in_msec);
80 // Called when the Translate Element library is loaded.
81 void ReportTimeToLoad(double time_in_msec);
83 // Called when a page translation is finished.
84 void ReportTimeToTranslate(double time_in_msec);
86 // Called when a translation is triggered.
87 void ReportUserActionDuration(base::TimeTicks begin, base::TimeTicks end);
89 // Called when a translation is triggered.
90 void ReportPageScheme(const std::string& scheme);
92 // Called when CLD detects page language.
93 void ReportLanguageDetectionTime(base::TimeTicks begin, base::TimeTicks end);
95 // Called when CLD agreed on a language which is different, but in the similar
96 // language list.
97 void ReportSimilarLanguageMatch(bool match);
99 // Gets UMA name for an entry specified by |index|.
100 const char* GetMetricsName(MetricsNameIndex index);
102 } // namespace translate
104 #endif // COMPONENTS_TRANSLATE_CORE_COMMON_TRANSLATE_METRICS_H_