From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/fs/include/fs/FileSystemAsyncCopy.h | 27 +++++++ dom/fs/include/fs/FileSystemChildFactory.h | 31 +++++++ dom/fs/include/fs/FileSystemConstants.h | 22 +++++ dom/fs/include/fs/FileSystemRequestHandler.h | 94 ++++++++++++++++++++++ dom/fs/include/fs/FileSystemShutdownBlocker.h | 33 ++++++++ .../include/fs/FileSystemThreadSafeStreamOwner.h | 52 ++++++++++++ 6 files changed, 259 insertions(+) create mode 100644 dom/fs/include/fs/FileSystemAsyncCopy.h create mode 100644 dom/fs/include/fs/FileSystemChildFactory.h create mode 100644 dom/fs/include/fs/FileSystemConstants.h create mode 100644 dom/fs/include/fs/FileSystemRequestHandler.h create mode 100644 dom/fs/include/fs/FileSystemShutdownBlocker.h create mode 100644 dom/fs/include/fs/FileSystemThreadSafeStreamOwner.h (limited to 'dom/fs/include') diff --git a/dom/fs/include/fs/FileSystemAsyncCopy.h b/dom/fs/include/fs/FileSystemAsyncCopy.h new file mode 100644 index 0000000000..a82a7e9007 --- /dev/null +++ b/dom/fs/include/fs/FileSystemAsyncCopy.h @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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_ASYNCCOPY_H_ +#define DOM_FS_ASYNCCOPY_H_ + +#include "mozilla/MoveOnlyFunction.h" +#include "nsStreamUtils.h" + +class nsIInputStream; +class nsIOutputStream; +class nsISerialEventTarget; + +namespace mozilla::dom::fs { + +nsresult AsyncCopy(nsIInputStream* aSource, nsIOutputStream* aSink, + nsISerialEventTarget* aIOTarget, const nsAsyncCopyMode aMode, + const bool aCloseSource, const bool aCloseSink, + std::function&& aProgressCallback, + MoveOnlyFunction&& aCompleteCallback); + +} // namespace mozilla::dom::fs + +#endif // DOM_FS_ASYNCCOPY_H_ diff --git a/dom/fs/include/fs/FileSystemChildFactory.h b/dom/fs/include/fs/FileSystemChildFactory.h new file mode 100644 index 0000000000..7fe58d65e9 --- /dev/null +++ b/dom/fs/include/fs/FileSystemChildFactory.h @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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_FILESYSTEMCHILDFACTORY_H_ +#define DOM_FS_FILESYSTEMCHILDFACTORY_H_ + +#include "mozilla/AlreadyAddRefed.h" + +namespace mozilla { +class ErrorResult; + +namespace dom { +class FileSystemManagerChild; +} // namespace dom +} // namespace mozilla + +namespace mozilla::dom::fs { + +class FileSystemChildFactory { + public: + virtual already_AddRefed Create() const; + + virtual ~FileSystemChildFactory() = default; +}; + +} // namespace mozilla::dom::fs + +#endif // DOM_FS_FILESYSTEMCHILDFACTORY_H_ diff --git a/dom/fs/include/fs/FileSystemConstants.h b/dom/fs/include/fs/FileSystemConstants.h new file mode 100644 index 0000000000..761d333cdc --- /dev/null +++ b/dom/fs/include/fs/FileSystemConstants.h @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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_FILESYSTEMCONSTANTS_H_ +#define DOM_FS_FILESYSTEMCONSTANTS_H_ + +#include "nsLiteralString.h" + +namespace mozilla::dom::fs { + +constexpr nsLiteralString kRootName = u""_ns; + +constexpr nsLiteralString kRootString = u"root"_ns; + +constexpr uint32_t kStreamCopyBlockSize = 1024 * 1024; + +} // namespace mozilla::dom::fs + +#endif // DOM_FS_FILESYSTEMCONSTANTS_H_ diff --git a/dom/fs/include/fs/FileSystemRequestHandler.h b/dom/fs/include/fs/FileSystemRequestHandler.h new file mode 100644 index 0000000000..d535d75164 --- /dev/null +++ b/dom/fs/include/fs/FileSystemRequestHandler.h @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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_CHILD_FILESYSTEMREQUESTHANDLER_H_ +#define DOM_FS_CHILD_FILESYSTEMREQUESTHANDLER_H_ + +#include "mozilla/dom/FileSystemTypes.h" + +template +class RefPtr; + +namespace mozilla { + +class ErrorResult; + +namespace dom { + +class FileSystemHandle; +class FileSystemManager; +class Promise; + +namespace fs { + +class FileSystemChildMetadata; +class FileSystemEntryMetadata; +class FileSystemEntryMetadataArray; +class FileSystemEntryPair; + +class FileSystemRequestHandler { + public: + virtual void GetRootHandle(RefPtr aManager, + RefPtr aPromise, ErrorResult& aError); + + virtual void GetDirectoryHandle(RefPtr& aManager, + const FileSystemChildMetadata& aDirectory, + bool aCreate, RefPtr aPromise, + ErrorResult& aError); + + virtual void GetFileHandle(RefPtr& aManager, + const FileSystemChildMetadata& aFile, bool aCreate, + RefPtr aPromise, ErrorResult& aError); + + virtual void GetFile(RefPtr& aManager, + const FileSystemEntryMetadata& aFile, + RefPtr aPromise, ErrorResult& aError); + + virtual void GetAccessHandle(RefPtr& aManager, + const FileSystemEntryMetadata& aFile, + const RefPtr& aPromise, + ErrorResult& aError); + + virtual void GetWritable(RefPtr& aManager, + const FileSystemEntryMetadata& aFile, bool aKeepData, + const RefPtr& aPromise, + ErrorResult& aError); + + virtual void GetEntries(RefPtr& aManager, + const EntryId& aDirectory, PageNumber aPage, + RefPtr aPromise, + RefPtr& aSink, + ErrorResult& aError); + + virtual void RemoveEntry(RefPtr& aManager, + const FileSystemChildMetadata& aEntry, + bool aRecursive, RefPtr aPromise, + ErrorResult& aError); + + virtual void MoveEntry(RefPtr& aManager, + FileSystemHandle* aHandle, + const FileSystemEntryMetadata& aEntry, + const FileSystemChildMetadata& aNewEntry, + RefPtr aPromise, ErrorResult& aError); + + virtual void RenameEntry(RefPtr& aManager, + FileSystemHandle* aHandle, + const FileSystemEntryMetadata& aEntry, + const Name& aName, RefPtr aPromise, + ErrorResult& aError); + + virtual void Resolve(RefPtr& aManager, + const FileSystemEntryPair& aEndpoints, + RefPtr aPromise, ErrorResult& aError); + + virtual ~FileSystemRequestHandler() = default; +}; // class FileSystemRequestHandler + +} // namespace fs +} // namespace dom +} // namespace mozilla + +#endif // DOM_FS_CHILD_FILESYSTEMREQUESTHANDLER_H_ diff --git a/dom/fs/include/fs/FileSystemShutdownBlocker.h b/dom/fs/include/fs/FileSystemShutdownBlocker.h new file mode 100644 index 0000000000..f11d263f4e --- /dev/null +++ b/dom/fs/include/fs/FileSystemShutdownBlocker.h @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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_CHILD_FILESYSTEMMANAGERCHILDBLOCKER_H_ +#define DOM_FS_CHILD_FILESYSTEMMANAGERCHILDBLOCKER_H_ + +#include "mozilla/AlreadyAddRefed.h" +#include "nsIAsyncShutdown.h" +#include "nsISupports.h" + +namespace mozilla::dom::fs { + +class FileSystemShutdownBlocker : public nsIAsyncShutdownBlocker { + public: + static already_AddRefed CreateForWritable(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIASYNCSHUTDOWNBLOCKER + + virtual NS_IMETHODIMP Block() = 0; + + virtual NS_IMETHODIMP Unblock() = 0; + + protected: + virtual ~FileSystemShutdownBlocker() = default; +}; + +} // namespace mozilla::dom::fs + +#endif // DOM_FS_CHILD_FILESYSTEMMANAGERCHILDBLOCKER_H_ diff --git a/dom/fs/include/fs/FileSystemThreadSafeStreamOwner.h b/dom/fs/include/fs/FileSystemThreadSafeStreamOwner.h new file mode 100644 index 0000000000..3ef7639f36 --- /dev/null +++ b/dom/fs/include/fs/FileSystemThreadSafeStreamOwner.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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_FILESYSTEMTHREADSAFESTREAMOWNER_H_ +#define DOM_FS_FILESYSTEMTHREADSAFESTREAMOWNER_H_ + +#include "nsCOMPtr.h" + +class nsIOutputStream; +class nsIRandomAccessStream; + +namespace mozilla::dom { + +class FileSystemWritableFileStream; + +namespace fs { + +class FileSystemThreadSafeStreamOwner { + public: + FileSystemThreadSafeStreamOwner( + FileSystemWritableFileStream* aWritableFileStream, + nsCOMPtr&& aStream); + + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemThreadSafeStreamOwner) + + nsresult Truncate(uint64_t aSize); + + nsresult Seek(uint64_t aPosition); + + void Close(); + + nsCOMPtr OutputStream(); + + protected: + virtual ~FileSystemThreadSafeStreamOwner() = default; + + private: +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED + FileSystemWritableFileStream* MOZ_NON_OWNING_REF mWritableFileStream; +#endif + nsCOMPtr mStream; + + bool mClosed; +}; + +} // namespace fs +} // namespace mozilla::dom + +#endif // DOM_FS_FILESYSTEMTHREADSAFESTREAMOWNER_H_ -- cgit v1.2.3