ManagedMozPromiseRequestHolder.h (1151B)
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_SHARED_MANAGEDMOZPROMISEREQUESTHOLDER_H_ 8 #define DOM_FS_SHARED_MANAGEDMOZPROMISEREQUESTHOLDER_H_ 9 10 #include "mozilla/MozPromise.h" 11 #include "mozilla/RefPtr.h" 12 #include "nsISupportsImpl.h" 13 14 namespace mozilla::dom::fs { 15 16 template <typename Manager, typename PromiseType> 17 class ManagedMozPromiseRequestHolder final 18 : public MozPromiseRequestHolder<PromiseType> { 19 public: 20 explicit ManagedMozPromiseRequestHolder(Manager* aManager) 21 : mManager(aManager) { 22 mManager->RegisterPromiseRequestHolder(this); 23 } 24 25 NS_INLINE_DECL_REFCOUNTING(ManagedMozPromiseRequestHolder) 26 27 private: 28 ~ManagedMozPromiseRequestHolder() { 29 mManager->UnregisterPromiseRequestHolder(this); 30 } 31 32 RefPtr<Manager> mManager; 33 }; 34 35 } // namespace mozilla::dom::fs 36 37 #endif // DOM_FS_SHARED_MANAGEDMOZPROMISEREQUESTHOLDER_H_