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

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

Issue 2888633002: Revert of [Autofill] Enable Autofill UKM by default. (Closed)
Patch Set: 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 (!ukm_service || !url.is_valid() || metrics.empty()) { 796 if (!IsUkmLoggingEnabled() || !ukm_service || !url.is_valid() ||
797 metrics.empty()) {
797 return false; 798 return false;
798 } 799 }
799 800
800 int32_t source_id = ukm_service->GetNewSourceID(); 801 int32_t source_id = ukm_service->GetNewSourceID();
801 ukm_service->UpdateSourceURL(source_id, url); 802 ukm_service->UpdateSourceURL(source_id, url);
802 std::unique_ptr<ukm::UkmEntryBuilder> builder = 803 std::unique_ptr<ukm::UkmEntryBuilder> builder =
803 ukm_service->GetEntryBuilder(source_id, ukm_entry_name.c_str()); 804 ukm_service->GetEntryBuilder(source_id, ukm_entry_name.c_str());
804 805
805 for (auto it = metrics.begin(); it != metrics.end(); ++it) { 806 for (auto it = metrics.begin(); it != metrics.end(); ++it) {
806 builder->AddMetric(it->first, it->second); 807 builder->AddMetric(it->first, it->second);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 name += ".WithBothServerAndLocalData"; 1028 name += ".WithBothServerAndLocalData";
1028 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS); 1029 LogUMAHistogramEnumeration(name, event, NUM_FORM_EVENTS);
1029 } 1030 }
1030 1031
1031 AutofillMetrics::FormInteractionsUkmLogger::FormInteractionsUkmLogger( 1032 AutofillMetrics::FormInteractionsUkmLogger::FormInteractionsUkmLogger(
1032 ukm::UkmService* ukm_service) 1033 ukm::UkmService* ukm_service)
1033 : ukm_service_(ukm_service) {} 1034 : ukm_service_(ukm_service) {}
1034 1035
1035 void AutofillMetrics::FormInteractionsUkmLogger::OnFormsParsed( 1036 void AutofillMetrics::FormInteractionsUkmLogger::OnFormsParsed(
1036 const GURL& url) { 1037 const GURL& url) {
1037 if (ukm_service_ == nullptr) 1038 if (!IsUkmLoggingEnabled() || ukm_service_ == nullptr)
1038 return; 1039 return;
1039 1040
1040 url_ = url; 1041 url_ = url;
1041 form_parsed_timestamp_ = base::TimeTicks::Now(); 1042 form_parsed_timestamp_ = base::TimeTicks::Now();
1042 } 1043 }
1043 1044
1044 void AutofillMetrics::FormInteractionsUkmLogger::LogInteractedWithForm( 1045 void AutofillMetrics::FormInteractionsUkmLogger::LogInteractedWithForm(
1045 bool is_for_credit_card, 1046 bool is_for_credit_card,
1046 size_t local_record_type_count, 1047 size_t local_record_type_count,
1047 size_t server_record_type_count) { 1048 size_t server_record_type_count) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 } 1146 }
1146 1147
1147 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL( 1148 void AutofillMetrics::FormInteractionsUkmLogger::UpdateSourceURL(
1148 const GURL& url) { 1149 const GURL& url) {
1149 url_ = url; 1150 url_ = url;
1150 if (CanLog()) 1151 if (CanLog())
1151 ukm_service_->UpdateSourceURL(source_id_, url_); 1152 ukm_service_->UpdateSourceURL(source_id_, url_);
1152 } 1153 }
1153 1154
1154 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const { 1155 bool AutofillMetrics::FormInteractionsUkmLogger::CanLog() const {
1155 return ukm_service_ && url_.is_valid(); 1156 return IsUkmLoggingEnabled() && ukm_service_ && url_.is_valid();
1156 } 1157 }
1157 1158
1158 int64_t 1159 int64_t
1159 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed() 1160 AutofillMetrics::FormInteractionsUkmLogger::MillisecondsSinceFormParsed()
1160 const { 1161 const {
1161 DCHECK(!form_parsed_timestamp_.is_null()); 1162 DCHECK(!form_parsed_timestamp_.is_null());
1162 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds(); 1163 return (base::TimeTicks::Now() - form_parsed_timestamp_).InMilliseconds();
1163 } 1164 }
1164 1165
1165 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() { 1166 void AutofillMetrics::FormInteractionsUkmLogger::GetNewSourceID() {
1166 source_id_ = ukm_service_->GetNewSourceID(); 1167 source_id_ = ukm_service_->GetNewSourceID();
1167 ukm_service_->UpdateSourceURL(source_id_, url_); 1168 ukm_service_->UpdateSourceURL(source_id_, url_);
1168 } 1169 }
1169 1170
1170 } // namespace autofill 1171 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698