File: text_formatting_metrics_android.h

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (143 lines) | stat: -rw-r--r-- 6,308 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_ACCESSIBILITY_TEXT_FORMATTING_METRICS_ANDROID_H_
#define CONTENT_BROWSER_ACCESSIBILITY_TEXT_FORMATTING_METRICS_ANDROID_H_

#include <optional>
#include <string_view>

#include "base/time/time.h"
#include "content/common/content_export.h"

namespace content {

inline constexpr std::string_view kTextFormattingTextLengthMetric =
    "Accessibility.Android.TextFormatting.TextLength";
inline constexpr std::string_view kTextFormattingTextLengthNoStyleDataMetric =
    "Accessibility.Android.TextFormatting.TextLength.NoStyleData";

inline constexpr std::string_view kTextFormattingTotalDurationMetric =
    "Accessibility.Android.TextFormatting.Performance.TotalDuration";
inline constexpr std::string_view
    kTextFormattingTotalDurationNoStyleDataMetric =
        "Accessibility.Android.TextFormatting.Performance.TotalDuration."
        "NoStyleData";
inline constexpr std::string_view kTextFormattingGetTextContentDurationMetric =
    "Accessibility.Android.TextFormatting.Performance.GetTextContentDuration";
inline constexpr std::string_view
    kTextFormattingGetTextContentDurationNoStyleDataMetric =
        "Accessibility.Android.TextFormatting.Performance."
        "GetTextContentDuration.NoStyleData";
inline constexpr std::string_view kTextFormattingToJavaDataDurationMetric =
    "Accessibility.Android.TextFormatting.Performance.ToJavaDataDuration";
inline constexpr std::string_view
    kTextFormattingToJavaDataDurationNoStyleDataMetric =
        "Accessibility.Android.TextFormatting.Performance.ToJavaDataDuration."
        "NoStyleData";
inline constexpr std::string_view kTextFormattingSetAniTextDurationMetric =
    "Accessibility.Android.TextFormatting.Performance.SetAniTextDuration";
inline constexpr std::string_view
    kTextFormattingSetAniTextDurationNoStyleDataMetric =
        "Accessibility.Android.TextFormatting.Performance.SetAniTextDuration."
        "NoStyleData";

inline constexpr std::string_view kTextFormattingRangesTotalCountMetric =
    "Accessibility.Android.TextFormatting.Ranges.TotalCount";

inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength0Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength.0";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength1To10Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength.1To10";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength11To25Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength.11To25";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength26To50Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength.26To50";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength51To100Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength."
        "51To100";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength101To250Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength."
        "101To250";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength251To500Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength."
        "251To500";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLength501To1000Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength."
        "501To1000";
inline constexpr std::string_view
    kTextFormattingRangesCountForTextLengthOver1000Metric =
        "Accessibility.Android.TextFormatting.Ranges.CountForTextLength."
        "Over1000";

inline constexpr std::string_view kTextFormattingDurationForRangeCount0Metric =
    "Accessibility.Android.TextFormatting.Performance.DurationForRangeCount.0";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCount1To5Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.1To5";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCount6To10Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.6To10";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCount11To20Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.11To20";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCount21To40Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.21To40";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCount41To80Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.41To80";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCount81To160Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.81To160";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCount161To320Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.161To320";
inline constexpr std::string_view
    kTextFormattingDurationForRangeCountOver320Metric =
        "Accessibility.Android.TextFormatting.Performance."
        "DurationForRangeCount.Over320";

enum class TextFormattingMetric {
  kTotalDuration,
  kGetTextContentDuration,
  kToJavaDataDuration,
  kSetAniTextDuration,
};

CONTENT_EXPORT void RecordTextFormattingTextLengthHistogram(
    int length,
    std::optional<bool> has_style_data = std::nullopt);

CONTENT_EXPORT void RecordTextFormattingDurationHistogram(
    TextFormattingMetric metric,
    base::TimeDelta duration,
    std::optional<bool> has_style_data = std::nullopt);

CONTENT_EXPORT void RecordTextFormattingRangeCountsForTextLengthHistogram(
    std::u16string_view text,
    int ranges_count);

CONTENT_EXPORT void RecordTextFormattingDurationForRangeCountHistogram(
    int ranges_count,
    base::TimeDelta total_duration);

}  // namespace content

#endif  // CONTENT_BROWSER_ACCESSIBILITY_TEXT_FORMATTING_METRICS_ANDROID_H_