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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/WebAuthnManagerBase.h"
8 #include "mozilla/dom/WebAuthnTransactionChild.h"
9 #include "mozilla/ipc/BackgroundChild.h"
10 #include "mozilla/ipc/PBackgroundChild.h"
12 namespace mozilla::dom
{
14 WebAuthnManagerBase::WebAuthnManagerBase(nsPIDOMWindowInner
* aParent
)
16 MOZ_ASSERT(NS_IsMainThread());
20 WebAuthnManagerBase::~WebAuthnManagerBase() { MOZ_ASSERT(NS_IsMainThread()); }
22 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebAuthnManagerBase
)
23 NS_INTERFACE_MAP_ENTRY(nsISupports
)
26 NS_IMPL_CYCLE_COLLECTION(WebAuthnManagerBase
, mParent
)
28 NS_IMPL_CYCLE_COLLECTING_ADDREF(WebAuthnManagerBase
)
29 NS_IMPL_CYCLE_COLLECTING_RELEASE(WebAuthnManagerBase
)
31 /***********************************************************************
32 * IPC Protocol Implementation
33 **********************************************************************/
35 bool WebAuthnManagerBase::MaybeCreateBackgroundActor() {
36 MOZ_ASSERT(NS_IsMainThread());
42 ::mozilla::ipc::PBackgroundChild
* actorChild
=
43 ::mozilla::ipc::BackgroundChild::GetOrCreateForCurrentThread();
44 if (NS_WARN_IF(!actorChild
)) {
48 RefPtr
<WebAuthnTransactionChild
> mgr(new WebAuthnTransactionChild(this));
49 PWebAuthnTransactionChild
* constructedMgr
=
50 actorChild
->SendPWebAuthnTransactionConstructor(mgr
);
52 if (NS_WARN_IF(!constructedMgr
)) {
56 MOZ_ASSERT(constructedMgr
== mgr
);
57 mChild
= std::move(mgr
);
62 void WebAuthnManagerBase::ActorDestroyed() {
63 MOZ_ASSERT(NS_IsMainThread());
67 } // namespace mozilla::dom