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

Side by Side Diff: chrome/browser/importer/importer_uma.cc

Issue 18501013: Move most importer code to chrome/utility/importer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CanImport Created 7 years, 5 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/importer/importer_creator.h" 5 #include "build/build_config.h"
6 6 #include "chrome/browser/importer/importer_uma.h"
7 #include "base/logging.h"
8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/importer/bookmarks_file_importer.h"
10 #include "chrome/browser/importer/firefox3_importer.h"
11
12 #if defined(OS_WIN)
13 #include "chrome/browser/importer/ie_importer.h"
14 #endif
15
16 #if defined(OS_MACOSX)
17 #include <CoreFoundation/CoreFoundation.h>
18 #include "base/mac/foundation_util.h"
19 #include "chrome/browser/importer/safari_importer.h"
20 #endif
21 7
22 namespace importer { 8 namespace importer {
23 9
24 namespace { 10 namespace {
25 11
26 // The enum used to register importer use. 12 // The enum used to register importer use.
27 enum ImporterTypeMetrics { 13 enum ImporterTypeMetrics {
28 IMPORTER_METRICS_UNKNOWN = 0, 14 IMPORTER_METRICS_UNKNOWN = 0,
29 #if defined(OS_WIN) 15 #if defined(OS_WIN)
30 IMPORTER_METRICS_IE = 1, 16 IMPORTER_METRICS_IE = 1,
31 #endif 17 #endif
32 IMPORTER_METRICS_FIREFOX2 = 2, // obsolete 18 IMPORTER_METRICS_FIREFOX2 = 2, // obsolete
33 IMPORTER_METRICS_FIREFOX3 = 3, 19 IMPORTER_METRICS_FIREFOX3 = 3,
34 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
35 IMPORTER_METRICS_SAFARI = 4, 21 IMPORTER_METRICS_SAFARI = 4,
36 #endif 22 #endif
37 IMPORTER_METRICS_GOOGLE_TOOLBAR5 = 5, // obsolete 23 IMPORTER_METRICS_GOOGLE_TOOLBAR5 = 5, // obsolete
38 IMPORTER_METRICS_BOOKMARKS_FILE = 6, 24 IMPORTER_METRICS_BOOKMARKS_FILE = 6,
39 25
40 // Insert new values here. Never remove any existing values, as this enum is 26 // Insert new values here. Never remove any existing values, as this enum is
41 // used to bucket a UMA histogram, and removing values breaks that. 27 // used to bucket a UMA histogram, and removing values breaks that.
42 IMPORTER_METRICS_SIZE 28 IMPORTER_METRICS_SIZE
43 }; 29 };
44 30
45
46 } // namespace 31 } // namespace
47 32
48 Importer* CreateImporterByType(ImporterType type) {
49 switch (type) {
50 #if defined(OS_WIN)
51 case TYPE_IE:
52 return new IEImporter();
53 #endif
54 case TYPE_BOOKMARKS_FILE:
55 return new BookmarksFileImporter();
56 case TYPE_FIREFOX3:
57 return new Firefox3Importer();
58 #if defined(OS_MACOSX)
59 case TYPE_SAFARI:
60 return new SafariImporter(base::mac::GetUserLibraryPath());
61 #endif
62 default:
63 NOTREACHED();
64 return NULL;
65 }
66 NOTREACHED();
67 return NULL;
68 }
69
70 void LogImporterUseToMetrics(const std::string& metric_postfix, 33 void LogImporterUseToMetrics(const std::string& metric_postfix,
71 ImporterType type) { 34 ImporterType type) {
72 ImporterTypeMetrics metrics_type = IMPORTER_METRICS_UNKNOWN; 35 ImporterTypeMetrics metrics_type = IMPORTER_METRICS_UNKNOWN;
73 switch (type) { 36 switch (type) {
74 case TYPE_UNKNOWN: 37 case TYPE_UNKNOWN:
75 metrics_type = IMPORTER_METRICS_UNKNOWN; 38 metrics_type = IMPORTER_METRICS_UNKNOWN;
76 break; 39 break;
77 #if defined(OS_WIN) 40 #if defined(OS_WIN)
78 case TYPE_IE: 41 case TYPE_IE:
79 metrics_type = IMPORTER_METRICS_IE; 42 metrics_type = IMPORTER_METRICS_IE;
(...skipping 17 matching lines...) Expand all
97 base::HistogramBase* histogram = 60 base::HistogramBase* histogram =
98 base::LinearHistogram::FactoryGet( 61 base::LinearHistogram::FactoryGet(
99 "Import.ImporterType." + metric_postfix, 62 "Import.ImporterType." + metric_postfix,
100 1, 63 1,
101 IMPORTER_METRICS_SIZE, 64 IMPORTER_METRICS_SIZE,
102 IMPORTER_METRICS_SIZE + 1, 65 IMPORTER_METRICS_SIZE + 1,
103 base::HistogramBase::kUmaTargetedHistogramFlag); 66 base::HistogramBase::kUmaTargetedHistogramFlag);
104 histogram->Add(metrics_type); 67 histogram->Add(metrics_type);
105 } 68 }
106 69
70
gab 2013/07/10 13:40:44 nit: Looks like you have more than a single empty
scottmg 2013/07/15 16:06:01 Done.
107 } // namespace importer 71 } // namespace importer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698