tor-browser

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

Http3StreamBase.h (2688B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef mozilla_net_Http3StreamBase_h
      7 #define mozilla_net_Http3StreamBase_h
      8 
      9 #include "nsAHttpTransaction.h"
     10 #include "ARefBase.h"
     11 #include "mozilla/WeakPtr.h"
     12 #include "nsIClassOfService.h"
     13 
     14 namespace mozilla::net {
     15 
     16 class Http3SessionBase;
     17 class Http3Stream;
     18 class Http3WebTransportSession;
     19 class Http3WebTransportStream;
     20 class Http3ConnectUDPStream;
     21 class Http3StreamTunnel;
     22 
     23 class Http3StreamBase : public SupportsWeakPtr, public ARefBase {
     24 public:
     25  Http3StreamBase(nsAHttpTransaction* trans, Http3SessionBase* session);
     26 
     27  virtual Http3WebTransportSession* GetHttp3WebTransportSession() = 0;
     28  virtual Http3WebTransportStream* GetHttp3WebTransportStream() = 0;
     29  virtual Http3Stream* GetHttp3Stream() = 0;
     30  virtual Http3ConnectUDPStream* GetHttp3ConnectUDPStream() = 0;
     31  virtual Http3StreamTunnel* GetHttp3StreamTunnel() = 0;
     32 
     33  bool HasStreamId() const { return mStreamId != UINT64_MAX; }
     34  uint64_t StreamId() const { return mStreamId; }
     35 
     36  [[nodiscard]] virtual nsresult ReadSegments() = 0;
     37  [[nodiscard]] virtual nsresult WriteSegments() = 0;
     38 
     39  virtual bool Done() const = 0;
     40 
     41  virtual void SetResponseHeaders(nsTArray<uint8_t>& aResponseHeaders, bool fin,
     42                                  bool interim) = 0;
     43 
     44  void SetQueued(bool aStatus) { mQueued = aStatus; }
     45  bool Queued() const { return mQueued; }
     46 
     47  virtual void Close(nsresult aResult) = 0;
     48 
     49  nsAHttpTransaction* Transaction() { return mTransaction; }
     50 
     51  // Mirrors nsAHttpTransaction
     52  virtual bool Do0RTT() { return false; }
     53  virtual nsresult Finish0RTT(bool aRestart) { return NS_OK; }
     54 
     55  virtual bool RecvdFin() const { return mFin; }
     56  virtual bool RecvdReset() const { return mResetRecv; }
     57  virtual void SetRecvdReset() { mResetRecv = true; }
     58 
     59  void SetInTxQueue(bool aValue) { mInTxQueue = aValue; }
     60  bool IsInTxQueue() const { return mInTxQueue; }
     61 
     62  void SetBlockedByFlowControl(bool aValue) { mBlockedByFlowControl = aValue; }
     63  bool BlockedByFlowControl() const { return mBlockedByFlowControl; }
     64 
     65 protected:
     66  ~Http3StreamBase();
     67 
     68  uint64_t mStreamId{UINT64_MAX};
     69  int64_t mSendOrder{0};
     70  bool mSendOrderIsSet{false};
     71  RefPtr<nsAHttpTransaction> mTransaction;
     72  RefPtr<Http3SessionBase> mSession;
     73  bool mQueued{false};
     74  bool mFin{false};
     75  bool mResetRecv{false};
     76  bool mInTxQueue{false};
     77  bool mBlockedByFlowControl{false};
     78 };
     79 
     80 }  // namespace mozilla::net
     81 
     82 #endif  // mozilla_net_Http3StreamBase_h