FormatZstd.h (1732B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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 #ifndef DOM_COMPRESSION_FORMATZSTD_H_ 8 #define DOM_COMPRESSION_FORMATZSTD_H_ 9 10 #include "BaseAlgorithms.h" 11 12 struct ZSTD_DCtx_s; 13 14 // See the zstd manual in https://facebook.github.io/zstd/zstd_manual.html or in 15 // https://searchfox.org/mozilla-central/source/third_party/zstd/lib/zstd.h 16 17 namespace mozilla::dom::compression { 18 19 class ZstdDecompressionStreamAlgorithms : public DecompressionStreamAlgorithms { 20 public: 21 NS_DECL_ISUPPORTS_INHERITED 22 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ZstdDecompressionStreamAlgorithms, 23 DecompressionStreamAlgorithms) 24 25 static Result<already_AddRefed<ZstdDecompressionStreamAlgorithms>, nsresult> 26 Create(); 27 28 private: 29 ZstdDecompressionStreamAlgorithms() = default; 30 31 [[nodiscard]] nsresult Init(); 32 33 // Shared by: 34 // https://wicg.github.io/compression/#decompress-and-enqueue-a-chunk 35 // https://wicg.github.io/compression/#decompress-flush-and-enqueue 36 // All data errors throw TypeError by step 2: If this results in an error, 37 // then throw a TypeError. 38 bool Decompress(JSContext* aCx, Span<const uint8_t> aInput, 39 JS::MutableHandleVector<JSObject*> aOutput, Flush aFlush, 40 ErrorResult& aRv) override; 41 42 ~ZstdDecompressionStreamAlgorithms() override; 43 44 ZSTD_DCtx_s* mDStream = nullptr; 45 }; 46 } // namespace mozilla::dom::compression 47 48 #endif // DOM_COMPRESSION_FORMATZSTD_H_