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/AuthenticatorResponse.h"
8
9
namespace mozilla {
10
namespace dom {
11
12
NS_IMPL_CYCLE_COLLECTION_CLASS(AuthenticatorResponse)
13
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AuthenticatorResponse)
14
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
15
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
16
tmp->mClientDataJSONCachedObj = nullptr;
17
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
18
19
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(AuthenticatorResponse)
20
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
21
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mClientDataJSONCachedObj)
22
NS_IMPL_CYCLE_COLLECTION_TRACE_END
23
24
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AuthenticatorResponse)
25
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
26
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
27
28
NS_IMPL_CYCLE_COLLECTING_ADDREF(AuthenticatorResponse)
29
NS_IMPL_CYCLE_COLLECTING_RELEASE(AuthenticatorResponse)
30
31
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AuthenticatorResponse)
32
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
33
NS_INTERFACE_MAP_ENTRY(nsISupports)
34
NS_INTERFACE_MAP_END
35
36
AuthenticatorResponse::AuthenticatorResponse(nsPIDOMWindowInner* aParent)
37
: mParent(aParent), mClientDataJSONCachedObj(nullptr) {
38
mozilla::HoldJSObjects(this);
39
}
40
41
AuthenticatorResponse::~AuthenticatorResponse() {
42
mozilla::DropJSObjects(this);
43
}
44
45
void AuthenticatorResponse::GetClientDataJSON(
46
JSContext* aCx, JS::MutableHandle<JSObject*> aRetVal) {
47
if (!mClientDataJSONCachedObj) {
48
mClientDataJSONCachedObj = mClientDataJSON.ToArrayBuffer(aCx);
49
}
50
aRetVal.set(mClientDataJSONCachedObj);
51
}
52
53
nsresult AuthenticatorResponse::SetClientDataJSON(CryptoBuffer& aBuffer) {
54
if (NS_WARN_IF(!mClientDataJSON.Assign(aBuffer))) {
55
return NS_ERROR_OUT_OF_MEMORY;
56
}
57
return NS_OK;
58
}
59
60
} // namespace dom
61
} // namespace mozilla