blob: 2c17365d48bafe55f462e9a937bd81f184a126b3 [file] [log] [blame]
Avi Drissman8ba1bad2022-09-13 19:22:361// Copyright 2022 The Chromium Authors
Min Qin75bee1b2022-02-05 03:57:342// 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 Qin7a9f38902023-05-15 16:27:469#include "base/rand_util.h"
Min Qin75bee1b2022-02-05 03:57:3410#include "base/strings/string_number_conversions.h"
11#include "base/strings/string_split.h"
Min Qincae984cb2022-05-20 03:08:3412#include "base/time/clock.h"
Salvador Guerrero5783fd62023-05-13 00:28:3213#include "base/time/time.h"
Min Qincae984cb2022-05-20 03:08:3414#include "components/segmentation_platform/internal/constants.h"
Min Qin642ab222022-05-19 21:54:5315#include "components/segmentation_platform/internal/selection/segmentation_result_prefs.h"
Min Qin75bee1b2022-02-05 03:57:3416#include "components/segmentation_platform/internal/stats.h"
17#include "components/segmentation_platform/public/config.h"
18#include "components/segmentation_platform/public/features.h"
Min Qincae984cb2022-05-20 03:08:3419#include "components/segmentation_platform/public/local_state_helper.h"
Min Qin75bee1b2022-02-05 03:57:3420#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 Qin1eeb6432023-02-23 23:41:5926using segmentation_platform::SegmentationUkmHelper;
ssid8386fc72022-05-21 00:34:1727using segmentation_platform::proto::SegmentId;
Min Qin75bee1b2022-02-05 03:57:3428using ukm::builders::Segmentation_ModelExecution;
29
ssid7a2fe7012023-07-05 23:16:0930namespace segmentation_platform {
31
Min Qin75bee1b2022-02-05 03:57:3432namespace {
33using UkmMemberFn =
34 Segmentation_ModelExecution& (Segmentation_ModelExecution::*)(int64_t);
35
Xing Liu282dd0d2022-02-24 00:20:3936const UkmMemberFn kSegmentationUkmInputMethods[] = {
Min Qin75bee1b2022-02-05 03:57:3437 &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 Qin81e6bda2022-12-07 06:44:2766 &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,