| 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 "components/autofill/core/browser/autofill_metrics.h" | 5 #include "components/autofill/core/browser/autofill_metrics.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 return; | 1135 return; |
| 1136 | 1136 |
| 1137 if (source_id_ == -1) | 1137 if (source_id_ == -1) |
| 1138 GetNewSourceID(); | 1138 GetNewSourceID(); |
| 1139 | 1139 |
| 1140 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( | 1140 std::unique_ptr<ukm::UkmEntryBuilder> builder = ukm_service_->GetEntryBuilder( |
| 1141 source_id_, internal::kUKMFormSubmittedEntryName); | 1141 source_id_, internal::kUKMFormSubmittedEntryName); |
| 1142 builder->AddMetric(internal::kUKMAutofillFormSubmittedStateMetricName, | 1142 builder->AddMetric(internal::kUKMAutofillFormSubmittedStateMetricName, |
| 1143 static_cast<int>(state)); | 1143 static_cast<int>(state)); |
| 1144 if (form_parsed_timestamp_.is_null()) | 1144 if (form_parsed_timestamp_.is_null()) |
| 1145 DCHECK_EQ(state, NON_FILLABLE_FORM_OR_NEW_DATA); | 1145 DCHECK(state == NON_FILLABLE_FORM_OR_NEW_DATA || |
| 1146 state == FILLABLE_FORM_AUTOFILLED_NONE_DID_NOT_SHOW_SUGGESTIONS) |
| 1147 << state; |
| 1146 else | 1148 else |
| 1147 builder->AddMetric(internal::kUKMMillisecondsSinceFormParsedMetricName, | 1149 builder->AddMetric(internal::kUKMMillisecondsSinceFormParsedMetricName, |
| 1148 MillisecondsSinceFormParsed()); | 1150 MillisecondsSinceFormParsed()); |
| 1149 } | 1151 } |
| 1150 | 1152 |
| 1151 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL( | 1153 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL( |
| 1152 const GURL& url) { | 1154 const GURL& url) { |
| 1153 url_ = url; | 1155 url_ = url; |
| 1154 if (CanLog()) | 1156 if (CanLog()) |
| 1155 ukm_service_->UpdateSourceURL(source_id_, url_); | 1157 ukm_service_->UpdateSourceURL(source_id_, url_); |
| 1156 } | 1158 } |
| 1157 | 1159 |
| 1158 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const { | 1160 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const { |
| 1159 return IsUkmLoggingEnabled() && ukm_service_ && url_.is_valid(); | 1161 return IsUkmLoggingEnabled() && ukm_service_ && url_.is_valid(); |
| 1160 } | 1162 } |
| 1161 | 1163 |
| 1162 int64_t | 1164 int64_t |
| 1163 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed() | 1165 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed() |
| 1164 const { | 1166 const { |
| 1165 DCHECK(!form_parsed_timestamp_.is_null()); | 1167 DCHECK(!form_parsed_timestamp_.is_null()); |
| 1166 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); | 1168 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); |
| 1167 } | 1169 } |
| 1168 | 1170 |
| 1169 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { | 1171 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { |
| 1170 source_id_ = ukm_service_->GetNewSourceID(); | 1172 source_id_ = ukm_service_->GetNewSourceID(); |
| 1171 ukm_service_->UpdateSourceURL(source_id_, url_); | 1173 ukm_service_->UpdateSourceURL(source_id_, url_); |
| 1172 } | 1174 } |
| 1173 | 1175 |
| 1174 } // namespace autofill | 1176 } // namespace autofill |
| OLD | NEW |