summarylogtreecommitdiffstats
path: root/0005-Revert-Trace-ICU-object-creation-in-ICU.CreateInstan.patch
blob: bf89b54beefcf6269ed8af4acc8e5a9bdfce436c (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
From 9c5607e39aaf34f866ca2b815196953ec3818098 Mon Sep 17 00:00:00 2001
From: Daniel Playfair Cal <daniel.playfair.cal@gmail.com>
Date: Sat, 11 Apr 2020 12:32:25 +1000
Subject: [PATCH 5/8] Revert "Trace ICU object creation in "ICU.CreateInstance"
 UMA histogram"

This reverts commit 928bcad29884064f83bf05ecadf82369f8b4622f.
---
 DEPS                  |   2 +-
 base/i18n/icu_util.cc | 150 +++++++-----------------------------------
 2 files changed, 25 insertions(+), 127 deletions(-)

diff --git a/DEPS b/DEPS
index 95ff15cbf88c..fd23a935909f 100644
--- a/DEPS
+++ b/DEPS
@@ -1014,7 +1014,7 @@ deps = {
     Var('chromium_git') + '/chromium/deps/hunspell_dictionaries.git' + '@' + '6fdad5388130757e1efb58a14b8e7f9494625691',
 
   'src/third_party/icu':
-    Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '13cfcd5874f6c39c34ec57fa5295e7910ae90b8d',
+    Var('chromium_git') + '/chromium/deps/icu.git' + '@' + 'd7aff76cf6bb0fbef3afa6c07718f78a80a70f8f',
 
   'src/third_party/icu4j': {
       'packages': [
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc
index 82022d5f490e..425a0b2a6648 100644
--- a/base/i18n/icu_util.cc
+++ b/base/i18n/icu_util.cc
@@ -350,134 +350,32 @@ void InitializeIcuTimeZone() {
 }
 
 const char kICUDataFile[] = "ICU.DataFile";
-const char kICUCreateInstance[] = "ICU.CreateInstance";
-
-enum class ICUCreateInstance {
-  kCharacterBreakIterator = 0,
-  kWordBreakIterator = 1,
-  kLineBreakIterator = 2,
-  kLineBreakIteratorTypeLoose = 3,
-  kLineBreakIteratorTypeNormal = 4,
-  kLineBreakIteratorTypeStrict = 5,
-  kSentenceBreakIterator = 6,
-  kTitleBreakIterator = 7,
-  kThaiBreakEngine = 8,
-  kLaoBreakEngine = 9,
-  kBurmeseBreakEngine = 10,
-  kKhmerBreakEngine = 11,
-  kChineseJapaneseBreakEngine = 12,
-
-  kMaxValue = kChineseJapaneseBreakEngine
-};
-
-// Callback functions to report the opening of ICU Data File, and creation of
-// key objects to UMA. This help us to understand what built-in ICU data files
-// are rarely used in the user's machines and the distribution of ICU usage.
-static void U_CALLCONV TraceICUEntry(const void*, int32_t fn_number) {
-  switch (fn_number) {
-    case UTRACE_UBRK_CREATE_CHARACTER:
-      base::UmaHistogramEnumeration(kICUCreateInstance,
-                                    ICUCreateInstance::kCharacterBreakIterator);
-      break;
-    case UTRACE_UBRK_CREATE_SENTENCE:
-      base::UmaHistogramEnumeration(kICUCreateInstance,
-                                    ICUCreateInstance::kSentenceBreakIterator);
-      break;
-    case UTRACE_UBRK_CREATE_TITLE:
-      base::UmaHistogramEnumeration(kICUCreateInstance,
-                                    ICUCreateInstance::kTitleBreakIterator);
-      break;
-    case UTRACE_UBRK_CREATE_WORD:
-      base::UmaHistogramEnumeration(kICUCreateInstance,
-                                    ICUCreateInstance::kWordBreakIterator);
-      break;
-    default:
-      return;
-  }
-}
 
-static void U_CALLCONV TraceICUData(const void* context,
-                                    int32_t fn_number,
-                                    int32_t level,
-                                    const char* fmt,
-                                    va_list args) {
-  switch (fn_number) {
-    case UTRACE_UDATA_DATA_FILE: {
-      std::string icu_data_file_name(va_arg(args, const char*));
-      va_end(args);
-      // Skip icu version specified prefix if exist.
-      // path is prefixed with icu version prefix such as "icudt65l-".
-      // Histogram only the part after the -.
-      if (icu_data_file_name.find("icudt") == 0) {
-        size_t dash = icu_data_file_name.find("-");
-        if (dash != std::string::npos) {
-          icu_data_file_name = icu_data_file_name.substr(dash + 1);
-        }
-      }
-      // UmaHistogramSparse should track less than 100 values.
-      // We currently have about total 55 built-in data files inside ICU
-      // so it fit the UmaHistogramSparse usage.
-      int hash = base::HashMetricName(icu_data_file_name);
-      base::UmaHistogramSparse(kICUDataFile, hash);
-      return;
-    }
-    case UTRACE_UBRK_CREATE_LINE: {
-      const char* lb_type = va_arg(args, const char*);
-      va_end(args);
-      ICUCreateInstance value;
-      switch (lb_type[0]) {
-        case '\0':
-          value = ICUCreateInstance::kLineBreakIterator;
-          break;
-        case 'l':
-          DCHECK(strcmp(lb_type, "loose") == 0);
-          value = ICUCreateInstance::kLineBreakIteratorTypeLoose;
-          break;
-        case 'n':
-          DCHECK(strcmp(lb_type, "normal") == 0);
-          value = ICUCreateInstance::kLineBreakIteratorTypeNormal;
-          break;
-        case 's':
-          DCHECK(strcmp(lb_type, "strict") == 0);
-          value = ICUCreateInstance::kLineBreakIteratorTypeStrict;
-          break;
-        default:
-          return;
-      }
-      base::UmaHistogramEnumeration(kICUCreateInstance, value);
-      return;
-    }
-    case UTRACE_UBRK_CREATE_BREAK_ENGINE: {
-      const char* script = va_arg(args, const char*);
-      va_end(args);
-      ICUCreateInstance value;
-      switch (script[0]) {
-        case 'H':
-          DCHECK(strcmp(script, "Hani") == 0);
-          value = ICUCreateInstance::kChineseJapaneseBreakEngine;
-          break;
-        case 'K':
-          DCHECK(strcmp(script, "Khmr") == 0);
-          value = ICUCreateInstance::kKhmerBreakEngine;
-          break;
-        case 'L':
-          DCHECK(strcmp(script, "Laoo") == 0);
-          value = ICUCreateInstance::kLaoBreakEngine;
-          break;
-        case 'M':
-          DCHECK(strcmp(script, "Mymr") == 0);
-          value = ICUCreateInstance::kBurmeseBreakEngine;
-          break;
-        case 'T':
-          DCHECK(strcmp(script, "Thai") == 0);
-          value = ICUCreateInstance::kThaiBreakEngine;
-          break;
-        default:
-          return;
+// Callback function to report the opening of ICU Data File to UMA.
+// This help us to understand what built-in ICU data files are rarely used
+// in the user's machines.
+static void U_CALLCONV TraceICUDataFile(const void* context,
+                                        int32_t fn_number,
+                                        int32_t level,
+                                        const char* fmt,
+                                        va_list args) {
+  if (fn_number == UTRACE_UDATA_DATA_FILE) {
+    std::string icu_data_file_name(va_arg(args, const char*));
+    va_end(args);
+    // Skip icu version specified prefix if exist.
+    // path is prefixed with icu version prefix such as "icudt65l-".
+    // Histogram only the part after the -.
+    if (icu_data_file_name.find("icudt") == 0) {
+      size_t dash = icu_data_file_name.find("-");
+      if (dash != std::string::npos) {
+        icu_data_file_name = icu_data_file_name.substr(dash + 1);
       }
-      base::UmaHistogramEnumeration(kICUCreateInstance, value);
-      return;
     }
+    // UmaHistogramSparse should track less than 100 values.
+    // We currently have about total 55 built-in data files inside ICU
+    // so it fit the UmaHistogramSparse usage.
+    int hash = base::HashMetricName(icu_data_file_name);
+    base::UmaHistogramSparse(kICUDataFile, hash);
   }
 }
 
@@ -491,7 +389,7 @@ bool DoCommonInitialization() {
   InitializeIcuTimeZone();
 
   const void* context = nullptr;
-  utrace_setFunctions(context, TraceICUEntry, nullptr, TraceICUData);
+  utrace_setFunctions(context, nullptr, nullptr, TraceICUDataFile);
   utrace_setLevel(UTRACE_VERBOSE);
   return true;
 }
-- 
2.26.1