tor-browser

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

WebTransportStreams.h (1721B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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_WEBTRANSPORT_API_WEBTRANSPORTSTREAMS__H_
      8 #define DOM_WEBTRANSPORT_API_WEBTRANSPORTSTREAMS__H_
      9 
     10 #include "mozilla/dom/UnderlyingSourceCallbackHelpers.h"
     11 #include "mozilla/dom/WritableStream.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 class WebTransport;
     16 
     17 class WebTransportIncomingStreamsAlgorithms
     18    : public UnderlyingSourceAlgorithmsWrapper {
     19 public:
     20  enum class StreamType : uint8_t { Unidirectional, Bidirectional };
     21  WebTransportIncomingStreamsAlgorithms(StreamType aUnidirectional,
     22                                        WebTransport* aTransport);
     23 
     24  NS_DECL_ISUPPORTS_INHERITED
     25  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(
     26      WebTransportIncomingStreamsAlgorithms, UnderlyingSourceAlgorithmsWrapper)
     27 
     28  already_AddRefed<Promise> PullCallbackImpl(
     29      JSContext* aCx, ReadableStreamControllerBase& aController,
     30      ErrorResult& aRv) override;
     31 
     32  // We call EnqueueNative, which is MOZ_CAN_RUN_SCRIPT but won't in this case
     33  MOZ_CAN_RUN_SCRIPT_BOUNDARY void BuildStream(JSContext* aCx,
     34                                               ErrorResult& aRv);
     35 
     36  void NotifyIncomingStream();
     37 
     38  void NotifyRejectAll();
     39 
     40 protected:
     41  ~WebTransportIncomingStreamsAlgorithms() override;
     42 
     43 private:
     44  const StreamType mUnidirectional;
     45  RefPtr<WebTransport> mTransport;
     46  RefPtr<Promise> mCallback;
     47 };
     48 
     49 }  // namespace mozilla::dom
     50 
     51 #endif  // DOM_WEBTRANSPORT_API_WEBTRANSPORTSTREAMS__H_