Bug 1809066 - Check the file size after closing RemoteQuotaObjectParent; r=dom-storage-reviewers,jari

Depends on D166346

Differential Revision: https://phabricator.services.mozilla.com/D166348
This commit is contained in:
Jan Varga 2023-02-07 08:27:08 +00:00
Родитель 0b16483618
Коммит f338a5e2f4
2 изменённых файлов: 19 добавлений и 3 удалений

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

@ -8,6 +8,7 @@
#include "CanonicalQuotaObject.h"
#include "mozilla/dom/quota/RemoteQuotaObjectParentTracker.h"
#include "mozilla/dom/quota/ResultExtensions.h"
#include "mozilla/ipc/BackgroundParent.h"
namespace mozilla::dom::quota {
@ -31,9 +32,7 @@ mozilla::ipc::IPCResult RemoteQuotaObjectParent::RecvMaybeUpdateSize(
}
void RemoteQuotaObjectParent::ActorDestroy(ActorDestroyReason aWhy) {
// XXX Check that the child properly used `MaybeUpdateSize` before each
// write, so the file size on disk matches mCanonicalQuotaObject::mSize.
// If the size doesn't match, do necessary adjustments.
QM_WARNONLY_TRY(MOZ_TO_RESULT(CheckFileAfterClose()));
mCanonicalQuotaObject = nullptr;
@ -42,4 +41,19 @@ void RemoteQuotaObjectParent::ActorDestroy(ActorDestroyReason aWhy) {
}
}
nsresult RemoteQuotaObjectParent::CheckFileAfterClose() {
MOZ_ASSERT(mCanonicalQuotaObject);
QM_TRY_INSPECT(const auto& file,
QM_NewLocalFile(mCanonicalQuotaObject->Path()));
QM_TRY_UNWRAP(auto size, MOZ_TO_RESULT_INVOKE_MEMBER(file, GetFileSize));
DebugOnly<bool> res =
mCanonicalQuotaObject->MaybeUpdateSize(size, /* aTruncate */ true);
MOZ_ASSERT(res);
return NS_OK;
}
} // namespace mozilla::dom::quota

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

@ -29,6 +29,8 @@ class RemoteQuotaObjectParent : public PRemoteQuotaObjectParent {
private:
virtual ~RemoteQuotaObjectParent();
nsresult CheckFileAfterClose();
RefPtr<CanonicalQuotaObject> mCanonicalQuotaObject;
nsCOMPtr<RemoteQuotaObjectParentTracker> mTracker;