tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TransformStreamDefaultController.h (2604B)


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