Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "chrome/browser/importer/importer_uma.h" | 6 #include "chrome/browser/importer/importer_uma.h" |
| 7 | 7 |
| 8 namespace importer { | 8 namespace importer { |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 // The enum used to register importer use. | 12 // The enum used to register importer use. |
| 13 enum ImporterTypeMetrics { | 13 enum ImporterTypeMetrics { |
| 14 IMPORTER_METRICS_UNKNOWN = 0, | 14 IMPORTER_METRICS_UNKNOWN = 0, |
| 15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 16 IMPORTER_METRICS_IE = 1, | 16 IMPORTER_METRICS_IE = 1, |
| 17 #endif | 17 #endif |
| 18 IMPORTER_METRICS_FIREFOX2 = 2, // obsolete | 18 IMPORTER_METRICS_FIREFOX2 = 2, // obsolete |
| 19 IMPORTER_METRICS_FIREFOX3 = 3, | 19 IMPORTER_METRICS_FIREFOX3 = 3, |
| 20 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
| 21 IMPORTER_METRICS_SAFARI = 4, | 21 IMPORTER_METRICS_SAFARI = 4, |
| 22 #endif | 22 #endif |
| 23 IMPORTER_METRICS_GOOGLE_TOOLBAR5 = 5, // obsolete | 23 IMPORTER_METRICS_GOOGLE_TOOLBAR5 = 5, // obsolete |
| 24 IMPORTER_METRICS_BOOKMARKS_FILE = 6, | 24 IMPORTER_METRICS_BOOKMARKS_FILE = 6, |
| 25 IMPORTER_METRICS_EDGE = 7, | |
|
Ilya Sherman
2015/11/26 02:04:43
nit: Should this be guarded with an "#if defined(O
forshaw
2015/11/30 12:57:58
Acknowledged.
| |
| 25 | 26 |
| 26 // Insert new values here. Never remove any existing values, as this enum is | 27 // 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 // used to bucket a UMA histogram, and removing values breaks that. |
| 28 IMPORTER_METRICS_SIZE | 29 IMPORTER_METRICS_SIZE |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 } // namespace | 32 } // namespace |
| 32 | 33 |
| 33 void LogImporterUseToMetrics(const std::string& metric_postfix, | 34 void LogImporterUseToMetrics(const std::string& metric_postfix, |
| 34 ImporterType type) { | 35 ImporterType type) { |
| 35 ImporterTypeMetrics metrics_type = IMPORTER_METRICS_UNKNOWN; | 36 ImporterTypeMetrics metrics_type = IMPORTER_METRICS_UNKNOWN; |
| 36 switch (type) { | 37 switch (type) { |
| 37 case TYPE_UNKNOWN: | 38 case TYPE_UNKNOWN: |
| 38 metrics_type = IMPORTER_METRICS_UNKNOWN; | 39 metrics_type = IMPORTER_METRICS_UNKNOWN; |
| 39 break; | 40 break; |
| 40 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 41 case TYPE_IE: | 42 case TYPE_IE: |
| 42 metrics_type = IMPORTER_METRICS_IE; | 43 metrics_type = IMPORTER_METRICS_IE; |
| 43 break; | 44 break; |
| 45 case TYPE_EDGE: | |
| 46 metrics_type = IMPORTER_METRICS_EDGE; | |
| 47 break; | |
| 44 #endif | 48 #endif |
| 45 case TYPE_FIREFOX: | 49 case TYPE_FIREFOX: |
| 46 metrics_type = IMPORTER_METRICS_FIREFOX3; | 50 metrics_type = IMPORTER_METRICS_FIREFOX3; |
| 47 break; | 51 break; |
| 48 #if defined(OS_MACOSX) | 52 #if defined(OS_MACOSX) |
| 49 case TYPE_SAFARI: | 53 case TYPE_SAFARI: |
| 50 metrics_type = IMPORTER_METRICS_SAFARI; | 54 metrics_type = IMPORTER_METRICS_SAFARI; |
| 51 break; | 55 break; |
| 52 #endif | 56 #endif |
| 53 case TYPE_BOOKMARKS_FILE: | 57 case TYPE_BOOKMARKS_FILE: |
| 54 metrics_type = IMPORTER_METRICS_BOOKMARKS_FILE; | 58 metrics_type = IMPORTER_METRICS_BOOKMARKS_FILE; |
| 55 break; | 59 break; |
| 56 } | 60 } |
| 57 | 61 |
| 58 // Note: This leaks memory, which is the expected behavior as the factory | 62 // Note: This leaks memory, which is the expected behavior as the factory |
| 59 // creates and owns the histogram. | 63 // creates and owns the histogram. |
| 60 base::HistogramBase* histogram = | 64 base::HistogramBase* histogram = |
| 61 base::LinearHistogram::FactoryGet( | 65 base::LinearHistogram::FactoryGet( |
| 62 "Import.ImporterType." + metric_postfix, | 66 "Import.ImporterType." + metric_postfix, |
| 63 1, | 67 1, |
| 64 IMPORTER_METRICS_SIZE, | 68 IMPORTER_METRICS_SIZE, |
| 65 IMPORTER_METRICS_SIZE + 1, | 69 IMPORTER_METRICS_SIZE + 1, |
| 66 base::HistogramBase::kUmaTargetedHistogramFlag); | 70 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 67 histogram->Add(metrics_type); | 71 histogram->Add(metrics_type); |
| 68 } | 72 } |
| 69 | 73 |
| 70 } // namespace importer | 74 } // namespace importer |
| OLD | NEW |