tor-browser

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

Http2Stream.h (1855B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set sw=2 ts=8 et 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 mozilla_net_Http2Stream_h
      8 #define mozilla_net_Http2Stream_h
      9 
     10 #include "Http2StreamBase.h"
     11 
     12 namespace mozilla::net {
     13 
     14 class Http2Stream : public Http2StreamBase {
     15 public:
     16  NS_INLINE_DECL_REFCOUNTING_INHERITED(Http2Stream, Http2StreamBase)
     17 
     18  Http2Stream(nsAHttpTransaction* httpTransaction, Http2Session* session,
     19              int32_t priority, uint64_t bcId);
     20 
     21  void CloseStream(nsresult reason) override;
     22  Http2Stream* GetHttp2Stream() override { return this; }
     23  uint32_t GetWireStreamId() override;
     24 
     25  nsresult OnWriteSegment(char* buf, uint32_t count,
     26                          uint32_t* countWritten) override;
     27 
     28  nsAHttpTransaction* Transaction() override { return mTransaction; }
     29  nsIRequestContext* RequestContext() override {
     30    return mTransaction ? mTransaction->RequestContext() : nullptr;
     31  }
     32 
     33 protected:
     34  ~Http2Stream();
     35  nsresult CallToReadData(uint32_t count, uint32_t* countRead) override;
     36  nsresult CallToWriteData(uint32_t count, uint32_t* countWritten) override;
     37  nsresult GenerateHeaders(nsCString& aCompressedData,
     38                           uint8_t& firstFrameFlags) override;
     39 
     40 private:
     41  // The underlying HTTP transaction. This pointer is used as the key
     42  // in the Http2Session mStreamTransactionHash so it is important to
     43  // keep a reference to it as long as this stream is a member of that hash.
     44  // (i.e. don't change it or release it after it is set in the ctor).
     45  RefPtr<nsAHttpTransaction> mTransaction;
     46 };
     47 
     48 }  // namespace mozilla::net
     49 
     50 #endif  // mozilla_net_Http2Stream_h