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

Side by Side Diff: components/ukm/ukm_entry.cc

Issue 2719823003: Convert first contentful paint logging to the new UKM client API (Closed)
Patch Set: renames Created 3 years, 9 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
« no previous file with comments | « components/ukm/ukm_entry.h ('k') | components/ukm/ukm_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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/ukm/ukm_entry.h" 5 #include "components/ukm/ukm_entry.h"
6 6
7 #include "base/metrics/metrics_hashes.h" 7 #include "base/metrics/metrics_hashes.h"
8 #include "components/metrics/proto/ukm/entry.pb.h" 8 #include "components/metrics/proto/ukm/entry.pb.h"
9 #include "components/ukm/ukm_source.h" 9 #include "components/ukm/ukm_source.h"
10 10
11 namespace ukm { 11 namespace ukm {
12 12
13 UkmEntry::UkmEntry(int32_t source_id, const char* event_name) 13 UkmEntry::UkmEntry(int32_t source_id, const char* event_name)
14 : source_id_(source_id), event_hash_(base::HashMetricName(event_name)) {} 14 : source_id_(source_id), event_hash_(base::HashMetricName(event_name)) {}
15 15
16 UkmEntry::~UkmEntry() {} 16 UkmEntry::~UkmEntry() {}
17 17
18 void UkmEntry::PopulateProto(Entry* proto_entry) { 18 void UkmEntry::PopulateProto(Entry* proto_entry) const {
19 DCHECK(!proto_entry->has_source_id()); 19 DCHECK(!proto_entry->has_source_id());
20 DCHECK(!proto_entry->has_event_hash()); 20 DCHECK(!proto_entry->has_event_hash());
21 DCHECK(proto_entry->metrics_size() == 0); 21 DCHECK(proto_entry->metrics_size() == 0);
22 22
23 proto_entry->set_source_id(source_id_); 23 proto_entry->set_source_id(source_id_);
24 proto_entry->set_event_hash(event_hash_); 24 proto_entry->set_event_hash(event_hash_);
25 for (auto& metric : metrics_) { 25 for (auto& metric : metrics_) {
26 Entry::Metric* proto_metric = proto_entry->add_metrics(); 26 Entry::Metric* proto_metric = proto_entry->add_metrics();
27 proto_metric->set_metric_hash(std::get<0>(metric)); 27 proto_metric->set_metric_hash(std::get<0>(metric));
28 proto_metric->set_value(std::get<1>(metric)); 28 proto_metric->set_value(std::get<1>(metric));
29 } 29 }
30 } 30 }
31 31
32 } // namespace ukm 32 } // namespace ukm
OLDNEW
« no previous file with comments | « components/ukm/ukm_entry.h ('k') | components/ukm/ukm_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698