| 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 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 if (!CanLog()) | 1134 if (!CanLog()) |
| 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 builder->AddMetric(internal::kUKMMillisecondsSinceFormParsedMetricName, | 1144 if (form_parsed_timestamp_.is_null()) |
| 1145 MillisecondsSinceFormParsed()); | 1145 DCHECK_EQ(state, NON_FILLABLE_FORM_OR_NEW_DATA); |
| 1146 else |
| 1147 builder->AddMetric(internal::kUKMMillisecondsSinceFormParsedMetricName, |
| 1148 MillisecondsSinceFormParsed()); |
| 1146 } | 1149 } |
| 1147 | 1150 |
| 1148 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL( | 1151 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL( |
| 1149 const GURL& url) { | 1152 const GURL& url) { |
| 1150 url_ = url; | 1153 url_ = url; |
| 1151 if (CanLog()) | 1154 if (CanLog()) |
| 1152 ukm_service_->UpdateSourceURL(source_id_, url_); | 1155 ukm_service_->UpdateSourceURL(source_id_, url_); |
| 1153 } | 1156 } |
| 1154 | 1157 |
| 1155 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const { | 1158 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const { |
| 1156 return IsUkmLoggingEnabled() && ukm_service_ && url_.is_valid(); | 1159 return IsUkmLoggingEnabled() && ukm_service_ && url_.is_valid(); |
| 1157 } | 1160 } |
| 1158 | 1161 |
| 1159 int64_t | 1162 int64_t |
| 1160 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed() | 1163 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed() |
| 1161 const { | 1164 const { |
| 1162 DCHECK(!form_parsed_timestamp_.is_null()); | 1165 DCHECK(!form_parsed_timestamp_.is_null()); |
| 1163 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); | 1166 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); |
| 1164 } | 1167 } |
| 1165 | 1168 |
| 1166 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { | 1169 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { |
| 1167 source_id_ = ukm_service_->GetNewSourceID(); | 1170 source_id_ = ukm_service_->GetNewSourceID(); |
| 1168 ukm_service_->UpdateSourceURL(source_id_, url_); | 1171 ukm_service_->UpdateSourceURL(source_id_, url_); |
| 1169 } | 1172 } |
| 1170 | 1173 |
| 1171 } // namespace autofill | 1174 } // namespace autofill |
| OLD | NEW |