#include "components/segmentation_platform/internal/database/signal_storage_config.h"
#include "base/containers/contains.h"
#include "base/functional/callback_helpers.h"
#include "components/segmentation_platform/internal/metadata/metadata_utils.h"
#include "components/segmentation_platform/public/proto/model_metadata.pb.h"
namespace segmentation_platform {
namespace {
const char kDatabaseKey[] = …;
}
CleanupItem::CleanupItem() = default;
CleanupItem::CleanupItem(uint64_t name_hash,
uint64_t event_hash,
proto::SignalType signal_type,
base::Time timestamp)
: … { … }
CleanupItem::~CleanupItem() = default;
bool CleanupItem::operator==(const CleanupItem& other) const { … }
SignalStorageConfig::SignalStorageConfig(
std::unique_ptr<SignalStorageConfigProtoDb> database,
base::Clock* clock)
: … { … }
SignalStorageConfig::~SignalStorageConfig() = default;
void SignalStorageConfig::InitAndLoad(SuccessCallback callback) { … }
void SignalStorageConfig::OnDatabaseInitialized(
SuccessCallback callback,
leveldb_proto::Enums::InitStatus status) { … }
void SignalStorageConfig::OnDataLoaded(
SuccessCallback callback,
bool success,
std::unique_ptr<std::vector<proto::SignalStorageConfigs>> entries) { … }
proto::SignalStorageConfig* SignalStorageConfig::FindSignal(
uint64_t signal_hash,
uint64_t event_hash,
proto::SignalType signal_type) { … }
void SignalStorageConfig::UpdateConfigForUMASignal(
int signal_storage_length,
bool* is_dirty,
const proto::UMAFeature& feature) { … }
bool SignalStorageConfig::UpdateConfigForSignal(int signal_storage_length,
uint64_t signal_hash,
uint64_t event_hash,
proto::SignalType signal_type) { … }
bool SignalStorageConfig::MeetsSignalCollectionRequirementForSignal(
base::TimeDelta min_signal_collection_length,
uint64_t signal_hash,
uint64_t event_hash,
proto::SignalType signal_type) { … }
bool SignalStorageConfig::MeetsSignalCollectionRequirement(
const proto::SegmentationModelMetadata& model_metadata,
bool include_outputs) { … }
void SignalStorageConfig::OnSignalCollectionStarted(
const proto::SegmentationModelMetadata& model_metadata) { … }
void SignalStorageConfig::GetSignalsForCleanup(
const std::set<std::pair<uint64_t, proto::SignalType>>& known_signals,
std::vector<CleanupItem>& result) const { … }
void SignalStorageConfig::UpdateSignalsForCleanup(
const std::vector<CleanupItem>& signals) { … }
void SignalStorageConfig::WriteToDB() { … }
}