#include "components/segmentation_platform/internal/selection/segment_result_provider.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/task/sequenced_task_runner.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/execution/execution_request.h"
#include "components/segmentation_platform/internal/logging.h"
#include "components/segmentation_platform/internal/metadata/metadata_utils.h"
#include "components/segmentation_platform/internal/proto/model_prediction.pb.h"
#include "components/segmentation_platform/internal/scheduler/execution_service.h"
#include "components/segmentation_platform/internal/stats.h"
#include "components/segmentation_platform/public/model_provider.h"
#include "components/segmentation_platform/public/proto/model_metadata.pb.h"
namespace segmentation_platform {
namespace {
float ComputeDiscreteMapping(const std::string& discrete_mapping_key,
float model_score,
const proto::SegmentationModelMetadata& metadata) { … }
ModelProvider* GetModelProvider(ExecutionService* execution_service,
SegmentId segment_id,
ModelSource model_source) { … }
class SegmentResultProviderImpl : public SegmentResultProvider { … };
void SegmentResultProviderImpl::GetSegmentResult(
std::unique_ptr<GetResultOptions> options) { … }
void SegmentResultProviderImpl::OnGotModelScore(
FallbackAction fallback_action,
std::unique_ptr<RequestState> request_state,
std::unique_ptr<SegmentResult> db_result) { … }
void SegmentResultProviderImpl::GetCachedModelScore(
std::unique_ptr<RequestState> request_state,
ModelSource model_source,
ResultCallbackWithState callback) { … }
void SegmentResultProviderImpl::ExecuteModelAndGetScore(
std::unique_ptr<RequestState> request_state,
ModelSource model_source,
ResultCallbackWithState callback) { … }
void SegmentResultProviderImpl::OnModelExecuted(
std::unique_ptr<RequestState> request_state,
ModelSource model_source,
ResultCallbackWithState callback,
std::unique_ptr<ModelExecutionResult> result) { … }
void SegmentResultProviderImpl::PostResultCallback(
std::unique_ptr<RequestState> request_state,
std::unique_ptr<SegmentResult> result) { … }
void SegmentResultProviderImpl::OnSavedSegmentResult(
SegmentId segment_id,
std::unique_ptr<RequestState> request_state,
std::unique_ptr<SegmentResult> segment_result,
ResultCallbackWithState callback,
bool success) { … }
}
SegmentResultProvider::SegmentResult::SegmentResult(ResultState state)
: … { … }
SegmentResultProvider::SegmentResult::SegmentResult(
ResultState state,
const proto::PredictionResult& prediction_result,
float rank)
: … { … }
SegmentResultProvider::SegmentResult::~SegmentResult() = default;
SegmentResultProvider::GetResultOptions::GetResultOptions() = default;
SegmentResultProvider::GetResultOptions::~GetResultOptions() = default;
std::unique_ptr<SegmentResultProvider> SegmentResultProvider::Create(
SegmentInfoDatabase* segment_database,
SignalStorageConfig* signal_storage_config,
ExecutionService* execution_service,
base::Clock* clock,
bool force_refresh_results) { … }
}