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

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

Issue 2897573003: Reland - [Autofill] Enable Autofill UKM by default. (Closed)
Patch Set: Rebase Created 3 years, 7 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
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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 786
787 LogUkm(ukm_service, url, internal::kUKMDeveloperEngagementEntryName, metrics); 787 LogUkm(ukm_service, url, internal::kUKMDeveloperEngagementEntryName, metrics);
788 } 788 }
789 789
790 // static 790 // static
791 bool AutofillMetrics::LogUkm( 791 bool AutofillMetrics::LogUkm(
792 ukm::UkmService* ukm_service, 792 ukm::UkmService* ukm_service,
793 const GURL& url, 793 const GURL& url,
794 const std::string& ukm_entry_name, 794 const std::string& ukm_entry_name,
795 const std::vector<std::pair<const char*, int>>& metrics) { 795 const std::vector<std::pair<const char*, int>>& metrics) {
796 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() || 796 if (!ukm_service || !url.is_valid() || metrics.empty()) {
797 metrics.empty()) {
798 return false; 797 return false;
799 } 798 }
800 799
801 int32_t source_id = ukm_service->GetNewSourceID(); 800 int32_t source_id = ukm_service->GetNewSourceID();
802 ukm_service->UpdateSourceURL(source_id, url); 801 ukm_service->UpdateSourceURL(source_id, url);
803 std::unique_ptr<ukm::UkmEntryBuilder> builder = 802 std::unique_ptr<ukm::UkmEntryBuilder> builder =
804 ukm_service->GetEntryBuilder(source_id, ukm_entry_name.c_str()); 803 ukm_service->GetEntryBuilder(source_id, ukm_entry_name.c_str());
805 804
806 for (auto it = metrics.begin(); it != metrics.end(); ++it) { 805 for (auto it = metrics.begin(); it != metrics.end(); ++it) {
807 builder->AddMetric(it->first, it->second); 806 builder->AddMetric(it->first, it->second);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 name += ".WithBothServerAndLocalData"; 1027 name += ".WithBothServerAndLocalData";
1029 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); 1028 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS);
1030 } 1029 }
1031 1030
1032 AutofillMetrics::FormInteractionsUkmLogger::FormInteractionsUkmLogger( 1031 AutofillMetrics::FormInteractionsUkmLogger::FormInteractionsUkmLogger(
1033 ukm::UkmService* ukm_service) 1032 ukm::UkmService* ukm_service)
1034 : ukm_service_(ukm_service) {} 1033 : ukm_service_(ukm_service) {}
1035 1034
1036 void AutofillMetrics::FormInteractionsUkmLogger::OnFormsParsed( 1035 void AutofillMetrics::FormInteractionsUkmLogger::OnFormsParsed(
1037 const GURL& url) { 1036 const GURL& url) {
1038 if (!IsUkmLoggingEnabled() || ukm_service_ == nullptr) 1037 if (ukm_service_ == nullptr)
1039 return; 1038 return;
1040 1039
1041 url_ = url; 1040 url_ = url;
1042 form_parsed_timestamp_ = base::TimeTicks::Now(); 1041 form_parsed_timestamp_ = base::TimeTicks::Now();
1043 } 1042 }
1044 1043
1045 void AutofillMetrics::FormInteractionsUkmLogger::LogInteractedWithForm( 1044 void AutofillMetrics::FormInteractionsUkmLogger::LogInteractedWithForm(
1046 bool is_for_credit_card, 1045 bool is_for_credit_card,
1047 size_t local_record_type_count, 1046 size_t local_record_type_count,
1048 size_t server_record_type_count) { 1047 size_t server_record_type_count) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 } 1150 }
1152 1151
1153 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL( 1152 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL(
1154 const GURL& url) { 1153 const GURL& url) {
1155 url_ = url; 1154 url_ = url;
1156 if (CanLog()) 1155 if (CanLog())
1157 ukm_service_->UpdateSourceURL(source_id_, url_); 1156 ukm_service_->UpdateSourceURL(source_id_, url_);
1158 } 1157 }
1159 1158
1160 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const { 1159 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const {
1161 return IsUkmLoggingEnabled() && ukm_service_ && url_.is_valid(); 1160 return ukm_service_ && url_.is_valid();
1162 } 1161 }
1163 1162
1164 int64_t 1163 int64_t
1165 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed() 1164 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed()
1166 const { 1165 const {
1167 DCHECK(!form_parsed_timestamp_.is_null()); 1166 DCHECK(!form_parsed_timestamp_.is_null());
1168 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); 1167 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds();
1169 } 1168 }
1170 1169
1171 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { 1170 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() {
1172 source_id_ = ukm_service_->GetNewSourceID(); 1171 source_id_ = ukm_service_->GetNewSourceID();
1173 ukm_service_->UpdateSourceURL(source_id_, url_); 1172 ukm_service_->UpdateSourceURL(source_id_, url_);
1174 } 1173 }
1175 1174
1176 } // namespace autofill 1175 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698