OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/autofill/autofill_metrics.h" | 5 #include "chrome/browser/autofill/autofill_metrics.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/autofill/autofill_type.h" | 10 #include "chrome/browser/autofill/autofill_type.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Interpolate the |metric| with the |group|, so that all metrics for a given | 153 // Interpolate the |metric| with the |group|, so that all metrics for a given |
154 // |group| are adjacent. | 154 // |group| are adjacent. |
155 return (group * num_possible_metrics) + metric; | 155 return (group * num_possible_metrics) + metric; |
156 } | 156 } |
157 | 157 |
158 // A version of the UMA_HISTOGRAM_ENUMERATION macro that allows the |name| | 158 // A version of the UMA_HISTOGRAM_ENUMERATION macro that allows the |name| |
159 // to vary over the program's runtime. | 159 // to vary over the program's runtime. |
160 void LogUMAHistogramEnumeration(const std::string& name, | 160 void LogUMAHistogramEnumeration(const std::string& name, |
161 int sample, | 161 int sample, |
162 int boundary_value) { | 162 int boundary_value) { |
163 // We can't use the UMA_HISTOGRAM_ENUMERATION macro here because the histogram | 163 // Note: This leaks memory, which is expected behavior. |
164 // name can vary over the duration of the program. | 164 base::HistogramBase* histogram = |
165 // Note that this leaks memory; that is expected behavior. | |
166 base::HistogramBase* counter = | |
167 base::LinearHistogram::FactoryGet( | 165 base::LinearHistogram::FactoryGet( |
168 name, | 166 name, |
169 1, | 167 1, |
170 boundary_value, | 168 boundary_value, |
171 boundary_value + 1, | 169 boundary_value + 1, |
172 base::HistogramBase::kUmaTargetedHistogramFlag); | 170 base::HistogramBase::kUmaTargetedHistogramFlag); |
173 counter->Add(sample); | 171 histogram->Add(sample); |
| 172 } |
| 173 |
| 174 // A version of the UMA_HISTOGRAM_LONG_TIMES macro that allows the |name| |
| 175 // to vary over the program's runtime. |
| 176 void LogUMAHistogramLongTimes(const std::string& name, |
| 177 const base::TimeDelta& duration) { |
| 178 // Note: This leaks memory, which is expected behavior. |
| 179 base::HistogramBase* histogram = |
| 180 base::Histogram::FactoryTimeGet( |
| 181 name, |
| 182 base::TimeDelta::FromMilliseconds(1), |
| 183 base::TimeDelta::FromHours(1), |
| 184 50, |
| 185 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 186 histogram->AddTime(duration); |
174 } | 187 } |
175 | 188 |
176 // Logs a type quality metric. The primary histogram name is constructed based | 189 // Logs a type quality metric. The primary histogram name is constructed based |
177 // on |base_name| and |experiment_id|. The field-specific histogram name also | 190 // on |base_name| and |experiment_id|. The field-specific histogram name also |
178 // factors in the |field_type|. Logs a sample of |metric|, which should be in | 191 // factors in the |field_type|. Logs a sample of |metric|, which should be in |
179 // the range [0, |num_possible_metrics|). | 192 // the range [0, |num_possible_metrics|). |
180 void LogTypeQualityMetric(const std::string& base_name, | 193 void LogTypeQualityMetric(const std::string& base_name, |
181 const int metric, | 194 const int metric, |
182 const int num_possible_metrics, | 195 const int num_possible_metrics, |
183 const AutofillFieldType field_type, | 196 const AutofillFieldType field_type, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 NUM_INFO_BAR_METRICS); | 274 NUM_INFO_BAR_METRICS); |
262 } | 275 } |
263 | 276 |
264 void AutofillMetrics::LogAutocheckoutInfoBarMetric(InfoBarMetric metric) const { | 277 void AutofillMetrics::LogAutocheckoutInfoBarMetric(InfoBarMetric metric) const { |
265 DCHECK(metric < NUM_INFO_BAR_METRICS); | 278 DCHECK(metric < NUM_INFO_BAR_METRICS); |
266 | 279 |
267 UMA_HISTOGRAM_ENUMERATION("Autofill.AutocheckoutInfoBar", metric, | 280 UMA_HISTOGRAM_ENUMERATION("Autofill.AutocheckoutInfoBar", metric, |
268 NUM_INFO_BAR_METRICS); | 281 NUM_INFO_BAR_METRICS); |
269 } | 282 } |
270 | 283 |
| 284 void AutofillMetrics::LogRequestAutocompleteUiDuration( |
| 285 const base::TimeDelta& duration, |
| 286 autofill::DialogType dialog_type, |
| 287 DialogDismissalAction dismissal_action) const { |
| 288 std::string prefix; |
| 289 switch (dialog_type) { |
| 290 case autofill::DIALOG_TYPE_AUTOCHECKOUT: |
| 291 prefix = "Autocheckout"; |
| 292 break; |
| 293 |
| 294 case autofill::DIALOG_TYPE_REQUEST_AUTOCOMPLETE: |
| 295 prefix = "RequestAutocomplete"; |
| 296 break; |
| 297 } |
| 298 |
| 299 std::string suffix; |
| 300 switch (dismissal_action) { |
| 301 case DIALOG_ACCEPTED: |
| 302 suffix = "Submit"; |
| 303 break; |
| 304 |
| 305 case DIALOG_CANCELED: |
| 306 suffix = "Cancel"; |
| 307 break; |
| 308 } |
| 309 |
| 310 LogUMAHistogramLongTimes(prefix + ".UiDuration", duration); |
| 311 LogUMAHistogramLongTimes(prefix + ".UiDuration." + suffix, duration); |
| 312 } |
| 313 |
271 void AutofillMetrics::LogDeveloperEngagementMetric( | 314 void AutofillMetrics::LogDeveloperEngagementMetric( |
272 DeveloperEngagementMetric metric) const { | 315 DeveloperEngagementMetric metric) const { |
273 DCHECK(metric < NUM_DEVELOPER_ENGAGEMENT_METRICS); | 316 DCHECK(metric < NUM_DEVELOPER_ENGAGEMENT_METRICS); |
274 | 317 |
275 UMA_HISTOGRAM_ENUMERATION("Autofill.DeveloperEngagement", metric, | 318 UMA_HISTOGRAM_ENUMERATION("Autofill.DeveloperEngagement", metric, |
276 NUM_DEVELOPER_ENGAGEMENT_METRICS); | 319 NUM_DEVELOPER_ENGAGEMENT_METRICS); |
277 } | 320 } |
278 | 321 |
279 void AutofillMetrics::LogHeuristicTypePrediction( | 322 void AutofillMetrics::LogHeuristicTypePrediction( |
280 FieldTypeQualityMetric metric, | 323 FieldTypeQualityMetric metric, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 427 |
385 void AutofillMetrics::LogServerExperimentIdForQuery( | 428 void AutofillMetrics::LogServerExperimentIdForQuery( |
386 const std::string& experiment_id) const { | 429 const std::string& experiment_id) const { |
387 LogServerExperimentId("Autofill.ServerExperimentId.Query", experiment_id); | 430 LogServerExperimentId("Autofill.ServerExperimentId.Query", experiment_id); |
388 } | 431 } |
389 | 432 |
390 void AutofillMetrics::LogServerExperimentIdForUpload( | 433 void AutofillMetrics::LogServerExperimentIdForUpload( |
391 const std::string& experiment_id) const { | 434 const std::string& experiment_id) const { |
392 LogServerExperimentId("Autofill.ServerExperimentId.Upload", experiment_id); | 435 LogServerExperimentId("Autofill.ServerExperimentId.Upload", experiment_id); |
393 } | 436 } |
OLD | NEW |