Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/translate/translate_manager_metrics.cc

Issue 14762014: Translate: move UMA related code in TranslateManager to TranslateManagerMetrics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typos Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/translate/translate_manager_metrics.h" 5 #include "chrome/browser/translate/translate_manager_metrics.h"
6 6
7 #include "base/basictypes.h"
7 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
8 9
9 namespace { 10 namespace {
10 11
11 const char kTranslateInitiationStatus[] = "Translate.InitiationStatus"; 12 // Constant string values to indicate UMA names. All entries should have
13 // a corresponding index in MetricsNameIndex and an entry in |kMetricsEntries|.
14 const char kTranslateInitiationStatus[] =
15 "Translate.InitiationStatus";
16 const char kTranslateReportLanguageDetectionError[] =
17 "Translate.ReportLanguageDetectionError";
18 const char kTranslateServerReportedUnsupportedLanguage[] =
19 "Translate.ServerReportedUnsupportedLanguage";
20
21 struct MetricsEntry {
22 TranslateManagerMetrics::MetricsNameIndex index;
23 const char* const name;
24 };
25
26 // This entry table should be updated when new UMA items are added.
27 const MetricsEntry kMetricsEntries[] = {
28 { TranslateManagerMetrics::UMA_INITIATION_STATUS,
29 kTranslateInitiationStatus },
30 { TranslateManagerMetrics::UMA_LANGUAGE_DETECTION_ERROR,
31 kTranslateReportLanguageDetectionError },
32 { TranslateManagerMetrics::UMA_SERVER_REPORTED_UNSUPPORTED_LANGUAGE,
33 kTranslateServerReportedUnsupportedLanguage },
34 };
35
36 COMPILE_ASSERT(arraysize(kMetricsEntries) == TranslateManagerMetrics::UMA_MAX,
37 arraysize_of_kMetricsEntries_should_be_UMA_MAX);
12 38
13 } // namespace 39 } // namespace
14 40
15 namespace TranslateManagerMetrics { 41 namespace TranslateManagerMetrics {
16 42
17 void ReportInitiationStatus(InitiationStatusType type) { 43 void ReportInitiationStatus(InitiationStatusType type) {
18 UMA_HISTOGRAM_ENUMERATION(kTranslateInitiationStatus, 44 UMA_HISTOGRAM_ENUMERATION(kTranslateInitiationStatus,
19 type, 45 type,
20 INITIATION_STATUS_MAX); 46 INITIATION_STATUS_MAX);
21 } 47 }
22 48
23 const char* GetMetricsName(MetricsNameIndex index) { 49 void ReportLanguageDetectionError() {
24 const char* names[] = { 50 UMA_HISTOGRAM_COUNTS(kTranslateReportLanguageDetectionError, 1);
25 kTranslateInitiationStatus,
26 };
27 CHECK(index < UMA_MAX);
28 return names[index];
29 } 51 }
30 52
31 // TODO(toyoshim): Move UMA related code in TranslateManager to 53 void ReportUnsupportedLanguage() {
32 // TranslateManagerMetrics. 54 UMA_HISTOGRAM_COUNTS(kTranslateServerReportedUnsupportedLanguage, 1);
55 }
56
57 const char* GetMetricsName(MetricsNameIndex index) {
58 for (size_t i = 0; i < arraysize(kMetricsEntries); ++i) {
59 if (kMetricsEntries[i].index == index)
60 return kMetricsEntries[i].name;
61 }
62 NOTREACHED();
63 return NULL;
64 }
33 65
34 } // namespace TranslateManagerMetrics 66 } // namespace TranslateManagerMetrics
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager_metrics.h ('k') | chrome/browser/translate/translate_manager_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698