Bug 1856663 - Add more chunks for Android mochitest-plain. r=jmaher,taskgraph-reviewe...
[gecko.git] / dom / webauthn / AuthenticatorResponse.cpp
blobba291ae4cdf44a0d7e7b3f0a3d645f661848975f
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/. */
7 #include "mozilla/Base64.h"
8 #include "mozilla/dom/AuthenticatorResponse.h"
9 #include "mozilla/dom/TypedArray.h"
10 #include "nsPIDOMWindow.h"
11 #include "nsWrapperCache.h"
13 namespace mozilla::dom {
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(
16 AuthenticatorResponse, (mParent), (mClientDataJSONCachedObj))
18 NS_IMPL_CYCLE_COLLECTING_ADDREF(AuthenticatorResponse)
19 NS_IMPL_CYCLE_COLLECTING_RELEASE(AuthenticatorResponse)
21 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AuthenticatorResponse)
22 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
23 NS_INTERFACE_MAP_ENTRY(nsISupports)
24 NS_INTERFACE_MAP_END
26 AuthenticatorResponse::AuthenticatorResponse(nsPIDOMWindowInner* aParent)
27 : mParent(aParent), mClientDataJSONCachedObj(nullptr) {
28 // Call HoldJSObjects() in subclasses.
31 AuthenticatorResponse::~AuthenticatorResponse() {
32 // Call DropJSObjects() in subclasses.
35 nsISupports* AuthenticatorResponse::GetParentObject() const { return mParent; }
37 void AuthenticatorResponse::GetClientDataJSON(
38 JSContext* aCx, JS::MutableHandle<JSObject*> aValue, ErrorResult& aRv) {
39 if (!mClientDataJSONCachedObj) {
40 mClientDataJSONCachedObj = ArrayBuffer::Create(aCx, mClientDataJSON);
41 if (!mClientDataJSONCachedObj) {
42 aRv.NoteJSContextException(aCx);
43 return;
46 aValue.set(mClientDataJSONCachedObj);
49 void AuthenticatorResponse::SetClientDataJSON(const nsCString& aBuffer) {
50 mClientDataJSON.Assign(aBuffer);
53 } // namespace mozilla::dom