Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / ipc / JSOracleChild.cpp
blob1ac495ab87faaeb05dc8bb4711fdd9907830c793
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 #include "mozilla/dom/JSOracleChild.h"
9 #include "mozilla/ClearOnShutdown.h"
10 #include "mozilla/dom/JSValidatorChild.h"
11 #include "mozilla/dom/PJSValidatorChild.h"
12 #include "mozilla/ipc/Endpoint.h"
14 using namespace mozilla::dom;
16 static mozilla::StaticRefPtr<JSOracleChild> sOracleSingletonChild;
18 static mozilla::StaticAutoPtr<JSFrontendContextHolder> sJSFrontendContextHolder;
20 /* static */
21 void JSFrontendContextHolder::MaybeInit() {
22 if (!sJSFrontendContextHolder) {
23 sJSFrontendContextHolder = new JSFrontendContextHolder();
24 ClearOnShutdown(&sJSFrontendContextHolder);
28 /* static */
29 JS::FrontendContext* JSOracleChild::JSFrontendContext() {
30 MOZ_ASSERT(sJSFrontendContextHolder);
31 return sJSFrontendContextHolder->mFc;
34 JSOracleChild* JSOracleChild::GetSingleton() {
35 MOZ_ASSERT(NS_IsMainThread());
36 if (!sOracleSingletonChild) {
37 sOracleSingletonChild = new JSOracleChild();
38 ClearOnShutdown(&sOracleSingletonChild);
40 return sOracleSingletonChild;
43 already_AddRefed<PJSValidatorChild> JSOracleChild::AllocPJSValidatorChild() {
44 return MakeAndAddRef<JSValidatorChild>();
47 void JSOracleChild::Start(Endpoint<PJSOracleChild>&& aEndpoint) {
48 DebugOnly<bool> ok = std::move(aEndpoint).Bind(this);
49 JSFrontendContextHolder::MaybeInit();
50 MOZ_ASSERT(ok);