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

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: limit to fcp 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
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(const content::GlobalRequestID& source_id, 13 UkmEntry::UkmEntry(const content::GlobalRequestID& source_id,
14 const char* event_name) 14 const char* event_name)
15 : source_id_(source_id), event_hash_(base::HashMetricName(event_name)) {} 15 : source_id_(source_id), event_hash_(base::HashMetricName(event_name)) {}
16 16
17 UkmEntry::~UkmEntry() {} 17 UkmEntry::~UkmEntry() {}
18 18
19 void UkmEntry::PopulateProto(Entry* proto_entry) { 19 void UkmEntry::PopulateProto(Entry* proto_entry) const {
20 DCHECK(!proto_entry->has_source_id()); 20 DCHECK(!proto_entry->has_source_id());
21 DCHECK(!proto_entry->has_event_hash()); 21 DCHECK(!proto_entry->has_event_hash());
22 DCHECK(proto_entry->metrics_size() == 0); 22 DCHECK(proto_entry->metrics_size() == 0);
23 23
24 proto_entry->set_source_id(UkmSource::GetHashedSourceID(source_id_)); 24 proto_entry->set_source_id(UkmSource::GetHashedSourceID(source_id_));
25 proto_entry->set_event_hash(event_hash_); 25 proto_entry->set_event_hash(event_hash_);
26 for (auto& metric : metrics_) { 26 for (auto& metric : metrics_) {
27 Entry::Metric* proto_metric = proto_entry->add_metrics(); 27 Entry::Metric* proto_metric = proto_entry->add_metrics();
28 proto_metric->set_metric_hash(std::get<0>(metric)); 28 proto_metric->set_metric_hash(std::get<0>(metric));
29 proto_metric->set_value(std::get<1>(metric)); 29 proto_metric->set_value(std::get<1>(metric));
30 } 30 }
31 } 31 }
32 32
33 } // namespace ukm 33 } // namespace ukm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698