Bug 1789585 - Store total file size and if size is constant to usage schema. r=dom-storage-reviewers,janv

Depends on D163634

Differential Revision: https://phabricator.services.mozilla.com/D163699
This commit is contained in:
Jari Jalkanen 2023-01-05 11:51:28 +00:00
Родитель d4d1d62c61
Коммит b31c4e77db
2 изменённых файлов: 14 добавлений и 10 удалений

Просмотреть файл

@ -24,7 +24,7 @@ Result<nsCOMPtr<nsIFile>, QMResult> GetDirectoryForOrigin(
QM_TRY_UNWRAP(auto directory, QM_TO_RESULT_TRANSFORM(quota::QM_NewLocalFile(
aQuotaManager.GetBasePath())));
QM_TRY(QM_TO_RESULT(directory->Append(u"opfs-storage"_ns)));
QM_TRY(QM_TO_RESULT(directory->Append(u"opfs-storage2"_ns)));
QM_TRY_UNWRAP(auto originHash,
data::FileSystemHashSource::GenerateHash(

Просмотреть файл

@ -58,6 +58,19 @@ nsresult CreateFiles(ResultConnection& aConn) {
";"_ns);
}
nsresult CreateUsages(ResultConnection& aConn) {
return aConn->ExecuteSimpleSQL(
"CREATE TABLE IF NOT EXISTS Usages ( "
"handle BLOB PRIMARY KEY, "
"usage INTEGER NOT NULL DEFAULT 0, "
"tracked BOOLEAN NOT NULL DEFAULT 0 CHECK (tracked IN (0, 1)), "
"CONSTRAINT handles_are_files "
"FOREIGN KEY (handle) "
"REFERENCES Files (handle) "
"ON DELETE CASCADE ) "
";"_ns);
}
class KeepForeignKeysOffUntilScopeExit final {
public:
explicit KeepForeignKeysOffUntilScopeExit(const ResultConnection& aConn)
@ -122,15 +135,6 @@ nsresult CreateRootEntry(ResultConnection& aConn, const Origin& aOrigin) {
return transaction.Commit();
}
nsresult CreateUsages(ResultConnection& aConn) {
return aConn->ExecuteSimpleSQL(
"CREATE TABLE IF NOT EXISTS Usages ( "
"usage INTEGER NOT NULL, "
"aggregated BOOLEAN DEFAULT FALSE "
") "
";"_ns);
}
Result<bool, QMResult> CheckIfEmpty(ResultConnection& aConn) {
const nsLiteralCString areThereTablesQuery =
"SELECT EXISTS ("