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/. */
7 #ifndef mozilla_dom_JSOracleChild
8 #define mozilla_dom_JSOracleChild
10 #include "mozilla/dom/PJSOracleChild.h"
12 #include "js/experimental/JSStencil.h"
13 #include "js/experimental/CompileScript.h"
14 #include "js/Initialization.h"
17 namespace mozilla::ipc
{
18 class UtilityProcessParent
;
21 namespace mozilla::dom
{
22 struct JSFrontendContextHolder
{
23 JSFrontendContextHolder() {
24 MOZ_RELEASE_ASSERT(JS_IsInitialized(),
25 "UtilityProcessChild::Init should have JS initialized");
27 mFc
= JS::NewFrontendContext();
29 MOZ_CRASH("Failed to create JS FrontendContext");
33 // See the comment in XPCJSContext::Initialize.
34 const size_t kDefaultStackQuota
= 128 * sizeof(size_t) * 1024;
36 JS::SetNativeStackQuota(mFc
, kDefaultStackQuota
);
39 ~JSFrontendContextHolder() {
41 JS::DestroyFrontendContext(mFc
);
45 static void MaybeInit();
47 JS::FrontendContext
* mFc
;
50 class PJSValidatorChild
;
52 class JSOracleChild final
: public PJSOracleChild
{
54 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSOracleChild
, override
);
56 already_AddRefed
<PJSValidatorChild
> AllocPJSValidatorChild();
58 void Start(Endpoint
<PJSOracleChild
>&& aEndpoint
);
60 static JS::FrontendContext
* JSFrontendContext();
63 ~JSOracleChild() = default;
65 static JSOracleChild
* GetSingleton();
67 } // namespace mozilla::dom
69 #endif // defined(mozilla_dom_JSOracleChild)