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