Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/autofill/core/browser/autofill_ukm.h" | |
| 6 | |
| 7 #include "components/ukm/ukm_entry_builder.h" | |
| 8 #include "components/ukm/ukm_service.h" | |
| 9 #include "url/gurl.h" | |
| 10 | |
| 11 namespace autofill { | |
| 12 | |
| 13 AutofillUkm::AutofillUkm(ukm::UkmService* ukm_service) | |
| 14 : ukm_service_(ukm_service) {} | |
| 15 | |
| 16 AutofillUkm::~AutofillUkm() {} | |
| 17 | |
| 18 void AutofillUkm::SetCardUploadDecisionMetricUrl(const GURL& url) { | |
| 19 if (ShouldLog(url)) { | |
| 20 card_upload_decision_url_.reset(new GURL(url)); | |
|
Mathieu
2017/03/08 22:33:49
I think I would prefer if |card_upload_decision_ur
| |
| 21 } | |
| 22 } | |
| 23 | |
| 24 void AutofillUkm::LogCardUploadDecisionMetric( | |
| 25 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | |
| 26 if (card_upload_decision_url_ && | |
| 27 upload_decision < AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) { | |
| 28 DVLOG(3) << "Sending event for url: " << card_upload_decision_url_->spec(); | |
| 29 int32_t source_id = ukm_service_->GetNewSourceID(); | |
| 30 ukm_service_->UpdateSourceURL(source_id, *card_upload_decision_url_.get()); | |
| 31 std::unique_ptr<ukm::UkmEntryBuilder> builder = | |
| 32 ukm_service_->GetEntryBuilder(source_id, "Autofill.CardUploadDecision"); | |
| 33 builder->AddMetric("UploadDecision", upload_decision); | |
| 34 | |
| 35 card_upload_decision_url_.reset(); | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 bool AutofillUkm::ShouldLog(const GURL& url) { | |
| 40 if (!url.is_valid()) { | |
| 41 return false; | |
| 42 } | |
| 43 | |
| 44 if (!ukm_service_) { | |
| 45 DVLOG(3) << "No UKM service."; | |
| 46 return false; | |
| 47 } | |
| 48 | |
| 49 return true; | |
| 50 } | |
| 51 | |
| 52 } // namespace autofill | |
| OLD | NEW |