| 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_BUILDER_H | 5 #ifndef COMPONENTS_UKM_UKM_ENTRY_BUILDER_H |
| 6 #define COMPONENTS_UKM_UKM_ENTRY_BUILDER_H | 6 #define COMPONENTS_UKM_UKM_ENTRY_BUILDER_H |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // builder->AddMetric("ResponseStart", response_start_time); | 25 // builder->AddMetric("ResponseStart", response_start_time); |
| 26 // builder->AddMetric("FirstPaint", first_paint_time); | 26 // builder->AddMetric("FirstPaint", first_paint_time); |
| 27 // builder->AddMetric("FirstContentfulPaint", fcp_time); | 27 // builder->AddMetric("FirstContentfulPaint", fcp_time); |
| 28 // } | 28 // } |
| 29 // | 29 // |
| 30 // When there exists an added metric, the builder will automatically add the | 30 // When there exists an added metric, the builder will automatically add the |
| 31 // UkmEntry to UkmService upon destruction when going out of scope. | 31 // UkmEntry to UkmService upon destruction when going out of scope. |
| 32 class UkmEntryBuilder { | 32 class UkmEntryBuilder { |
| 33 public: | 33 public: |
| 34 // Add metric to the entry. A metric contains a metric name and value. | 34 // Add metric to the entry. A metric contains a metric name and value. |
| 35 // Repeated calls with the same metric name will add multiple values, |
| 36 // rather than replace the existing value. |
| 35 void AddMetric(const char* metric_name, int64_t value); | 37 void AddMetric(const char* metric_name, int64_t value); |
| 36 | 38 |
| 37 ~UkmEntryBuilder(); | 39 ~UkmEntryBuilder(); |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 friend class UkmService; | 42 friend class UkmService; |
| 41 | 43 |
| 42 UkmEntryBuilder(const UkmService::AddEntryCallback& callback, | 44 UkmEntryBuilder(const UkmService::AddEntryCallback& callback, |
| 43 int32_t source_id, | 45 int32_t source_id, |
| 44 const char* event_name); | 46 const char* event_name); |
| 45 | 47 |
| 46 UkmService::AddEntryCallback add_entry_callback_; | 48 UkmService::AddEntryCallback add_entry_callback_; |
| 47 std::unique_ptr<UkmEntry> entry_; | 49 std::unique_ptr<UkmEntry> entry_; |
| 48 | 50 |
| 49 DISALLOW_COPY_AND_ASSIGN(UkmEntryBuilder); | 51 DISALLOW_COPY_AND_ASSIGN(UkmEntryBuilder); |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 } // namespace ukm | 54 } // namespace ukm |
| 53 | 55 |
| 54 #endif // COMPONENTS_UKM_UKM_ENTRY_BUILDER_H | 56 #endif // COMPONENTS_UKM_UKM_ENTRY_BUILDER_H |
| OLD | NEW |