Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=mgaudet
[gecko.git] / dom / webauthn / WebAuthnTransactionChild.cpp
blob15022ff9816909ce746b041a40bc66456b98e4c7
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/WebAuthnTransactionChild.h"
9 namespace mozilla::dom {
11 WebAuthnTransactionChild::WebAuthnTransactionChild(
12 WebAuthnManagerBase* aManager)
13 : mManager(aManager) {
14 MOZ_ASSERT(aManager);
16 // Retain a reference so the task object isn't deleted without IPDL's
17 // knowledge. The reference will be released by
18 // mozilla::ipc::BackgroundChildImpl::DeallocPWebAuthnTransactionChild.
19 NS_ADDREF_THIS();
22 mozilla::ipc::IPCResult WebAuthnTransactionChild::RecvConfirmRegister(
23 const uint64_t& aTransactionId,
24 const WebAuthnMakeCredentialResult& aResult) {
25 if (NS_WARN_IF(!mManager)) {
26 return IPC_FAIL_NO_REASON(this);
29 // We don't own the reference to mManager. We need to prevent its refcount
30 // going to 0 while we call anything that can reach the call to
31 // StopListeningForVisibilityEvents in WebAuthnManager::ClearTransaction
32 // (often via WebAuthnManager::RejectTransaction).
33 RefPtr<WebAuthnManagerBase> kungFuDeathGrip(mManager);
34 kungFuDeathGrip->FinishMakeCredential(aTransactionId, aResult);
35 return IPC_OK();
38 mozilla::ipc::IPCResult WebAuthnTransactionChild::RecvConfirmSign(
39 const uint64_t& aTransactionId, const WebAuthnGetAssertionResult& aResult) {
40 if (NS_WARN_IF(!mManager)) {
41 return IPC_FAIL_NO_REASON(this);
44 // We don't own the reference to mManager. We need to prevent its refcount
45 // going to 0 while we call anything that can reach the call to
46 // StopListeningForVisibilityEvents in WebAuthnManager::ClearTransaction
47 // (often via WebAuthnManager::RejectTransaction).
48 RefPtr<WebAuthnManagerBase> kungFuDeathGrip(mManager);
49 kungFuDeathGrip->FinishGetAssertion(aTransactionId, aResult);
50 return IPC_OK();
53 mozilla::ipc::IPCResult WebAuthnTransactionChild::RecvAbort(
54 const uint64_t& aTransactionId, const nsresult& aError) {
55 if (NS_WARN_IF(!mManager)) {
56 return IPC_FAIL_NO_REASON(this);
59 // We don't own the reference to mManager. We need to prevent its refcount
60 // going to 0 while we call anything that can reach the call to
61 // StopListeningForVisibilityEvents in WebAuthnManager::ClearTransaction
62 // (often via WebAuthnManager::RejectTransaction).
63 RefPtr<WebAuthnManagerBase> kungFuDeathGrip(mManager);
64 kungFuDeathGrip->RequestAborted(aTransactionId, aError);
65 return IPC_OK();
68 void WebAuthnTransactionChild::ActorDestroy(ActorDestroyReason why) {
69 // Called by either a __delete__ message from the parent, or when the
70 // channel disconnects. Clear out the child actor reference to be sure.
71 if (mManager) {
72 mManager->ActorDestroyed();
73 mManager = nullptr;
77 void WebAuthnTransactionChild::Disconnect() {
78 mManager = nullptr;
80 // The WebAuthnManager released us, but we're going to be held alive by the
81 // IPC layer. The parent will explicitly destroy us via Send__delete__(),
82 // after receiving the DestroyMe message.
84 SendDestroyMe();
87 } // namespace mozilla::dom