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_STREAMS_TRANSFORMSTREAMDEFAULTCONTROLLER_H_
8 #define DOM_STREAMS_TRANSFORMSTREAMDEFAULTCONTROLLER_H_
10 #include "js/TypeDecls.h"
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "mozilla/dom/BindingDeclarations.h"
13 #include "mozilla/dom/QueuingStrategyBinding.h"
15 #include "mozilla/dom/TransformerBinding.h"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsWrapperCache.h"
19 namespace mozilla::dom
{
21 class TransformStream
;
22 class TransformerAlgorithmsBase
;
24 class TransformStreamDefaultController final
: public nsISupports
,
25 public nsWrapperCache
{
27 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
28 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(TransformStreamDefaultController
)
30 MOZ_KNOWN_LIVE TransformStream
* Stream();
31 void SetStream(TransformStream
& aStream
);
32 TransformerAlgorithmsBase
* Algorithms();
33 void SetAlgorithms(TransformerAlgorithmsBase
* aTransformerAlgorithms
);
35 explicit TransformStreamDefaultController(nsIGlobalObject
* aGlobal
);
38 ~TransformStreamDefaultController();
41 nsIGlobalObject
* GetParentObject() const { return mGlobal
; }
42 JSObject
* WrapObject(JSContext
* aCx
,
43 JS::Handle
<JSObject
*> aGivenProto
) override
;
45 Nullable
<double> GetDesiredSize() const;
47 MOZ_CAN_RUN_SCRIPT
void Enqueue(JSContext
* aCx
, JS::Handle
<JS::Value
> aChunk
,
49 MOZ_CAN_RUN_SCRIPT
void Error(JSContext
* aCx
, JS::Handle
<JS::Value
> aError
,
51 MOZ_CAN_RUN_SCRIPT
void Terminate(JSContext
* aCx
, ErrorResult
& aRv
);
54 nsCOMPtr
<nsIGlobalObject
> mGlobal
;
57 RefPtr
<TransformStream
> mStream
;
58 RefPtr
<TransformerAlgorithmsBase
> mTransformerAlgorithms
;
61 namespace streams_abstract
{
62 void SetUpTransformStreamDefaultController(
63 JSContext
* aCx
, TransformStream
& aStream
,
64 TransformStreamDefaultController
& aController
,
65 TransformerAlgorithmsBase
& aTransformerAlgorithms
);
67 void SetUpTransformStreamDefaultControllerFromTransformer(
68 JSContext
* aCx
, TransformStream
& aStream
,
69 JS::Handle
<JSObject
*> aTransformer
, Transformer
& aTransformerDict
);
70 } // namespace streams_abstract
72 } // namespace mozilla::dom
74 #endif // DOM_STREAMS_TRANSFORMSTREAMDEFAULTCONTROLLER_H_