#include "components/segmentation_platform/internal/database/segment_info_database.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "components/segmentation_platform/internal/logging.h"
#include "components/segmentation_platform/internal/stats.h"
#include <string>
namespace segmentation_platform {
namespace {
std::string ToString(SegmentId segment_id, ModelSource model_source) { … }
ModelSource GetModelSource(ModelSource model_source) { … }
}
SegmentInfoDatabase::SegmentInfoDatabase(
std::unique_ptr<SegmentInfoProtoDb> database,
std::unique_ptr<SegmentInfoCache> cache)
: … { … }
SegmentInfoDatabase::~SegmentInfoDatabase() = default;
void SegmentInfoDatabase::Initialize(SuccessCallback callback) { … }
std::unique_ptr<SegmentInfoDatabase::SegmentInfoList>
SegmentInfoDatabase::GetSegmentInfoForBothModels(
const base::flat_set<SegmentId>& segment_ids) { … }
void SegmentInfoDatabase::GetSegmentInfoForSegments(
const base::flat_set<SegmentId>& segment_ids,
MultipleSegmentInfoCallback callback) { … }
void SegmentInfoDatabase::GetSegmentInfo(SegmentId segment_id,
proto::ModelSource model_source,
SegmentInfoCallback callback) { … }
const SegmentInfo* SegmentInfoDatabase::GetCachedSegmentInfo(
SegmentId segment_id,
proto::ModelSource model_source) { … }
void SegmentInfoDatabase::GetTrainingData(SegmentId segment_id,
ModelSource model_source,
TrainingRequestId request_id,
bool delete_from_db,
TrainingDataCallback callback) { … }
void SegmentInfoDatabase::UpdateSegment(
SegmentId segment_id,
ModelSource model_source,
std::optional<proto::SegmentInfo> segment_info,
SuccessCallback callback) { … }
void SegmentInfoDatabase::UpdateMultipleSegments(
const SegmentInfoList& segments_to_update,
const std::vector<std::pair<proto::SegmentId, ModelSource>>&
segments_to_delete,
SuccessCallback callback) { … }
void SegmentInfoDatabase::SaveSegmentResult(
SegmentId segment_id,
ModelSource model_source,
std::optional<proto::PredictionResult> result,
SuccessCallback callback) { … }
void SegmentInfoDatabase::SaveTrainingData(SegmentId segment_id,
ModelSource model_source,
const proto::TrainingData& data,
SuccessCallback callback) { … }
void SegmentInfoDatabase::OnDatabaseInitialized(
SuccessCallback callback,
leveldb_proto::Enums::InitStatus status) { … }
void SegmentInfoDatabase::OnLoadAllEntries(
SuccessCallback callback,
bool success,
std::unique_ptr<std::vector<proto::SegmentInfo>> all_infos) { … }
}