#include "content/browser/first_party_sets/database/first_party_sets_database.h"
#include <inttypes.h>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/sequence_checker.h"
#include "base/version.h"
#include "content/browser/first_party_sets/first_party_set_parser.h"
#include "net/base/schemeful_site.h"
#include "net/first_party_sets/first_party_set_entry.h"
#include "net/first_party_sets/first_party_set_entry_override.h"
#include "net/first_party_sets/first_party_sets_cache_filter.h"
#include "net/first_party_sets/first_party_sets_context_config.h"
#include "net/first_party_sets/first_party_sets_validator.h"
#include "net/first_party_sets/global_first_party_sets.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "sql/recovery.h"
#include "sql/statement.h"
#include "sql/transaction.h"
namespace content {
namespace {
const int kCurrentVersionNumber = …;
const int kDeprecatedVersionNumber = …;
const char kRunCountKey[] = …;
[[nodiscard]] bool InitSchema(sql::Database& db) { … }
void RecordInitializationStatus(FirstPartySetsDatabase::InitStatus status) { … }
}
FirstPartySetsDatabase::FirstPartySetsDatabase(base::FilePath db_path)
: … { … }
FirstPartySetsDatabase::~FirstPartySetsDatabase() { … }
bool FirstPartySetsDatabase::PersistSets(
const std::string& browser_context_id,
const net::GlobalFirstPartySets& sets,
const net::FirstPartySetsContextConfig& config) { … }
bool FirstPartySetsDatabase::SetPublicSets(
const std::string& browser_context_id,
const net::GlobalFirstPartySets& sets) { … }
bool FirstPartySetsDatabase::InsertSitesToClear(
const std::string& browser_context_id,
const base::flat_set<net::SchemefulSite>& sites) { … }
bool FirstPartySetsDatabase::InsertBrowserContextCleared(
const std::string& browser_context_id) { … }
bool FirstPartySetsDatabase::InsertPolicyConfigurations(
const std::string& browser_context_id,
const net::FirstPartySetsContextConfig& config) { … }
bool FirstPartySetsDatabase::InsertManualConfiguration(
const std::string& browser_context_id,
const net::GlobalFirstPartySets& global_first_party_sets) { … }
std::optional<
std::pair<net::GlobalFirstPartySets, net::FirstPartySetsContextConfig>>
FirstPartySetsDatabase::GetGlobalSetsAndConfig(
const std::string& browser_context_id) { … }
std::optional<net::GlobalFirstPartySets> FirstPartySetsDatabase::GetGlobalSets(
const std::string& browser_context_id) { … }
std::optional<
std::pair<std::vector<net::SchemefulSite>, net::FirstPartySetsCacheFilter>>
FirstPartySetsDatabase::GetSitesToClearFilters(
const std::string& browser_context_id) { … }
std::optional<std::vector<net::SchemefulSite>>
FirstPartySetsDatabase::FetchSitesToClear(
const std::string& browser_context_id) { … }
std::optional<base::flat_map<net::SchemefulSite, int64_t>>
FirstPartySetsDatabase::FetchAllSitesToClearFilter(
const std::string& browser_context_id) { … }
std::optional<net::FirstPartySetsContextConfig>
FirstPartySetsDatabase::FetchPolicyConfigurations(
const std::string& browser_context_id) { … }
bool FirstPartySetsDatabase::HasEntryInBrowserContextsClearedForTesting(
const std::string& browser_context_id) { … }
std::optional<net::FirstPartySetsContextConfig>
FirstPartySetsDatabase::FetchManualConfiguration(
const std::string& browser_context_id) { … }
bool FirstPartySetsDatabase::LazyInit() { … }
bool FirstPartySetsDatabase::OpenDatabase() { … }
void FirstPartySetsDatabase::DatabaseErrorCallback(int extended_error,
sql::Statement* stmt) { … }
FirstPartySetsDatabase::InitStatus FirstPartySetsDatabase::InitializeTables() { … }
bool FirstPartySetsDatabase::UpgradeSchema() { … }
bool FirstPartySetsDatabase::MigrateToVersion3() { … }
bool FirstPartySetsDatabase::MigrateToVersion4() { … }
bool FirstPartySetsDatabase::MigrateToVersion5() { … }
void FirstPartySetsDatabase::IncreaseRunCount() { … }
bool FirstPartySetsDatabase::Destroy() { … }
bool FirstPartySetsDatabase::TransactionFailed() { … }
}