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

Side by Side Diff: components/autofill/core/browser/autofill_metrics.cc

Issue 23629046: Remove default case from autofill_metrics.cc::GetFieldTypeGroupMetric (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Appease foolish compiler Created 7 years, 3 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 "components/autofill/core/browser/autofill_metrics.h" 5 #include "components/autofill/core/browser/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/metrics/sparse_histogram.h" 9 #include "base/metrics/sparse_histogram.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 ADDRESS_STATE, 49 ADDRESS_STATE,
50 ADDRESS_ZIP, 50 ADDRESS_ZIP,
51 ADDRESS_COUNTRY, 51 ADDRESS_COUNTRY,
52 PHONE, 52 PHONE,
53 FAX, // Deprecated. 53 FAX, // Deprecated.
54 EMAIL, 54 EMAIL,
55 CREDIT_CARD_NAME, 55 CREDIT_CARD_NAME,
56 CREDIT_CARD_NUMBER, 56 CREDIT_CARD_NUMBER,
57 CREDIT_CARD_DATE, 57 CREDIT_CARD_DATE,
58 CREDIT_CARD_TYPE, 58 CREDIT_CARD_TYPE,
59 PASSWORD,
59 NUM_FIELD_TYPE_GROUPS_FOR_METRICS 60 NUM_FIELD_TYPE_GROUPS_FOR_METRICS
60 }; 61 };
61 62
62 // First, translates |field_type| to the corresponding logical |group| from 63 // First, translates |field_type| to the corresponding logical |group| from
63 // |FieldTypeGroupForMetrics|. Then, interpolates this with the given |metric|, 64 // |FieldTypeGroupForMetrics|. Then, interpolates this with the given |metric|,
64 // which should be in the range [0, |num_possible_metrics|). 65 // which should be in the range [0, |num_possible_metrics|).
65 // Returns the interpolated index. 66 // Returns the interpolated index.
66 // 67 //
67 // The interpolation maps the pair (|group|, |metric|) to a single index, so 68 // The interpolation maps the pair (|group|, |metric|) to a single index, so
68 // that all the indicies for a given group are adjacent. In particular, with 69 // that all the indicies for a given group are adjacent. In particular, with
69 // the groups {AMBIGUOUS, NAME, ...} combining with the metrics {UNKNOWN, MATCH, 70 // the groups {AMBIGUOUS, NAME, ...} combining with the metrics {UNKNOWN, MATCH,
70 // MISMATCH}, we create this set of mapped indices: 71 // MISMATCH}, we create this set of mapped indices:
71 // { 72 // {
72 // AMBIGUOUS+UNKNOWN, 73 // AMBIGUOUS+UNKNOWN,
73 // AMBIGUOUS+MATCH, 74 // AMBIGUOUS+MATCH,
74 // AMBIGUOUS+MISMATCH, 75 // AMBIGUOUS+MISMATCH,
75 // NAME+UNKNOWN, 76 // NAME+UNKNOWN,
76 // NAME+MATCH, 77 // NAME+MATCH,
77 // NAME+MISMATCH, 78 // NAME+MISMATCH,
78 // ... 79 // ...
79 // }. 80 // }.
80 // 81 //
81 // Clients must ensure that |field_type| is one of the types Chrome supports 82 // Clients must ensure that |field_type| is one of the types Chrome supports
82 // natively, e.g. |field_type| must not be a billng address. 83 // natively, e.g. |field_type| must not be a billng address.
83 int GetFieldTypeGroupMetric(const ServerFieldType field_type, 84 int GetFieldTypeGroupMetric(const ServerFieldType field_type,
84 const int metric, 85 const int metric,
85 const int num_possible_metrics) { 86 const int num_possible_metrics) {
86 DCHECK_LT(metric, num_possible_metrics); 87 DCHECK_LT(metric, num_possible_metrics);
87 88
88 FieldTypeGroupForMetrics group; 89 FieldTypeGroupForMetrics group = AMBIGUOUS;
89 switch (AutofillType(field_type).group()) { 90 switch (AutofillType(field_type).group()) {
90 case ::autofill::NO_GROUP: 91 case ::autofill::NO_GROUP:
91 group = AMBIGUOUS; 92 group = AMBIGUOUS;
92 break; 93 break;
93 94
94 case ::autofill::NAME: 95 case ::autofill::NAME:
96 case ::autofill::NAME_BILLING:
95 group = NAME; 97 group = NAME;
96 break; 98 break;
97 99
98 case ::autofill::COMPANY: 100 case ::autofill::COMPANY:
99 group = COMPANY; 101 group = COMPANY;
100 break; 102 break;
101 103
102 case ::autofill::ADDRESS_HOME: 104 case ::autofill::ADDRESS_HOME:
103 switch (field_type) { 105 case ::autofill::ADDRESS_BILLING:
106 switch (AutofillType(field_type).GetStorableType()) {
104 case ADDRESS_HOME_LINE1: 107 case ADDRESS_HOME_LINE1:
105 group = ADDRESS_LINE_1; 108 group = ADDRESS_LINE_1;
106 break; 109 break;
107 case ADDRESS_HOME_LINE2: 110 case ADDRESS_HOME_LINE2:
108 group = ADDRESS_LINE_2; 111 group = ADDRESS_LINE_2;
109 break; 112 break;
110 case ADDRESS_HOME_CITY: 113 case ADDRESS_HOME_CITY:
111 group = ADDRESS_CITY; 114 group = ADDRESS_CITY;
112 break; 115 break;
113 case ADDRESS_HOME_STATE: 116 case ADDRESS_HOME_STATE:
114 group = ADDRESS_STATE; 117 group = ADDRESS_STATE;
115 break; 118 break;
116 case ADDRESS_HOME_ZIP: 119 case ADDRESS_HOME_ZIP:
117 group = ADDRESS_ZIP; 120 group = ADDRESS_ZIP;
118 break; 121 break;
119 case ADDRESS_HOME_COUNTRY: 122 case ADDRESS_HOME_COUNTRY:
120 group = ADDRESS_COUNTRY; 123 group = ADDRESS_COUNTRY;
121 break; 124 break;
122 default: 125 default:
123 NOTREACHED(); 126 NOTREACHED();
124 group = AMBIGUOUS; 127 group = AMBIGUOUS;
128 break;
125 } 129 }
126 break; 130 break;
127 131
128 case ::autofill::EMAIL: 132 case ::autofill::EMAIL:
129 group = EMAIL; 133 group = EMAIL;
130 break; 134 break;
131 135
132 case ::autofill::PHONE_HOME: 136 case ::autofill::PHONE_HOME:
137 case ::autofill::PHONE_BILLING:
133 group = PHONE; 138 group = PHONE;
134 break; 139 break;
135 140
136 case ::autofill::CREDIT_CARD: 141 case ::autofill::CREDIT_CARD:
137 switch (field_type) { 142 switch (field_type) {
138 case ::autofill::CREDIT_CARD_NAME: 143 case ::autofill::CREDIT_CARD_NAME:
139 group = CREDIT_CARD_NAME; 144 group = CREDIT_CARD_NAME;
140 break; 145 break;
141 case ::autofill::CREDIT_CARD_NUMBER: 146 case ::autofill::CREDIT_CARD_NUMBER:
142 group = CREDIT_CARD_NUMBER; 147 group = CREDIT_CARD_NUMBER;
143 break; 148 break;
144 case ::autofill::CREDIT_CARD_TYPE: 149 case ::autofill::CREDIT_CARD_TYPE:
145 group = CREDIT_CARD_TYPE; 150 group = CREDIT_CARD_TYPE;
146 break; 151 break;
152 case ::autofill::CREDIT_CARD_EXP_MONTH:
153 case ::autofill::CREDIT_CARD_EXP_2_DIGIT_YEAR:
154 case ::autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR:
155 case ::autofill::CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR:
156 case ::autofill::CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR:
157 group = CREDIT_CARD_DATE;
158 break;
147 default: 159 default:
148 group = CREDIT_CARD_DATE; 160 NOTREACHED();
161 group = AMBIGUOUS;
162 break;
149 } 163 }
150 break; 164 break;
151 165
152 default: 166 case ::autofill::PASSWORD_FIELD:
153 NOTREACHED(); 167 group = PASSWORD;
154 group = AMBIGUOUS; 168 break;
155 } 169 }
156 170
157 // Interpolate the |metric| with the |group|, so that all metrics for a given 171 // Interpolate the |metric| with the |group|, so that all metrics for a given
158 // |group| are adjacent. 172 // |group| are adjacent.
159 return (group * num_possible_metrics) + metric; 173 return (group * num_possible_metrics) + metric;
160 } 174 }
161 175
162 std::string WalletApiMetricToString( 176 std::string WalletApiMetricToString(
163 AutofillMetrics::WalletApiCallMetric metric) { 177 AutofillMetrics::WalletApiCallMetric metric) {
164 switch (metric) { 178 switch (metric) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 const std::string& experiment_id) const { 530 const std::string& experiment_id) const {
517 LogServerExperimentId("Autofill.ServerExperimentId.Query", experiment_id); 531 LogServerExperimentId("Autofill.ServerExperimentId.Query", experiment_id);
518 } 532 }
519 533
520 void AutofillMetrics::LogServerExperimentIdForUpload( 534 void AutofillMetrics::LogServerExperimentIdForUpload(
521 const std::string& experiment_id) const { 535 const std::string& experiment_id) const {
522 LogServerExperimentId("Autofill.ServerExperimentId.Upload", experiment_id); 536 LogServerExperimentId("Autofill.ServerExperimentId.Upload", experiment_id);
523 } 537 }
524 538
525 } // namespace autofill 539 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698