Bug 1787269 [wpt PR 35624] - Further refine STP download regexs, a=testonly
[gecko.git] / dom / encoding / TextDecoderStream.h
blob13a6e5791ea28c9f7b115894a67026628781773f
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/. */
7 #ifndef DOM_ENCODING_TEXTDECODERSTREAM_H_
8 #define DOM_ENCODING_TEXTDECODERSTREAM_H_
10 #include "js/TypeDecls.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/ErrorResult.h"
13 #include "mozilla/dom/BindingDeclarations.h"
14 #include "mozilla/dom/TextDecoder.h"
15 #include "nsCycleCollectionParticipant.h"
16 #include "nsWrapperCache.h"
18 class nsIGlobalObject;
20 namespace mozilla {
22 class Decoder;
23 class Encoding;
25 namespace dom {
27 class ReadableStream;
28 class WritableStream;
29 struct TextDecoderOptions;
30 class TransformStream;
32 } // namespace dom
34 } // namespace mozilla
36 namespace mozilla::dom {
38 class TextDecoderStream final : public nsISupports,
39 public nsWrapperCache,
40 public TextDecoderCommon {
41 public:
42 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
43 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextDecoderStream)
45 public:
46 TextDecoderStream(nsISupports* aGlobal, const Encoding& aEncoding,
47 bool aFatal, bool aIgnoreBOM, TransformStream& aStream);
49 nsISupports* GetParentObject() const { return mGlobal; }
51 JSObject* WrapObject(JSContext* aCx,
52 JS::Handle<JSObject*> aGivenProto) override;
54 mozilla::Decoder* Decoder() { return mDecoder.get(); }
56 // TODO: Mark as MOZ_CAN_RUN_SCRIPT when IDL constructors can be (bug 1749042)
57 MOZ_CAN_RUN_SCRIPT_BOUNDARY static already_AddRefed<TextDecoderStream>
58 Constructor(const GlobalObject& aGlobal, const nsAString& aLabel,
59 const TextDecoderOptions& aOptions, ErrorResult& aRv);
61 ReadableStream* Readable() const;
63 WritableStream* Writable() const;
65 private:
66 ~TextDecoderStream();
68 nsCOMPtr<nsISupports> mGlobal;
69 RefPtr<TransformStream> mStream;
72 } // namespace mozilla::dom
74 #endif // DOM_ENCODING_TEXTDECODERSTREAM_H_