FileSystemManagerChild.h (2016B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef DOM_FS_CHILD_FILESYSTEMMANAGERCHILD_H_ 8 #define DOM_FS_CHILD_FILESYSTEMMANAGERCHILD_H_ 9 10 #include "mozilla/dom/FileSystemWritableFileStreamChild.h" 11 #include "mozilla/dom/PFileSystemManagerChild.h" 12 #include "mozilla/dom/quota/ForwardDecls.h" 13 14 namespace mozilla::dom { 15 16 class FileSystemBackgroundRequestHandler; 17 18 class FileSystemManagerChild : public PFileSystemManagerChild { 19 public: 20 using ActorPromise = 21 MozPromise<RefPtr<FileSystemManagerChild>, nsresult, false>; 22 23 NS_INLINE_DECL_REFCOUNTING_WITH_DESTROY(FileSystemManagerChild, Destroy(), 24 override) 25 26 bool CloseAllReceived() const { return mCloseAllReceived; } 27 28 void SetBackgroundRequestHandler( 29 FileSystemBackgroundRequestHandler* aBackgroundRequestHandler); 30 31 void CloseAllWritables(std::function<void()>&& aCallback); 32 33 #ifdef DEBUG 34 virtual bool AllSyncAccessHandlesClosed() const; 35 36 virtual bool AllWritableFileStreamsClosed() const; 37 #endif 38 39 virtual void Shutdown(); 40 41 already_AddRefed<PFileSystemWritableFileStreamChild> 42 AllocPFileSystemWritableFileStreamChild(); 43 44 ::mozilla::ipc::IPCResult RecvCloseAll(CloseAllResolver&& aResolver); 45 46 void ActorDestroy(ActorDestroyReason aWhy) override; 47 48 protected: 49 virtual ~FileSystemManagerChild() = default; 50 51 virtual void Destroy() { 52 Shutdown(); 53 delete this; 54 } 55 56 // The weak reference is cleared in ActorDestroy. 57 FileSystemBackgroundRequestHandler* MOZ_NON_OWNING_REF 58 mBackgroundRequestHandler; 59 60 private: 61 template <class T> 62 void CloseAllWritablesImpl(T& aPromises); 63 64 bool mCloseAllReceived = false; 65 }; 66 67 } // namespace mozilla::dom 68 69 #endif // DOM_FS_CHILD_FILESYSTEMMANAGERCHILD_H_