#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/services/storage/dom_storage/session_storage_metadata.h"
#include <string_view>
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "components/services/storage/dom_storage/async_dom_storage_database.h"
#include "third_party/blink/public/common/dom_storage/session_storage_namespace_id.h"
#include "url/gurl.h"
namespace storage {
namespace {
constexpr const uint8_t kMapIdPrefixBytes[] = …;
constexpr const size_t kNamespacePrefixLength = …;
constexpr const uint8_t kNamespaceStorageKeySeperatorByte = …;
constexpr const size_t kNamespaceStorageKeySeperatorLength = …;
constexpr const size_t kPrefixBeforeStorageKeyLength = …;
std::string_view Uint8VectorToStringView(const std::vector<uint8_t>& bytes) { … }
bool ValueToNumber(const std::vector<uint8_t>& value, int64_t* out) { … }
std::vector<uint8_t> NumberToValue(int64_t map_number) { … }
}
constexpr const int64_t SessionStorageMetadata::kMinSessionStorageSchemaVersion;
constexpr const int64_t
SessionStorageMetadata::kLatestSessionStorageSchemaVersion;
constexpr const int64_t SessionStorageMetadata::kInvalidDatabaseVersion;
constexpr const int64_t SessionStorageMetadata::kInvalidMapId;
constexpr const uint8_t SessionStorageMetadata::kDatabaseVersionBytes[];
constexpr const uint8_t SessionStorageMetadata::kNamespacePrefixBytes[];
constexpr const uint8_t SessionStorageMetadata::kNextMapIdKeyBytes[];
SessionStorageMetadata::MapData::MapData(int64_t map_number,
blink::StorageKey storage_key)
: … { … }
SessionStorageMetadata::MapData::~MapData() = default;
SessionStorageMetadata::SessionStorageMetadata() { … }
SessionStorageMetadata::~SessionStorageMetadata() { … }
std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>
SessionStorageMetadata::SetupNewDatabase() { … }
bool SessionStorageMetadata::ParseDatabaseVersion(
std::optional<std::vector<uint8_t>> value,
std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* upgrade_tasks) { … }
bool SessionStorageMetadata::ParseNamespaces(
std::vector<DomStorageDatabase::KeyValuePair> values,
std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* upgrade_tasks) { … }
void SessionStorageMetadata::ParseNextMapId(
const std::vector<uint8_t>& map_id) { … }
std::vector<uint8_t> SessionStorageMetadata::LatestDatabaseVersionAsVector() { … }
scoped_refptr<SessionStorageMetadata::MapData>
SessionStorageMetadata::RegisterNewMap(
NamespaceEntry namespace_entry,
const blink::StorageKey& storage_key,
std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks) { … }
void SessionStorageMetadata::RegisterShallowClonedNamespace(
NamespaceEntry source_namespace,
NamespaceEntry destination_namespace,
std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks) { … }
void SessionStorageMetadata::DeleteNamespace(
const std::string& namespace_id,
std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks) { … }
void SessionStorageMetadata::DeleteArea(
const std::string& namespace_id,
const blink::StorageKey& storage_key,
std::vector<AsyncDomStorageDatabase::BatchDatabaseTask>* save_tasks) { … }
SessionStorageMetadata::NamespaceEntry
SessionStorageMetadata::GetOrCreateNamespaceEntry(
const std::string& namespace_id) { … }
std::vector<uint8_t> SessionStorageMetadata::GetNamespacePrefix(
const std::string& namespace_id) { … }
std::vector<uint8_t> SessionStorageMetadata::GetAreaKey(
const std::string& namespace_id,
const blink::StorageKey& storage_key) { … }
std::vector<uint8_t> SessionStorageMetadata::GetMapPrefix(int64_t map_number) { … }
std::vector<uint8_t> SessionStorageMetadata::GetMapPrefix(
const std::vector<uint8_t>& map_number_as_bytes) { … }
}