Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/webauthn/WebAuthnTransactionParent.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/WebAuthnTransactionParent.h"
8
#include "mozilla/dom/U2FTokenManager.h"
9
#include "mozilla/ipc/PBackgroundParent.h"
10
#include "mozilla/ipc/BackgroundParent.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
mozilla::ipc::IPCResult
16
WebAuthnTransactionParent::RecvRequestRegister(const uint64_t& aTransactionId,
17
                                               const WebAuthnMakeCredentialInfo& aTransactionInfo)
18
0
{
19
0
  AssertIsOnBackgroundThread();
20
0
  U2FTokenManager* mgr = U2FTokenManager::Get();
21
0
  mgr->Register(this, aTransactionId, aTransactionInfo);
22
0
  return IPC_OK();
23
0
}
24
25
mozilla::ipc::IPCResult
26
WebAuthnTransactionParent::RecvRequestSign(const uint64_t& aTransactionId,
27
                                           const WebAuthnGetAssertionInfo& aTransactionInfo)
28
0
{
29
0
  AssertIsOnBackgroundThread();
30
0
  U2FTokenManager* mgr = U2FTokenManager::Get();
31
0
  mgr->Sign(this, aTransactionId, aTransactionInfo);
32
0
  return IPC_OK();
33
0
}
34
35
mozilla::ipc::IPCResult
36
WebAuthnTransactionParent::RecvRequestCancel(const uint64_t& aTransactionId)
37
0
{
38
0
  AssertIsOnBackgroundThread();
39
0
  U2FTokenManager* mgr = U2FTokenManager::Get();
40
0
  mgr->Cancel(this, aTransactionId);
41
0
  return IPC_OK();
42
0
}
43
44
mozilla::ipc::IPCResult
45
WebAuthnTransactionParent::RecvDestroyMe()
46
0
{
47
0
  AssertIsOnBackgroundThread();
48
0
49
0
  // The child was disconnected from the WebAuthnManager instance and will send
50
0
  // no further messages. It is kept alive until we delete it explicitly.
51
0
52
0
  // The child should have cancelled any active transaction. This means
53
0
  // we expect no more messages to the child. We'll crash otherwise.
54
0
55
0
  // The IPC roundtrip is complete. No more messages, hopefully.
56
0
  IProtocol* mgr = Manager();
57
0
  if (!Send__delete__(this)) {
58
0
    return IPC_FAIL_NO_REASON(mgr);
59
0
  }
60
0
61
0
  return IPC_OK();
62
0
}
63
64
void
65
WebAuthnTransactionParent::ActorDestroy(ActorDestroyReason aWhy)
66
0
{
67
0
  AssertIsOnBackgroundThread();
68
0
69
0
  // Called either by Send__delete__() in RecvDestroyMe() above, or when
70
0
  // the channel disconnects. Ensure the token manager forgets about us.
71
0
  U2FTokenManager* mgr = U2FTokenManager::Get();
72
0
73
0
  // The manager could probably be null on shutdown?
74
0
  if (mgr) {
75
0
    mgr->MaybeClearTransaction(this);
76
0
  }
77
0
}
78
79
}
80
}