tor-browser

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

WebTransportSendStream.h (1900B)


      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_WEBTRANSPORTSENDSTREAM__H_
      8 #define DOM_WEBTRANSPORT_API_WEBTRANSPORTSENDSTREAM__H_
      9 
     10 #include "mozilla/dom/WritableStream.h"
     11 
     12 namespace mozilla::ipc {
     13 class DataPipeSender;
     14 }
     15 
     16 namespace mozilla::dom {
     17 
     18 class WebTransport;
     19 
     20 class WebTransportSendStream final : public WritableStream {
     21 public:
     22  NS_DECL_ISUPPORTS_INHERITED
     23  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(WebTransportSendStream,
     24                                           WritableStream)
     25 
     26  WebTransportSendStream(nsIGlobalObject* aGlobal, WebTransport* aTransport);
     27 
     28  static already_AddRefed<WebTransportSendStream> Create(
     29      WebTransport* aWebTransport, nsIGlobalObject* aGlobal, uint64_t aStreamId,
     30      mozilla::ipc::DataPipeSender* aSender, Maybe<int64_t> aSendOrder,
     31      ErrorResult& aRv);
     32 
     33  // WebIDL Boilerplate
     34  JSObject* WrapObject(JSContext* aCx,
     35                       JS::Handle<JSObject*> aGivenProto) override;
     36 
     37  // WebIDL Interface
     38  Nullable<int64_t> GetSendOrder() { return mSendOrder; }
     39 
     40  void SetSendOrder(Nullable<int64_t> aSendOrder);
     41 
     42  already_AddRefed<Promise> GetStats();
     43 
     44 private:
     45  ~WebTransportSendStream() override { mozilla::DropJSObjects(this); };
     46 
     47  // We must hold a reference to the WebTransport so it can't go away on
     48  // us.  This forms a cycle with WebTransport that will be broken when the
     49  // CC runs.   WebTransport::CleanUp() will destroy all the send and receive
     50  // streams, breaking the cycle.
     51  RefPtr<WebTransport> mTransport;
     52  uint64_t mStreamId;
     53  Nullable<int64_t> mSendOrder;
     54 };
     55 }  // namespace mozilla::dom
     56 
     57 #endif