Bug 1908663 - Move TargetPtrHolder.h to dom/quota; r=dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D225919
This commit is contained in:
Jan Varga 2024-10-29 00:51:19 +00:00
parent 262a8eb2f9
commit 117cb49ba4
6 changed files with 19 additions and 19 deletions

View File

@ -26,9 +26,9 @@
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/fs/IPCRejectReporter.h"
#include "mozilla/dom/fs/TargetPtrHolder.h"
#include "mozilla/dom/quota/QuotaCommon.h"
#include "mozilla/dom/quota/ResultExtensions.h"
#include "mozilla/dom/quota/TargetPtrHolder.h"
#include "mozilla/ipc/RandomAccessStreamUtils.h"
#include "nsNetCID.h"
#include "nsStringStream.h"
@ -231,7 +231,7 @@ RefPtr<BoolPromise> FileSystemSyncAccessHandle::BeginClose() {
mState = State::Closing;
InvokeAsync(mIOTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this)]() {
[selfHolder = quota::TargetPtrHolder(this)]() {
if (selfHolder->mStream) {
LOG(("%p: Closing", selfHolder->mStream.get()));
@ -337,7 +337,7 @@ void FileSystemSyncAccessHandle::Truncate(uint64_t aSize, ErrorResult& aError) {
InvokeAsync(
mIOTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this), aSize]() {
[selfHolder = quota::TargetPtrHolder(this), aSize]() {
QM_TRY(MOZ_TO_RESULT(selfHolder->EnsureStream()),
CreateAndRejectBoolPromise);
@ -398,7 +398,7 @@ uint64_t FileSystemSyncAccessHandle::GetSize(ErrorResult& aError) {
int64_t size;
InvokeAsync(mIOTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this)]() {
[selfHolder = quota::TargetPtrHolder(this)]() {
QM_TRY(MOZ_TO_RESULT(selfHolder->EnsureStream()),
CreateAndRejectSizePromise);
@ -457,7 +457,7 @@ void FileSystemSyncAccessHandle::Flush(ErrorResult& aError) {
});
InvokeAsync(mIOTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this)]() {
[selfHolder = quota::TargetPtrHolder(this)]() {
QM_TRY(MOZ_TO_RESULT(selfHolder->EnsureStream()),
CreateAndRejectBoolPromise);
@ -562,7 +562,7 @@ uint64_t FileSystemSyncAccessHandle::ReadOrWrite(
ProcessTypedArraysFixed(aBuffer, [&](const Span<uint8_t> aData) {
InvokeAsync(
mIOTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this), aData,
[selfHolder = quota::TargetPtrHolder(this), aData,
use_offset = aOptions.mAt.WasPassed(), offset, aRead, syncLoopTarget,
&totalCount]() {
QM_TRY(MOZ_TO_RESULT(selfHolder->EnsureStream()),

View File

@ -27,9 +27,9 @@
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WritableStreamDefaultController.h"
#include "mozilla/dom/fs/TargetPtrHolder.h"
#include "mozilla/dom/quota/QuotaCommon.h"
#include "mozilla/dom/quota/ResultExtensions.h"
#include "mozilla/dom/quota/TargetPtrHolder.h"
#include "mozilla/ipc/RandomAccessStreamUtils.h"
#include "nsAsyncStreamCopier.h"
#include "nsIInputStream.h"
@ -418,7 +418,7 @@ RefPtr<BoolPromise> FileSystemWritableFileStream::BeginFinishing(
if (mCloseHandler->SetClosing()) {
Finish()
->Then(mTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this)]() mutable {
[selfHolder = quota::TargetPtrHolder(this)]() mutable {
if (selfHolder->mStreamOwner) {
selfHolder->mStreamOwner->Close();
} else {
@ -857,7 +857,7 @@ RefPtr<Int64Promise> FileSystemWritableFileStream::WriteImpl(
nsCOMPtr<nsIInputStream> aInputStream, const Maybe<uint64_t> aPosition) {
return InvokeAsync(
mTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this),
[selfHolder = quota::TargetPtrHolder(this),
inputStream = std::move(aInputStream), aPosition]() {
QM_TRY(MOZ_TO_RESULT(selfHolder->EnsureStream()),
CreateAndRejectInt64Promise);
@ -911,7 +911,7 @@ RefPtr<BoolPromise> FileSystemWritableFileStream::Seek(uint64_t aPosition) {
return InvokeAsync(
mTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this), aPosition]() mutable {
[selfHolder = quota::TargetPtrHolder(this), aPosition]() mutable {
QM_TRY(MOZ_TO_RESULT(selfHolder->EnsureStream()),
CreateAndRejectBoolPromise);
@ -927,7 +927,7 @@ RefPtr<BoolPromise> FileSystemWritableFileStream::Truncate(uint64_t aSize) {
return InvokeAsync(
mTaskQueue, __func__,
[selfHolder = fs::TargetPtrHolder(this), aSize]() mutable {
[selfHolder = quota::TargetPtrHolder(this), aSize]() mutable {
QM_TRY(MOZ_TO_RESULT(selfHolder->EnsureStream()),
CreateAndRejectBoolPromise);

View File

@ -13,7 +13,6 @@ EXPORTS.mozilla.dom += [
EXPORTS.mozilla.dom.fs += [
"IPCRejectReporter.h",
"ManagedMozPromiseRequestHolder.h",
"TargetPtrHolder.h",
]
UNIFIED_SOURCES += [

View File

@ -9,10 +9,10 @@
#include "mozilla/Assertions.h"
#include "mozilla/MozPromise.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/dom/fs/TargetPtrHolder.h"
#include "mozilla/dom/quota/OriginOperationCallbacks.h"
#include "mozilla/dom/quota/QuotaManager.h"
#include "mozilla/dom/quota/ResultExtensions.h"
#include "mozilla/dom/quota/TargetPtrHolder.h"
#include "nsError.h"
#include "nsIThread.h"
#include "nsThreadUtils.h"
@ -88,7 +88,7 @@ void OriginOperationBase::RunImmediately() {
})
#endif
->Then(mQuotaManager->IOThread(), __func__,
[selfHolder = fs::TargetPtrHolder(this)](
[selfHolder = TargetPtrHolder(this)](
const BoolPromise::ResolveOrRejectValue& aValue) {
if (aValue.IsReject()) {
return BoolPromise::CreateAndReject(aValue.RejectValue(),

View File

@ -4,15 +4,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_FS_SHARED_TARGETPTRHOLDER_H_
#define DOM_FS_SHARED_TARGETPTRHOLDER_H_
#ifndef DOM_QUOTA_TARGETPTRHOLDER_H_
#define DOM_QUOTA_TARGETPTRHOLDER_H_
#include "mozilla/RefPtr.h"
#include "nsCOMPtr.h"
#include "nsProxyRelease.h"
#include "nsThreadUtils.h"
namespace mozilla::dom::fs {
namespace mozilla::dom::quota {
// TODO: Remove this ad hoc class when bug 1805830 is fixed.
template <typename T>
@ -54,6 +54,6 @@ class TargetPtrHolder {
RefPtr<T> mPtr;
};
} // namespace mozilla::dom::fs
} // namespace mozilla::dom::quota
#endif // DOM_FS_SHARED_TARGETPTRHOLDER_H_
#endif // DOM_QUOTA_TARGETPTRHOLDER_H_

View File

@ -93,6 +93,7 @@ EXPORTS.mozilla.dom.quota += [
"StorageHelpers.h",
"StreamUtils.h",
"StringifyUtils.h",
"TargetPtrHolder.h",
"ThreadUtils.h",
"UniversalDirectoryLock.h",
"UsageInfo.h",