#include "components/segmentation_platform/internal/database/ukm_database_backend.h"
#include "base/check_is_test.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "components/segmentation_platform/internal/database/ukm_metrics_table.h"
#include "components/segmentation_platform/internal/database/ukm_types.h"
#include "components/segmentation_platform/internal/database/ukm_url_table.h"
#include "components/segmentation_platform/internal/database/uma_metrics_table.h"
#include "sql/database.h"
#include "sql/statement.h"
#include "sql/transaction.h"
namespace segmentation_platform {
namespace {
BASE_FEATURE(…);
static constexpr int kChangeCountToCommit = …;
bool SanityCheckUrl(const GURL& url, UrlId url_id) { … }
std::string BindValuesToStatement(
const std::vector<processing::ProcessedValue>& bind_values,
sql::Statement& statement) { … }
float GetSingleFloatOutput(sql::Statement& statement) { … }
void ErrorCallback(int code, sql::Statement* stmt) { … }
}
UkmDatabaseBackend::UkmDatabaseBackend(
const base::FilePath& database_path,
bool in_memory,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner)
: … { … }
UkmDatabaseBackend::~UkmDatabaseBackend() { … }
void UkmDatabaseBackend::InitDatabase(SuccessCallback callback) { … }
void UkmDatabaseBackend::StoreUkmEntry(ukm::mojom::UkmEntryPtr entry) { … }
void UkmDatabaseBackend::UpdateUrlForUkmSource(ukm::SourceId source_id,
const GURL& url,
bool is_validated,
const std::string& profile_id) { … }
void UkmDatabaseBackend::OnUrlValidated(const GURL& url,
const std::string& profile_id) { … }
void UkmDatabaseBackend::RemoveUrls(const std::vector<GURL>& urls,
bool all_urls) { … }
void UkmDatabaseBackend::AddUmaMetric(const std::string& profile_id,
const UmaMetricEntry& row) { … }
void UkmDatabaseBackend::RunReadOnlyQueries(QueryList&& queries,
QueryCallback callback) { … }
void UkmDatabaseBackend::DeleteEntriesOlderThan(base::Time time) { … }
void UkmDatabaseBackend::CommitTransactionForTesting() { … }
void UkmDatabaseBackend::RollbackTransactionForTesting() { … }
void UkmDatabaseBackend::DeleteAllUrls() { … }
void UkmDatabaseBackend::TrackChangesInTransaction(int change_count) { … }
void UkmDatabaseBackend::RestartTransaction() { … }
}