no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / ipc / JSOracleChild.h
blobf62ef7134c11804388366c91512a067dbe4b2985
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"
15 #include "jsapi.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();
28 if (!mFc) {
29 MOZ_CRASH("Failed to create JS FrontendContext");
30 return;
33 // See the comment in XPCJSContext::Initialize.
34 const size_t kDefaultStackQuota = 128 * sizeof(size_t) * 1024;
36 JS::SetNativeStackQuota(mFc, kDefaultStackQuota);
39 ~JSFrontendContextHolder() {
40 if (mFc) {
41 JS::DestroyFrontendContext(mFc);
45 static void MaybeInit();
47 JS::FrontendContext* mFc;
50 class PJSValidatorChild;
52 class JSOracleChild final : public PJSOracleChild {
53 public:
54 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSOracleChild, override);
56 already_AddRefed<PJSValidatorChild> AllocPJSValidatorChild();
58 void Start(Endpoint<PJSOracleChild>&& aEndpoint);
60 static JS::FrontendContext* JSFrontendContext();
62 private:
63 ~JSOracleChild() = default;
65 static JSOracleChild* GetSingleton();
67 } // namespace mozilla::dom
69 #endif // defined(mozilla_dom_JSOracleChild)