Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / webauthn / CtapArgs.h
blob406c24f4ba81b2c31969e96b0bf869b09f344600
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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 #ifndef CtapArgs_h
8 #define CtapArgs_h
10 #include "mozilla/dom/WebAuthnTransactionChild.h"
11 #include "mozilla/ipc/BackgroundParent.h"
12 #include "nsIWebAuthnController.h"
14 namespace mozilla::dom {
16 // These classes provide an FFI between C++ and Rust for the getters of IPC
17 // objects (WebAuthnMakeCredentialInfo and WebAuthnGetAssertionInfo). They hold
18 // non-owning references to IPC objects, and must only be used within the
19 // lifetime of the IPC transaction that created them. There are runtime
20 // assertions to ensure that these types are created and used on the IPC
21 // background thread, but that alone does not guarantee safety.
23 class CtapRegisterArgs final : public nsICtapRegisterArgs {
24 public:
25 NS_DECL_ISUPPORTS
26 NS_DECL_NSICTAPREGISTERARGS
28 explicit CtapRegisterArgs(const WebAuthnMakeCredentialInfo& aInfo,
29 bool aForceNoneAttestation)
30 : mInfo(aInfo), mForceNoneAttestation(aForceNoneAttestation) {
31 mozilla::ipc::AssertIsOnBackgroundThread();
34 private:
35 ~CtapRegisterArgs() = default;
37 const WebAuthnMakeCredentialInfo& mInfo;
38 const bool mForceNoneAttestation;
41 class CtapSignArgs final : public nsICtapSignArgs {
42 public:
43 NS_DECL_ISUPPORTS
44 NS_DECL_NSICTAPSIGNARGS
46 explicit CtapSignArgs(const WebAuthnGetAssertionInfo& aInfo) : mInfo(aInfo) {
47 mozilla::ipc::AssertIsOnBackgroundThread();
50 private:
51 ~CtapSignArgs() = default;
53 const WebAuthnGetAssertionInfo& mInfo;
56 } // namespace mozilla::dom
58 #endif // CtapArgs_h