Source code

Revision control

Other Tools

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/WebAuthenticationBinding.h"
8
#include "mozilla/dom/AuthenticatorAttestationResponse.h"
9
10
namespace mozilla {
11
namespace dom {
12
13
NS_IMPL_CYCLE_COLLECTION_CLASS(AuthenticatorAttestationResponse)
14
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
15
AuthenticatorAttestationResponse, AuthenticatorResponse)
16
tmp->mAttestationObjectCachedObj = nullptr;
17
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
18
19
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(AuthenticatorAttestationResponse,
20
AuthenticatorResponse)
21
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
22
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAttestationObjectCachedObj)
23
NS_IMPL_CYCLE_COLLECTION_TRACE_END
24
25
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
26
AuthenticatorAttestationResponse, AuthenticatorResponse)
27
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
28
29
NS_IMPL_ADDREF_INHERITED(AuthenticatorAttestationResponse,
30
AuthenticatorResponse)
31
NS_IMPL_RELEASE_INHERITED(AuthenticatorAttestationResponse,
32
AuthenticatorResponse)
33
34
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AuthenticatorAttestationResponse)
35
NS_INTERFACE_MAP_END_INHERITING(AuthenticatorResponse)
36
37
AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(
38
nsPIDOMWindowInner* aParent)
39
: AuthenticatorResponse(aParent), mAttestationObjectCachedObj(nullptr) {
40
mozilla::HoldJSObjects(this);
41
}
42
43
AuthenticatorAttestationResponse::~AuthenticatorAttestationResponse() {
44
mozilla::DropJSObjects(this);
45
}
46
47
JSObject* AuthenticatorAttestationResponse::WrapObject(
48
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
49
return AuthenticatorAttestationResponse_Binding::Wrap(aCx, this, aGivenProto);
50
}
51
52
void AuthenticatorAttestationResponse::GetAttestationObject(
53
JSContext* aCx, JS::MutableHandle<JSObject*> aRetVal) {
54
if (!mAttestationObjectCachedObj) {
55
mAttestationObjectCachedObj = mAttestationObject.ToArrayBuffer(aCx);
56
}
57
aRetVal.set(mAttestationObjectCachedObj);
58
}
59
60
nsresult AuthenticatorAttestationResponse::SetAttestationObject(
61
CryptoBuffer& aBuffer) {
62
if (NS_WARN_IF(!mAttestationObject.Assign(aBuffer))) {
63
return NS_ERROR_OUT_OF_MEMORY;
64
}
65
return NS_OK;
66
}
67
68
} // namespace dom
69
} // namespace mozilla