Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / importer / importer_uma.cc
blob839dd6e68d397c4b09ba878b8006fa32cb613baf
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
3 // found in the LICENSE file.
5 #include "build/build_config.h"
6 #include "chrome/browser/importer/importer_uma.h"
8 namespace importer {
10 namespace {
12 // The enum used to register importer use.
13 enum ImporterTypeMetrics {
14 IMPORTER_METRICS_UNKNOWN = 0,
15 #if defined(OS_WIN)
16 IMPORTER_METRICS_IE = 1,
17 #endif
18 IMPORTER_METRICS_FIREFOX2 = 2, // obsolete
19 IMPORTER_METRICS_FIREFOX3 = 3,
20 #if defined(OS_MACOSX)
21 IMPORTER_METRICS_SAFARI = 4,
22 #endif
23 IMPORTER_METRICS_GOOGLE_TOOLBAR5 = 5, // obsolete
24 IMPORTER_METRICS_BOOKMARKS_FILE = 6,
26 // Insert new values here. Never remove any existing values, as this enum is
27 // used to bucket a UMA histogram, and removing values breaks that.
28 IMPORTER_METRICS_SIZE
31 } // namespace
33 void LogImporterUseToMetrics(const std::string& metric_postfix,
34 ImporterType type) {
35 ImporterTypeMetrics metrics_type = IMPORTER_METRICS_UNKNOWN;
36 switch (type) {
37 case TYPE_UNKNOWN:
38 metrics_type = IMPORTER_METRICS_UNKNOWN;
39 break;
40 #if defined(OS_WIN)
41 case TYPE_IE:
42 metrics_type = IMPORTER_METRICS_IE;
43 break;
44 #endif
45 case TYPE_FIREFOX:
46 metrics_type = IMPORTER_METRICS_FIREFOX3;
47 break;
48 #if defined(OS_MACOSX)
49 case TYPE_SAFARI:
50 metrics_type = IMPORTER_METRICS_SAFARI;
51 break;
52 #endif
53 case TYPE_BOOKMARKS_FILE:
54 metrics_type = IMPORTER_METRICS_BOOKMARKS_FILE;
55 break;
58 // Note: This leaks memory, which is the expected behavior as the factory
59 // creates and owns the histogram.
60 base::HistogramBase* histogram =
61 base::LinearHistogram::FactoryGet(
62 "Import.ImporterType." + metric_postfix,
64 IMPORTER_METRICS_SIZE,
65 IMPORTER_METRICS_SIZE + 1,
66 base::HistogramBase::kUmaTargetedHistogramFlag);
67 histogram->Add(metrics_type);
70 } // namespace importer