summaryrefslogtreecommitdiffstats
path: root/dom/fs/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dom/fs/include/fs/FileSystemAsyncCopy.h27
-rw-r--r--dom/fs/include/fs/FileSystemChildFactory.h31
-rw-r--r--dom/fs/include/fs/FileSystemConstants.h22
-rw-r--r--dom/fs/include/fs/FileSystemRequestHandler.h94
-rw-r--r--dom/fs/include/fs/FileSystemShutdownBlocker.h33
-rw-r--r--dom/fs/include/fs/FileSystemThreadSafeStreamOwner.h52
6 files changed, 259 insertions, 0 deletions
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<void(uint32_t)>&& aProgressCallback,
+ MoveOnlyFunction<void(nsresult)>&& 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<FileSystemManagerChild> 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 T>
+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<FileSystemManager> aManager,
+ RefPtr<Promise> aPromise, ErrorResult& aError);
+
+ virtual void GetDirectoryHandle(RefPtr<FileSystemManager>& aManager,
+ const FileSystemChildMetadata& aDirectory,
+ bool aCreate, RefPtr<Promise> aPromise,
+ ErrorResult& aError);
+
+ virtual void GetFileHandle(RefPtr<FileSystemManager>& aManager,
+ const FileSystemChildMetadata& aFile, bool aCreate,
+ RefPtr<Promise> aPromise, ErrorResult& aError);
+
+ virtual void GetFile(RefPtr<FileSystemManager>& aManager,
+ const FileSystemEntryMetadata& aFile,
+ RefPtr<Promise> aPromise, ErrorResult& aError);
+
+ virtual void GetAccessHandle(RefPtr<FileSystemManager>& aManager,
+ const FileSystemEntryMetadata& aFile,
+ const RefPtr<Promise>& aPromise,
+ ErrorResult& aError);
+
+ virtual void GetWritable(RefPtr<FileSystemManager>& aManager,
+ const FileSystemEntryMetadata& aFile, bool aKeepData,
+ const RefPtr<Promise>& aPromise,
+ ErrorResult& aError);
+
+ virtual void GetEntries(RefPtr<FileSystemManager>& aManager,
+ const EntryId& aDirectory, PageNumber aPage,
+ RefPtr<Promise> aPromise,
+ RefPtr<FileSystemEntryMetadataArray>& aSink,
+ ErrorResult& aError);
+
+ virtual void RemoveEntry(RefPtr<FileSystemManager>& aManager,
+ const FileSystemChildMetadata& aEntry,
+ bool aRecursive, RefPtr<Promise> aPromise,
+ ErrorResult& aError);
+
+ virtual void MoveEntry(RefPtr<FileSystemManager>& aManager,
+ FileSystemHandle* aHandle,
+ const FileSystemEntryMetadata& aEntry,
+ const FileSystemChildMetadata& aNewEntry,
+ RefPtr<Promise> aPromise, ErrorResult& aError);
+
+ virtual void RenameEntry(RefPtr<FileSystemManager>& aManager,
+ FileSystemHandle* aHandle,
+ const FileSystemEntryMetadata& aEntry,
+ const Name& aName, RefPtr<Promise> aPromise,
+ ErrorResult& aError);
+
+ virtual void Resolve(RefPtr<FileSystemManager>& aManager,
+ const FileSystemEntryPair& aEndpoints,
+ RefPtr<Promise> 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<FileSystemShutdownBlocker> 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<nsIRandomAccessStream>&& aStream);
+
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemThreadSafeStreamOwner)
+
+ nsresult Truncate(uint64_t aSize);
+
+ nsresult Seek(uint64_t aPosition);
+
+ void Close();
+
+ nsCOMPtr<nsIOutputStream> OutputStream();
+
+ protected:
+ virtual ~FileSystemThreadSafeStreamOwner() = default;
+
+ private:
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+ FileSystemWritableFileStream* MOZ_NON_OWNING_REF mWritableFileStream;
+#endif
+ nsCOMPtr<nsIRandomAccessStream> mStream;
+
+ bool mClosed;
+};
+
+} // namespace fs
+} // namespace mozilla::dom
+
+#endif // DOM_FS_FILESYSTEMTHREADSAFESTREAMOWNER_H_