OLD | NEW |
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 #ifndef COMPONENTS_UKM_UKM_ENTRY_H_ | 5 #ifndef COMPONENTS_UKM_UKM_ENTRY_H_ |
6 #define COMPONENTS_UKM_UKM_ENTRY_H_ | 6 #define COMPONENTS_UKM_UKM_ENTRY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 | 12 |
13 namespace ukm { | 13 namespace ukm { |
14 | 14 |
15 class Entry; | 15 class Entry; |
16 class UkmEntryBuilder; | 16 class UkmEntryBuilder; |
17 | 17 |
18 // One UkmEntry contains metrics for a specific source and event. It is | 18 // One UkmEntry contains metrics for a specific source and event. It is |
19 // connected to a UkmSource by the source ID. The event can be user defined. | 19 // connected to a UkmSource by the source ID. The event can be user defined. |
20 // One example is "PageLoad". Each UkmEntry can have a list of metrics, each of | 20 // One example is "PageLoad". Each UkmEntry can have a list of metrics, each of |
21 // which consist of a metric name and value. When the entry is serialized to the | 21 // which consist of a metric name and value. When the entry is serialized to the |
22 // proto message, the event and metric names will be hashed by | 22 // proto message, the event and metric names will be hashed by |
23 // base::HashMetricName. | 23 // base::HashMetricName. |
24 // | 24 // |
25 // To build UkmEntry objects, please use UkmEntryBuilder. | 25 // To build UkmEntry objects, please use UkmEntryBuilder. |
26 class UkmEntry { | 26 class UkmEntry { |
27 public: | 27 public: |
28 // Serializes the members of the class into the supplied proto. | 28 // Serializes the members of the class into the supplied proto. |
29 void PopulateProto(Entry* proto_entry); | 29 void PopulateProto(Entry* proto_entry) const; |
| 30 |
| 31 int32_t source_id() const { return source_id_; } |
30 | 32 |
31 ~UkmEntry(); | 33 ~UkmEntry(); |
32 | 34 |
33 private: | 35 private: |
34 friend UkmEntryBuilder; | 36 friend UkmEntryBuilder; |
35 | 37 |
36 UkmEntry(int32_t source_id, const char* event_name); | 38 UkmEntry(int32_t source_id, const char* event_name); |
37 | 39 |
38 const int32_t source_id_; | 40 const int32_t source_id_; |
39 const uint64_t event_hash_; | 41 const uint64_t event_hash_; |
40 std::vector<std::pair<uint64_t, int64_t>> metrics_; | 42 std::vector<std::pair<uint64_t, int64_t>> metrics_; |
41 | 43 |
42 DISALLOW_COPY_AND_ASSIGN(UkmEntry); | 44 DISALLOW_COPY_AND_ASSIGN(UkmEntry); |
43 }; | 45 }; |
44 | 46 |
45 } // namespace ukm | 47 } // namespace ukm |
46 | 48 |
47 #endif // COMPONENTS_UKM_UKM_ENTRY_H_ | 49 #endif // COMPONENTS_UKM_UKM_ENTRY_H_ |
OLD | NEW |