#include "components/segmentation_platform/internal/database/storage_service.h"
#include "base/task/sequenced_task_runner.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
#include "components/leveldb_proto/public/shared_proto_database_client_list.h"
#include "components/segmentation_platform/internal/database/client_result_prefs.h"
#include "components/segmentation_platform/internal/database/database_maintenance_impl.h"
#include "components/segmentation_platform/internal/database/segment_info_database.h"
#include "components/segmentation_platform/internal/database/signal_database_impl.h"
#include "components/segmentation_platform/internal/database/signal_storage_config.h"
#include "components/segmentation_platform/internal/proto/signal.pb.h"
#include "components/segmentation_platform/internal/proto/signal_storage_config.pb.h"
#include "components/segmentation_platform/internal/ukm_data_manager.h"
#include "components/segmentation_platform/public/features.h"
namespace segmentation_platform {
namespace {
const base::FilePath::CharType kSegmentInfoDBName[] = …);
const base::FilePath::CharType kSignalDBName[] = …);
const base::FilePath::CharType kSignalStorageConfigDBName[] = …);
const base::TimeDelta kDatabaseMaintenanceDelay = …;
}
StorageService::StorageService(
const base::FilePath& storage_dir,
leveldb_proto::ProtoDatabaseProvider* db_provider,
scoped_refptr<base::SequencedTaskRunner> task_runner,
base::Clock* clock,
UkmDataManager* ukm_data_manager,
std::vector<std::unique_ptr<Config>> configs,
ModelProviderFactory* model_provider_factory,
PrefService* profile_prefs,
const std::string& profile_id,
ModelManager::SegmentationModelUpdatedCallback model_updated_callback)
: … { … }
StorageService::StorageService(
std::unique_ptr<leveldb_proto::ProtoDatabase<proto::SegmentInfo>>
segment_db,
std::unique_ptr<leveldb_proto::ProtoDatabase<proto::SignalData>> signal_db,
std::unique_ptr<leveldb_proto::ProtoDatabase<proto::SignalStorageConfigs>>
signal_storage_config_db,
scoped_refptr<base::SequencedTaskRunner> task_runner,
base::Clock* clock,
UkmDataManager* ukm_data_manager,
std::vector<std::unique_ptr<Config>> configs,
ModelProviderFactory* model_provider_factory,
PrefService* profile_prefs,
const std::string& profile_id,
ModelManager::SegmentationModelUpdatedCallback model_updated_callback)
: … { … }
StorageService::StorageService(
std::unique_ptr<SegmentInfoDatabase> segment_info_database,
std::unique_ptr<SignalDatabase> signal_database,
std::unique_ptr<SignalStorageConfig> signal_storage_config,
std::unique_ptr<ModelManager> model_manager,
std::unique_ptr<ConfigHolder> config_holder,
UkmDataManager* ukm_data_manager)
: … { … }
StorageService::~StorageService() { … }
void StorageService::Initialize(SuccessCallback callback) { … }
void StorageService::OnSegmentInfoDatabaseInitialized(bool success) { … }
void StorageService::OnSignalDatabaseInitialized(bool success) { … }
void StorageService::OnSignalStorageConfigInitialized(bool success) { … }
bool StorageService::IsInitializationFinished() const { … }
void StorageService::MaybeFinishInitialization() { … }
int StorageService::GetServiceStatus() const { … }
void StorageService::ExecuteDatabaseMaintenanceTasks(bool is_startup) { … }
base::WeakPtr<StorageService> StorageService::GetWeakPtr() { … }
}