tor-browser

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

TextEncoderStream.h (1900B)


      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_ENCODING_TEXTENCODERSTREAM_H_
      8 #define DOM_ENCODING_TEXTENCODERSTREAM_H_
      9 
     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"
     16 
     17 class nsIGlobalObject;
     18 
     19 namespace mozilla {
     20 
     21 class Decoder;
     22 
     23 namespace dom {
     24 
     25 class ReadableStream;
     26 class WritableStream;
     27 class TransformStream;
     28 
     29 }  // namespace dom
     30 
     31 }  // namespace mozilla
     32 
     33 namespace mozilla::dom {
     34 
     35 class TextEncoderStream final : public nsISupports, public nsWrapperCache {
     36 public:
     37  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     38  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(TextEncoderStream)
     39 
     40 public:
     41  TextEncoderStream(nsISupports* aGlobal, TransformStream& aStream);
     42 
     43  nsISupports* GetParentObject() const { return mGlobal; }
     44 
     45  JSObject* WrapObject(JSContext* aCx,
     46                       JS::Handle<JSObject*> aGivenProto) override;
     47 
     48  mozilla::Decoder* Decoder() { return mDecoder.get(); }
     49 
     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);
     53 
     54  ReadableStream* Readable() const;
     55 
     56  WritableStream* Writable() const;
     57 
     58  void GetEncoding(nsCString& aRetVal) const;
     59 
     60 private:
     61  ~TextEncoderStream();
     62 
     63  nsCOMPtr<nsISupports> mGlobal;
     64  RefPtr<TransformStream> mStream;
     65  mozilla::UniquePtr<mozilla::Decoder> mDecoder;
     66 };
     67 
     68 }  // namespace mozilla::dom
     69 
     70 #endif  // DOM_ENCODING_TEXTENCODERSTREAM_H_