[segmentation] Replace OptimizationTarget with SegmentId

Replaces the segmentation_platform internal code to use a new SegmentId
enum instead of OptimizationTarget. This lets us add segments that do
not need any smart logic to be the output of the selections.

SegmentId enum is added to the public API of segmentation_platform.
The existing enum values from OptimizationTarget are copied over,
with a warning to stop adding more enums until migration is done.

The public API of SegmentationPlatformService is unchanged and uses
OptimizationTarget, which is currently used by multiple clients.
The selector converts the SegmentId to OptimizationTarget to return
to the client. The public API will be updated in the next CL. This
one still updates the Config.

The optimization guide model wrapper converts the SegmentId to
OptimizationTarget to fetch the models.

All other changes are mechanical replacement of string
OptimizationTarget to SegmentId with namespace. There should be no
behavior changes or metrics changes due to this CL. Additionally
makes style fixes with namespace and using declarations.

BUG=1315459

Change-Id: I5cd70b83bb6feef893ff74b8289d0542b4b342c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3656802
Commit-Queue: Siddhartha S <[email protected]>
Reviewed-by: Shakti Sahu <[email protected]>
Reviewed-by: David Trainor <[email protected]>
Reviewed-by: Min Qin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1006045}
diff --git a/components/segmentation_platform/internal/segmentation_ukm_helper.cc b/components/segmentation_platform/internal/segmentation_ukm_helper.cc
index 24bc080..38d0751 100644
--- a/components/segmentation_platform/internal/segmentation_ukm_helper.cc
+++ b/components/segmentation_platform/internal/segmentation_ukm_helper.cc
@@ -21,6 +21,7 @@
 #define CALL_MEMBER_FN(obj, func) ((obj).*(func))
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x)[0])
 
+using segmentation_platform::proto::SegmentId;
 using ukm::builders::Segmentation_ModelExecution;
 
 namespace {
@@ -67,7 +68,7 @@
     &Segmentation_ModelExecution::SetActualResult5,
     &Segmentation_ModelExecution::SetActualResult6};
 
-base::flat_set<OptimizationTarget> GetSegmentIdsAllowedForReporting() {
+base::flat_set<SegmentId> GetSegmentIdsAllowedForReporting() {
   std::vector<std::string> segment_ids = base::SplitString(
       base::GetFieldTrialParamValueByFeature(
           segmentation_platform::features::
@@ -75,11 +76,11 @@
           segmentation_platform::kSegmentIdsAllowedForReportingKey),
       ",;", base::WhitespaceHandling::TRIM_WHITESPACE,
       base::SplitResult::SPLIT_WANT_NONEMPTY);
-  base::flat_set<OptimizationTarget> result;
+  base::flat_set<SegmentId> result;
   for (const auto& id : segment_ids) {
     int segment_id;
     if (base::StringToInt(id, &segment_id))
-      result.emplace(static_cast<OptimizationTarget>(segment_id));
+      result.emplace(static_cast<SegmentId>(segment_id));
   }
   return result;
 }
@@ -105,7 +106,7 @@
 }
 
 ukm::SourceId SegmentationUkmHelper::RecordModelExecutionResult(
-    OptimizationTarget segment_id,
+    SegmentId segment_id,
     int64_t model_version,
     const std::vector<float>& input_tensor,
     float result) {
@@ -124,7 +125,7 @@
 }
 
 ukm::SourceId SegmentationUkmHelper::RecordTrainingData(
-    OptimizationTarget segment_id,
+    SegmentId segment_id,
     int64_t model_version,
     const std::vector<float>& input_tensor,
     const std::vector<float>& outputs,
@@ -158,7 +159,7 @@
 
 bool SegmentationUkmHelper::AddInputsToUkm(
     ukm::builders::Segmentation_ModelExecution* ukm_builder,
-    OptimizationTarget segment_id,
+    SegmentId segment_id,
     int64_t model_version,
     const std::vector<float>& input_tensor) {
   if (!allowed_segment_ids_.contains(static_cast<int>(segment_id)))