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/api/FileSystemManager.h | 102 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 dom/fs/api/FileSystemManager.h (limited to 'dom/fs/api/FileSystemManager.h') diff --git a/dom/fs/api/FileSystemManager.h b/dom/fs/api/FileSystemManager.h new file mode 100644 index 0000000000..b910eacea2 --- /dev/null +++ b/dom/fs/api/FileSystemManager.h @@ -0,0 +1,102 @@ +/* -*- 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_FILESYSTEMMANAGER_H_ +#define DOM_FS_CHILD_FILESYSTEMMANAGER_H_ + +#include + +#include "mozilla/MozPromise.h" +#include "mozilla/UniquePtr.h" +#include "mozilla/dom/FlippedOnce.h" +#include "mozilla/dom/quota/ForwardDecls.h" +#include "nsCOMPtr.h" +#include "nsCycleCollectionParticipant.h" +#include "nsISupports.h" +#include "nsTObserverArray.h" + +class nsIGlobalObject; + +namespace mozilla { + +class ErrorResult; + +namespace dom { + +class FileSystemManagerChild; +class FileSystemBackgroundRequestHandler; +class StorageManager; + +namespace fs { +class FileSystemRequestHandler; +template +class ManagedMozPromiseRequestHolder; +} // namespace fs + +// `FileSystemManager` is supposed to be held by `StorageManager` and thus +// there should always be only one `FileSystemManager` per `nsIGlobalObject`. +// `FileSystemManager` is responsible for creating and eventually caching +// `FileSystemManagerChild` which is required for communication with the parent +// process. `FileSystemHandle` is also expected to hold `FileSystemManager`, +// but it should never clear the strong reference during cycle collection's +// unlink phase to keep the actor alive. `FileSystemSyncAccessHandle` and +// `FileSystemWritableFileStream` are also expected to hold `FileSystemManager`, +// and they shouldn't clear the strong reference during cycle collection's +// unlink phase as well even though they have their own actor. Those actors +// are managed by the top level actor, so if the top level actor is destroyed, +// the whole chain of managed actors would be destroyed as well. +class FileSystemManager : public nsISupports { + public: + template + using PromiseRequestHolder = + fs::ManagedMozPromiseRequestHolder; + + FileSystemManager( + nsIGlobalObject* aGlobal, RefPtr aStorageManager, + RefPtr aBackgroundRequestHandler); + + FileSystemManager(nsIGlobalObject* aGlobal, + RefPtr aStorageManager); + + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS(FileSystemManager) + + bool IsShutdown() const { return mShutdown; } + + void Shutdown(); + + const RefPtr& ActorStrongRef() const; + + void RegisterPromiseRequestHolder(PromiseRequestHolder* aHolder); + + void UnregisterPromiseRequestHolder( + PromiseRequestHolder* aHolder); + + void BeginRequest( + std::function&)>&& aSuccess, + std::function&& aFailure); + + already_AddRefed GetDirectory(ErrorResult& aError); + + private: + virtual ~FileSystemManager(); + + nsCOMPtr mGlobal; + + RefPtr mStorageManager; + + const RefPtr mBackgroundRequestHandler; + const UniquePtr mRequestHandler; + + nsTObserverArray*> mPromiseRequestHolders; + + FlippedOnce mShutdown; +}; + +} // namespace dom +} // namespace mozilla + +#endif // DOM_FS_CHILD_FILESYSTEMMANAGER_H_ -- cgit v1.2.3