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 <map> | |
8 | |
9 #include "components/ukm/ukm_entry_builder.h" | |
10 #include "components/ukm/ukm_service.h" | |
11 #include "url/gurl.h" | |
12 | |
13 namespace autofill { | |
14 | |
15 // static | |
16 bool AutofillUkm::LogUkm(ukm::UkmService* ukm_service, | |
17 const GURL& url, | |
18 const std::string& ukm, | |
19 const std::map<std::string, int>& metrics) { | |
20 if (!ukm_service) { | |
21 DVLOG(3) << "No UKM service."; | |
Mathieu
2017/03/09 18:40:49
these DVLOG are not very useful?
sebsg
2017/03/09 19:57:04
Done.
| |
22 return false; | |
23 } | |
24 | |
25 if (!url.is_valid()) { | |
26 DVLOG(3) << "Invalid URL."; | |
27 return false; | |
28 } | |
29 | |
30 if (metrics.empty()) { | |
31 DVLOG(3) << "No Metrics to log."; | |
32 return false; | |
33 } | |
34 | |
35 DVLOG(3) << "Sending event for url: " << url.spec(); | |
36 int32_t source_id = ukm_service->GetNewSourceID(); | |
37 ukm_service->UpdateSourceURL(source_id, url); | |
38 std::unique_ptr<ukm::UkmEntryBuilder> builder = | |
39 ukm_service->GetEntryBuilder(source_id, ukm.c_str()); | |
40 | |
41 for (auto it = metrics.begin(); it != metrics.end(); ++it) { | |
42 builder->AddMetric(it->first.c_str(), it->second); | |
43 } | |
44 | |
45 return true; | |
46 } | |
47 | |
48 } // namespace autofill | |
OLD | NEW |