JSOracleParent.h (1399B)
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 mozilla_dom_JSOracleParent 8 #define mozilla_dom_JSOracleParent 9 10 #include "mozilla/MozPromise.h" 11 #include "mozilla/ProcInfo.h" 12 #include "mozilla/dom/PJSOracleParent.h" 13 14 namespace mozilla::ipc { 15 class UtilityProcessParent; 16 } 17 18 namespace mozilla::dom { 19 20 class JSOracleParent final : public PJSOracleParent { 21 public: 22 JSOracleParent() = default; 23 24 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSOracleParent, override); 25 26 static void WithJSOracle( 27 const std::function<void(JSOracleParent* aParent)>& aCallback); 28 29 UtilityActorName GetActorName() { return UtilityActorName::JSOracle; } 30 31 void ActorDestroy(ActorDestroyReason aReason) override; 32 33 nsresult BindToUtilityProcess( 34 const RefPtr<mozilla::ipc::UtilityProcessParent>& aUtilityParent); 35 36 void Bind(Endpoint<PJSOracleParent>&& aEndpoint); 37 38 private: 39 ~JSOracleParent() = default; 40 41 static JSOracleParent* GetSingleton(); 42 43 using JSOraclePromise = GenericNonExclusivePromise; 44 RefPtr<JSOraclePromise> StartJSOracle(); 45 }; 46 } // namespace mozilla::dom 47 48 #endif // defined(mozilla_dom_JSOracleParent)