Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Min Qin | 75bee1b | 2022-02-05 03:57:34 | [diff] [blame] | 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/segmentation_platform/internal/segmentation_ukm_helper.h" |
| 6 | |
| 7 | #include "base/bit_cast.h" |
| 8 | #include "base/metrics/field_trial_params.h" |
Min Qin | 7a9f3890 | 2023-05-15 16:27:46 | [diff] [blame] | 9 | #include "base/rand_util.h" |
Min Qin | 75bee1b | 2022-02-05 03:57:34 | [diff] [blame] | 10 | #include "base/strings/string_number_conversions.h" |
| 11 | #include "base/strings/string_split.h" |
Min Qin | cae984cb | 2022-05-20 03:08:34 | [diff] [blame] | 12 | #include "base/time/clock.h" |
Salvador Guerrero | 5783fd6 | 2023-05-13 00:28:32 | [diff] [blame] | 13 | #include "base/time/time.h" |
Min Qin | cae984cb | 2022-05-20 03:08:34 | [diff] [blame] | 14 | #include "components/segmentation_platform/internal/constants.h" |
Min Qin | 642ab22 | 2022-05-19 21:54:53 | [diff] [blame] | 15 | #include "components/segmentation_platform/internal/selection/segmentation_result_prefs.h" |
Min Qin | 75bee1b | 2022-02-05 03:57:34 | [diff] [blame] | 16 | #include "components/segmentation_platform/internal/stats.h" |
| 17 | #include "components/segmentation_platform/public/config.h" |
| 18 | #include "components/segmentation_platform/public/features.h" |
Min Qin | cae984cb | 2022-05-20 03:08:34 | [diff] [blame] | 19 | #include "components/segmentation_platform/public/local_state_helper.h" |
Min Qin | 75bee1b | 2022-02-05 03:57:34 | [diff] [blame] | 20 | #include "services/metrics/public/cpp/ukm_builders.h" |
| 21 | #include "services/metrics/public/cpp/ukm_recorder.h" |
| 22 | |
| 23 | #define CALL_MEMBER_FN(obj, func) ((obj).*(func)) |
| 24 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x)[0]) |
| 25 | |
Min Qin | 1eeb643 | 2023-02-23 23:41:59 | [diff] [blame] | 26 | using segmentation_platform::SegmentationUkmHelper; |
ssid | 8386fc7 | 2022-05-21 00:34:17 | [diff] [blame] | 27 | using segmentation_platform::proto::SegmentId; |
Min Qin | 75bee1b | 2022-02-05 03:57:34 | [diff] [blame] | 28 | using ukm::builders::Segmentation_ModelExecution; |
| 29 | |
ssid | 7a2fe701 | 2023-07-05 23:16:09 | [diff] [blame] | 30 | namespace segmentation_platform { |
| 31 | |
Min Qin | 75bee1b | 2022-02-05 03:57:34 | [diff] [blame] | 32 | namespace { |
| 33 | using UkmMemberFn = |
| 34 | Segmentation_ModelExecution& (Segmentation_ModelExecution::*)(int64_t); |
| 35 | |
Xing Liu | 282dd0d | 2022-02-24 00:20:39 | [diff] [blame] | 36 | const UkmMemberFn kSegmentationUkmInputMethods[] = { |
Min Qin | 75bee1b | 2022-02-05 03:57:34 | [diff] [blame] | 37 | &Segmentation_ModelExecution::SetInput0, |
| 38 | &Segmentation_ModelExecution::SetInput1, |
| 39 | &Segmentation_ModelExecution::SetInput2, |
| 40 | &Segmentation_ModelExecution::SetInput3, |
| 41 | &Segmentation_ModelExecution::SetInput4, |
| 42 | &Segmentation_ModelExecution::SetInput5, |
| 43 | &Segmentation_ModelExecution::SetInput6, |
| 44 | &Segmentation_ModelExecution::SetInput7, |
| 45 | &Segmentation_ModelExecution::SetInput8, |
| 46 | &Segmentation_ModelExecution::SetInput9, |
| 47 | &Segmentation_ModelExecution::SetInput10, |
| 48 | &Segmentation_ModelExecution::SetInput11, |
| 49 | &Segmentation_ModelExecution::SetInput12, |
| 50 | &Segmentation_ModelExecution::SetInput13, |
| 51 | &Segmentation_ModelExecution::SetInput14, |
| 52 | &Segmentation_ModelExecution::SetInput15, |
| 53 | &Segmentation_ModelExecution::SetInput16, |
| 54 | &Segmentation_ModelExecution::SetInput17, |
| 55 | &Segmentation_ModelExecution::SetInput18, |
| 56 | &Segmentation_ModelExecution::SetInput19, |
| 57 | &Segmentation_ModelExecution::SetInput20, |
| 58 | &Segmentation_ModelExecution::SetInput21, |
| 59 | &Segmentation_ModelExecution::SetInput22, |
| 60 | &Segmentation_ModelExecution::SetInput23, |
| 61 | &Segmentation_ModelExecution::SetInput24, |
| 62 | &Segmentation_ModelExecution::SetInput25, |
| 63 | &Segmentation_ModelExecution::SetInput26, |
| 64 | &Segmentation_ModelExecution::SetInput27, |
| 65 | &Segmentation_ModelExecution::SetInput28, |
Min Qin | 81e6bda | 2022-12-07 06:44:27 | [diff] [blame] | 66 | &Segmentation_ModelExecution::SetInput29, |
| 67 | &Segmentation_ModelExecution::SetInput30, |
| 68 | &Segmentation_ModelExecution::SetInput31, |
| 69 | &Segmentation_ModelExecution::SetInput32, |
| 70 | &Segmentation_ModelExecution::SetInput33, |
| 71 | &Segmentation_ModelExecution::SetInput34, |
| 72 | &Segmentation_ModelExecution::SetInput35, |
| 73 | &Segmentation_ModelExecution::SetInput36, |
| 74 | &Segmentation_ModelExecution::SetInput37, |
| 75 | &Segmentation_ModelExecution::SetInput38, |
| 76 | &Segmentation_ModelExecution::SetInput39, |
| 77 | &Segmentation_ModelExecution::SetInput40, |
| 78 | &Segmentation_ModelExecution::SetInput41, |
| 79 | &Segmentation_ModelExecution::SetInput42, |
| 80 | &Segmentation_ModelExecution::SetInput43, |
| 81 | &Segmentation_ModelExecution::SetInput44, |
| 82 | &Segmentation_ModelExecution::SetInput45, |
|
|