Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/webauthn/WebAuthnTransactionChild.cpp
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#include "mozilla/dom/WebAuthnTransactionChild.h"
8
9
namespace mozilla {
10
namespace dom {
11
12
WebAuthnTransactionChild::WebAuthnTransactionChild(WebAuthnManagerBase* aManager)
13
  : mManager(aManager)
14
0
{
15
0
  MOZ_ASSERT(aManager);
16
0
17
0
  // Retain a reference so the task object isn't deleted without IPDL's
18
0
  // knowledge. The reference will be released by
19
0
  // mozilla::ipc::BackgroundChildImpl::DeallocPWebAuthnTransactionChild.
20
0
  NS_ADDREF_THIS();
21
0
}
22
23
mozilla::ipc::IPCResult
24
WebAuthnTransactionChild::RecvConfirmRegister(const uint64_t& aTransactionId,
25
                                              const WebAuthnMakeCredentialResult& aResult)
26
0
{
27
0
  if (NS_WARN_IF(!mManager)) {
28
0
    return IPC_FAIL_NO_REASON(this);
29
0
  }
30
0
31
0
  mManager->FinishMakeCredential(aTransactionId, aResult);
32
0
  return IPC_OK();
33
0
}
34
35
mozilla::ipc::IPCResult
36
WebAuthnTransactionChild::RecvConfirmSign(const uint64_t& aTransactionId,
37
                                          const WebAuthnGetAssertionResult& aResult)
38
0
{
39
0
  if (NS_WARN_IF(!mManager)) {
40
0
    return IPC_FAIL_NO_REASON(this);
41
0
  }
42
0
43
0
  mManager->FinishGetAssertion(aTransactionId, aResult);
44
0
  return IPC_OK();
45
0
}
46
47
mozilla::ipc::IPCResult
48
WebAuthnTransactionChild::RecvAbort(const uint64_t& aTransactionId,
49
                                    const nsresult& aError)
50
0
{
51
0
  if (NS_WARN_IF(!mManager)) {
52
0
    return IPC_FAIL_NO_REASON(this);
53
0
  }
54
0
55
0
  mManager->RequestAborted(aTransactionId, aError);
56
0
  return IPC_OK();
57
0
}
58
59
void
60
WebAuthnTransactionChild::ActorDestroy(ActorDestroyReason why)
61
0
{
62
0
  // Called by either a __delete__ message from the parent, or when the
63
0
  // channel disconnects. Clear out the child actor reference to be sure.
64
0
  if (mManager) {
65
0
    mManager->ActorDestroyed();
66
0
    mManager = nullptr;
67
0
  }
68
0
}
69
70
void
71
WebAuthnTransactionChild::Disconnect()
72
0
{
73
0
  mManager = nullptr;
74
0
75
0
  // The WebAuthnManager released us, but we're going to be held alive by the
76
0
  // IPC layer. The parent will explicitly destroy us via Send__delete__(),
77
0
  // after receiving the DestroyMe message.
78
0
79
0
  SendDestroyMe();
80
0
}
81
82
}
83
}