Bug 1828523 [wpt PR 39579] - Only restore dialog focus if focus is in the dialog...
[gecko.git] / dom / crypto / CryptoBuffer.h
blob7d1775f4993cd2c55a5ebfc68ab37aadc7536778
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 #ifndef mozilla_dom_CryptoBuffer_h
8 #define mozilla_dom_CryptoBuffer_h
10 #include "nsTArray.h"
11 #include "seccomon.h"
12 #include "mozilla/dom/TypedArray.h"
14 namespace mozilla::dom {
16 class ArrayBufferViewOrArrayBuffer;
17 class OwningArrayBufferViewOrArrayBuffer;
19 class CryptoBuffer : public FallibleTArray<uint8_t> {
20 public:
21 uint8_t* Assign(const CryptoBuffer& aData);
22 uint8_t* Assign(const uint8_t* aData, uint32_t aLength);
23 uint8_t* Assign(const nsACString& aString);
24 uint8_t* Assign(const SECItem* aItem);
25 uint8_t* Assign(const nsTArray<uint8_t>& aData);
26 uint8_t* Assign(const ArrayBuffer& aData);
27 uint8_t* Assign(const ArrayBufferView& aData);
28 uint8_t* Assign(const ArrayBufferViewOrArrayBuffer& aData);
29 uint8_t* Assign(const OwningArrayBufferViewOrArrayBuffer& aData);
30 uint8_t* Assign(const Uint8Array& aArray);
32 uint8_t* AppendSECItem(const SECItem* aItem);
33 uint8_t* AppendSECItem(const SECItem& aItem);
35 nsresult FromJwkBase64(const nsString& aBase64);
36 nsresult ToJwkBase64(nsString& aBase64) const;
37 bool ToSECItem(PLArenaPool* aArena, SECItem* aItem) const;
38 JSObject* ToUint8Array(JSContext* aCx) const;
39 JSObject* ToArrayBuffer(JSContext* aCx) const;
40 bool ToNewUnsignedBuffer(uint8_t** aBuf, uint32_t* aBufLen) const;
42 bool GetBigIntValue(unsigned long& aRetVal);
44 CryptoBuffer InfallibleClone() const {
45 CryptoBuffer result;
46 if (!result.Assign(*this)) {
47 MOZ_CRASH("Out of memory");
49 return result;
53 } // namespace mozilla::dom
55 #endif // mozilla_dom_CryptoBuffer_h