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_TEXTENCODERSTREAM_H_
8 #define DOM_ENCODING_TEXTENCODERSTREAM_H_
10 #include "js/TypeDecls.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/ErrorResult.h"
13 #include "mozilla/dom/BindingDeclarations.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsWrapperCache.h"
17 class nsIGlobalObject
;
27 class TransformStream
;
31 } // namespace mozilla
33 namespace mozilla::dom
{
35 class TextEncoderStream final
: public nsISupports
, public nsWrapperCache
{
37 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
38 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(TextEncoderStream
)
41 TextEncoderStream(nsISupports
* aGlobal
, TransformStream
& aStream
);
43 nsISupports
* GetParentObject() const { return mGlobal
; }
45 JSObject
* WrapObject(JSContext
* aCx
,
46 JS::Handle
<JSObject
*> aGivenProto
) override
;
48 mozilla::Decoder
* Decoder() { return mDecoder
.get(); }
50 // TODO: Mark as MOZ_CAN_RUN_SCRIPT when IDL constructors can be (bug 1749042)
51 MOZ_CAN_RUN_SCRIPT_BOUNDARY
static already_AddRefed
<TextEncoderStream
>
52 Constructor(const GlobalObject
& aGlobal
, ErrorResult
& aRv
);
54 ReadableStream
* Readable() const;
56 WritableStream
* Writable() const;
58 void GetEncoding(nsCString
& aRetVal
) const;
63 nsCOMPtr
<nsISupports
> mGlobal
;
64 RefPtr
<TransformStream
> mStream
;
65 mozilla::UniquePtr
<mozilla::Decoder
> mDecoder
;
68 } // namespace mozilla::dom
70 #endif // DOM_ENCODING_TEXTENCODERSTREAM_H_