Bug 1697115 - Rename mTimestamp to mLastAccessTime in FullOriginMetadata; r=dom-storage-reviewers,sg

Differential Revision: https://phabricator.services.mozilla.com/D107609
This commit is contained in:
Jan Varga 2021-03-17 06:56:37 +00:00
Родитель 3732339b05
Коммит 83de9af404
2 изменённых файлов: 29 добавлений и 28 удалений

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

@ -4135,7 +4135,7 @@ nsresult QuotaManager::LoadQuota() {
QM_TRY_INSPECT(const auto& metadata, QM_TRY_INSPECT(const auto& metadata,
LoadFullOriginMetadataWithRestore(directory)); LoadFullOriginMetadataWithRestore(directory));
QM_TRY(OkIf(lastAccessTime == metadata.mTimestamp), QM_TRY(OkIf(lastAccessTime == metadata.mLastAccessTime),
Err(NS_ERROR_FAILURE)); Err(NS_ERROR_FAILURE));
QM_TRY(OkIf(persisted == metadata.mPersisted), QM_TRY(OkIf(persisted == metadata.mPersisted),
@ -4558,7 +4558,7 @@ Result<FullOriginMetadata, nsresult> QuotaManager::LoadFullOriginMetadata(
FullOriginMetadata fullOriginMetadata; FullOriginMetadata fullOriginMetadata;
QM_TRY_UNWRAP(fullOriginMetadata.mTimestamp, QM_TRY_UNWRAP(fullOriginMetadata.mLastAccessTime,
MOZ_TO_RESULT_INVOKE(binaryStream, Read64)); MOZ_TO_RESULT_INVOKE(binaryStream, Read64));
QM_TRY_UNWRAP(fullOriginMetadata.mPersisted, QM_TRY_UNWRAP(fullOriginMetadata.mPersisted,
@ -4600,9 +4600,9 @@ Result<FullOriginMetadata, nsresult> QuotaManager::LoadFullOriginMetadata(
if (updated) { if (updated) {
// Only overwriting .metadata-v2 (used to overwrite .metadata too) to reduce // Only overwriting .metadata-v2 (used to overwrite .metadata too) to reduce
// I/O. // I/O.
QM_TRY(CreateDirectoryMetadata2(*aDirectory, fullOriginMetadata.mTimestamp, QM_TRY(CreateDirectoryMetadata2(
fullOriginMetadata.mPersisted, *aDirectory, fullOriginMetadata.mLastAccessTime,
fullOriginMetadata)); fullOriginMetadata.mPersisted, fullOriginMetadata));
} }
return fullOriginMetadata; return fullOriginMetadata;
@ -4712,11 +4712,12 @@ nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType) {
// If it's the known case, we try to restore the // If it's the known case, we try to restore the
// origin directory name if it's possible. // origin directory name if it's possible.
if (originSanitized.Equals(utf8LeafName + "."_ns)) { if (originSanitized.Equals(utf8LeafName + "."_ns)) {
const int64_t timestamp = metadata.mTimestamp; const int64_t lastAccessTime =
metadata.mLastAccessTime;
const bool persisted = metadata.mPersisted; const bool persisted = metadata.mPersisted;
renameAndInitInfos.AppendElement(RenameAndInitInfo{ renameAndInitInfos.AppendElement(RenameAndInitInfo{
std::move(childDirectory), std::move(metadata), std::move(childDirectory), std::move(metadata),
timestamp, persisted}); lastAccessTime, persisted});
break; break;
} }
@ -4726,26 +4727,26 @@ nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType) {
// they won't be accessed after initialization. // they won't be accessed after initialization.
} }
QM_TRY(ToResult(InitializeOrigin(aPersistenceType, QM_TRY(
metadata, ToResult(InitializeOrigin(
metadata.mTimestamp, aPersistenceType, metadata,
metadata.mPersisted, metadata.mLastAccessTime,
childDirectory)) metadata.mPersisted, childDirectory))
.orElse([&childDirectory](const nsresult rv) .orElse([&childDirectory](const nsresult rv)
-> Result<Ok, nsresult> { -> Result<Ok, nsresult> {
if (IsDatabaseCorruptionError(rv)) { if (IsDatabaseCorruptionError(rv)) {
// If the origin can't be initialized due // If the origin can't be initialized due
// to corruption, this is a permanent // to corruption, this is a permanent
// condition, and we need to remove all // condition, and we need to remove all
// data for the origin on disk. // data for the origin on disk.
QM_TRY(childDirectory->Remove(true)); QM_TRY(childDirectory->Remove(true));
return Ok{}; return Ok{};
} }
return Err(rv); return Err(rv);
})); }));
break; break;
} }
@ -6110,9 +6111,9 @@ QuotaManager::EnsurePersistentOriginIsInitialized(
const auto& metadata, const auto& metadata,
LoadFullOriginMetadataWithRestore(directory)); LoadFullOriginMetadataWithRestore(directory));
MOZ_ASSERT(metadata.mTimestamp <= PR_Now()); MOZ_ASSERT(metadata.mLastAccessTime <= PR_Now());
return metadata.mTimestamp; return metadata.mLastAccessTime;
}())); }()));
QM_TRY(InitializeOrigin(PERSISTENCE_TYPE_PERSISTENT, aOriginMetadata, QM_TRY(InitializeOrigin(PERSISTENCE_TYPE_PERSISTENT, aOriginMetadata,
@ -8447,7 +8448,7 @@ nsresult GetUsageOp::ProcessOrigin(QuotaManager& aQuotaManager,
GetUsageForOrigin(aQuotaManager, aPersistenceType, metadata)); GetUsageForOrigin(aQuotaManager, aPersistenceType, metadata));
ProcessOriginInternal(&aQuotaManager, aPersistenceType, metadata.mOrigin, ProcessOriginInternal(&aQuotaManager, aPersistenceType, metadata.mOrigin,
metadata.mTimestamp, metadata.mPersisted, metadata.mLastAccessTime, metadata.mPersisted,
usageInfo.TotalUsage().valueOr(0)); usageInfo.TotalUsage().valueOr(0));
return NS_OK; return NS_OK;

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

@ -48,7 +48,7 @@ struct OriginMetadata : public PrincipalMetadata {
struct FullOriginMetadata : OriginMetadata { struct FullOriginMetadata : OriginMetadata {
bool mPersisted; bool mPersisted;
int64_t mTimestamp; int64_t mLastAccessTime;
// XXX Only default construction is needed for now. // XXX Only default construction is needed for now.
}; };