#include "components/segmentation_platform/internal/service_proxy_impl.h"
#include <memory>
#include <sstream>
#include "base/functional/callback_helpers.h"
#include "base/observer_list.h"
#include "base/strings/stringprintf.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "components/segmentation_platform/internal/database/segment_info_database.h"
#include "components/segmentation_platform/internal/database/signal_storage_config.h"
#include "components/segmentation_platform/internal/database/storage_service.h"
#include "components/segmentation_platform/internal/metadata/metadata_utils.h"
#include "components/segmentation_platform/internal/post_processor/post_processor.h"
#include "components/segmentation_platform/internal/scheduler/execution_service.h"
#include "components/segmentation_platform/internal/selection/segment_result_provider.h"
#include "components/segmentation_platform/internal/selection/segment_selector_impl.h"
#include "components/segmentation_platform/internal/selection/selection_utils.h"
#include "components/segmentation_platform/public/config.h"
#include "components/segmentation_platform/public/result.h"
#include "components/segmentation_platform/public/segment_selection_result.h"
namespace segmentation_platform {
namespace {
std::string SegmentMetadataToString(const proto::SegmentInfo& segment_info) { … }
std::string PredictionResultToString(const proto::SegmentInfo& segment_info,
const std::optional<float>& segment_rank) { … }
base::flat_set<proto::SegmentId> GetAllSegmentIds(
const std::vector<std::unique_ptr<Config>>& configs) { … }
}
ServiceProxyImpl::ServiceProxyImpl(
SegmentInfoDatabase* segment_db,
SignalStorageConfig* signal_storage_config,
const std::vector<std::unique_ptr<Config>>* configs,
const PlatformOptions& platform_options,
base::flat_map<std::string, std::unique_ptr<SegmentSelectorImpl>>*
segment_selectors)
: … { … }
ServiceProxyImpl::~ServiceProxyImpl() = default;
void ServiceProxyImpl::AddObserver(ServiceProxy::Observer* observer) { … }
void ServiceProxyImpl::RemoveObserver(ServiceProxy::Observer* observer) { … }
void ServiceProxyImpl::OnServiceStatusChanged(bool is_initialized,
int status_flag) { … }
void ServiceProxyImpl::UpdateObservers(bool update_service_status) { … }
void ServiceProxyImpl::SetExecutionService(
ExecutionService* model_execution_scheduler) { … }
void ServiceProxyImpl::GetServiceStatus() { … }
void ServiceProxyImpl::ExecuteModel(SegmentId segment_id) { … }
void ServiceProxyImpl::OverwriteResult(SegmentId segment_id, float result) { … }
void ServiceProxyImpl::SetSelectedSegment(const std::string& segmentation_key,
SegmentId segment_id) { … }
void ServiceProxyImpl::OnGetAllSegmentationInfo(
std::unique_ptr<SegmentInfoDatabase::SegmentInfoList> segment_info_list) { … }
void ServiceProxyImpl::OnModelExecutionCompleted(SegmentId segment_id) { … }
}