#include "services/network/trust_tokens/sqlite_trust_token_persister.h"
#include <optional>
#include <string_view>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_split.h"
#include "base/task/sequenced_task_runner.h"
#include "components/sqlite_proto/key_value_data.h"
#include "services/network/public/mojom/trust_tokens.mojom.h"
#include "services/network/trust_tokens/proto/storage.pb.h"
#include "services/network/trust_tokens/trust_token_database_owner.h"
#include "services/network/trust_tokens/types.h"
#include "url/gurl.h"
#include "url/url_constants.h"
namespace network {
namespace {
const char kIssuerToplevelKeySeparator[] = …;
std::string ToKey(const SuitableTrustTokenOrigin& issuer,
const SuitableTrustTokenOrigin& toplevel) { … }
bool FromKey(std::string_view key_from_database,
std::optional<SuitableTrustTokenOrigin>* issuer,
std::optional<SuitableTrustTokenOrigin>* toplevel) { … }
void OnDatabaseOwnerCreated(
base::OnceCallback<void(std::unique_ptr<SQLiteTrustTokenPersister>)>
on_done_initializing,
std::unique_ptr<TrustTokenDatabaseOwner> database_owner) { … }
}
SQLiteTrustTokenPersister::SQLiteTrustTokenPersister(
std::unique_ptr<TrustTokenDatabaseOwner> database_owner)
: … { … }
SQLiteTrustTokenPersister::~SQLiteTrustTokenPersister() = default;
void SQLiteTrustTokenPersister::CreateForFilePath(
scoped_refptr<base::SequencedTaskRunner> db_task_runner,
const base::FilePath& path,
base::TimeDelta flush_delay_for_writes,
base::OnceCallback<void(std::unique_ptr<SQLiteTrustTokenPersister>)>
on_done_initializing) { … }
std::unique_ptr<TrustTokenIssuerConfig>
SQLiteTrustTokenPersister::GetIssuerConfig(
const SuitableTrustTokenOrigin& issuer) { … }
std::unique_ptr<TrustTokenToplevelConfig>
SQLiteTrustTokenPersister::GetToplevelConfig(
const SuitableTrustTokenOrigin& toplevel) { … }
std::unique_ptr<TrustTokenIssuerToplevelPairConfig>
SQLiteTrustTokenPersister::GetIssuerToplevelPairConfig(
const SuitableTrustTokenOrigin& issuer,
const SuitableTrustTokenOrigin& toplevel) { … }
void SQLiteTrustTokenPersister::SetIssuerConfig(
const SuitableTrustTokenOrigin& issuer,
std::unique_ptr<TrustTokenIssuerConfig> config) { … }
void SQLiteTrustTokenPersister::SetToplevelConfig(
const SuitableTrustTokenOrigin& toplevel,
std::unique_ptr<TrustTokenToplevelConfig> config) { … }
void SQLiteTrustTokenPersister::SetIssuerToplevelPairConfig(
const SuitableTrustTokenOrigin& issuer,
const SuitableTrustTokenOrigin& toplevel,
std::unique_ptr<TrustTokenIssuerToplevelPairConfig> config) { … }
bool SQLiteTrustTokenPersister::DeleteIssuerConfig(
PSTKeyMatcher key_matcher,
PSTTimeMatcher time_matcher) { … }
bool SQLiteTrustTokenPersister::DeleteToplevelConfig(
PSTKeyMatcher key_matcher) { … }
bool SQLiteTrustTokenPersister::DeleteIssuerToplevelPairConfig(
PSTKeyMatcher key_matcher,
PSTTimeMatcher time_matcher) { … }
base::flat_map<SuitableTrustTokenOrigin, int>
SQLiteTrustTokenPersister::GetStoredTrustTokenCounts() { … }
IssuerRedemptionRecordMap SQLiteTrustTokenPersister::GetRedemptionRecords() { … }
}