Bug 1726269: part 1) Repeatedly call `::OleSetClipboard` for the Windows-specific...
[gecko.git] / dom / prio / PrioEncoder.h
blob38cb9fcd7309246d318854498aa9e41b2417f5af
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_PrioEncoder_h
8 #define mozilla_dom_PrioEncoder_h
10 #include "mozilla/dom/PrioEncoderBinding.h"
11 #include "mozilla/dom/RootedDictionary.h"
13 class nsIGlobalObject;
14 using SECKEYPublicKey = struct SECKEYPublicKeyStr;
15 using PublicKey = SECKEYPublicKey*;
17 namespace mozilla {
18 namespace dom {
20 class PrioEncoder {
21 public:
22 NS_INLINE_DECL_REFCOUNTING(PrioEncoder)
24 // C++ API
25 static nsresult EncodeNative(const nsCString& aBatchID,
26 const nsTArray<bool>& aData, nsCString& aResult,
27 nsCString& bResult);
29 // DOM API
30 static void Encode(GlobalObject& aGlobal, const nsCString& aBatchID,
31 const PrioParams& aPrioParams,
32 RootedDictionary<PrioEncodedData>& aData,
33 ErrorResult& aRv);
35 // maximum number of booleans that can be prio-encoded in a single batch.
36 const static uint32_t gNumBooleans = 2046;
38 // Set (or, by passing nullptrs, reset) the keys used to encode the payloads.
39 static nsresult SetKeys(const char* aKeyA = nullptr,
40 const char* aKeyB = nullptr);
42 private:
43 PrioEncoder();
44 ~PrioEncoder();
46 static PublicKey sPublicKeyA;
48 static PublicKey sPublicKeyB;
50 static StaticRefPtr<PrioEncoder> sSingleton;
52 static bool IsValidHexPublicKey(mozilla::Span<const char>);
54 static nsresult LazyInitSingleton();
57 } // namespace dom
58 } // namespace mozilla
60 #endif // mozilla_dom_PrioEncoder_h