diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /netwerk/protocol/webtransport/WebTransportStreamProxy.h | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/protocol/webtransport/WebTransportStreamProxy.h')
-rw-r--r-- | netwerk/protocol/webtransport/WebTransportStreamProxy.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/netwerk/protocol/webtransport/WebTransportStreamProxy.h b/netwerk/protocol/webtransport/WebTransportStreamProxy.h new file mode 100644 index 0000000000..972eac3f05 --- /dev/null +++ b/netwerk/protocol/webtransport/WebTransportStreamProxy.h @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_net_WebTransportStreamProxy_h +#define mozilla_net_WebTransportStreamProxy_h + +#include "nsIAsyncInputStream.h" +#include "nsIAsyncOutputStream.h" +#include "nsIWebTransportStream.h" +#include "nsCOMPtr.h" + +namespace mozilla::net { + +class Http3WebTransportStream; + +class WebTransportStreamProxy final + : public nsIWebTransportReceiveStream, + public nsIWebTransportSendStream, + public nsIWebTransportBidirectionalStream { + public: + NS_DECL_THREADSAFE_ISUPPORTS + + explicit WebTransportStreamProxy(Http3WebTransportStream* aStream); + + NS_IMETHOD SendStopSending(uint8_t aError) override; + NS_IMETHOD SendFin() override; + NS_IMETHOD Reset(uint8_t aErrorCode) override; + NS_IMETHOD GetSendStreamStats( + nsIWebTransportStreamStatsCallback* aCallback) override; + NS_IMETHOD GetReceiveStreamStats( + nsIWebTransportStreamStatsCallback* aCallback) override; + + NS_IMETHOD GetHasReceivedFIN(bool* aHasReceivedFIN) override; + + NS_IMETHOD GetInputStream(nsIAsyncInputStream** aOut) override; + NS_IMETHOD GetOutputStream(nsIAsyncOutputStream** aOut) override; + + NS_IMETHOD GetStreamId(uint64_t* aId) override; + + private: + virtual ~WebTransportStreamProxy(); + + class AsyncInputStreamWrapper : public nsIAsyncInputStream { + public: + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSIINPUTSTREAM + NS_DECL_NSIASYNCINPUTSTREAM + + AsyncInputStreamWrapper(nsIAsyncInputStream* aStream, + Http3WebTransportStream* aWebTransportStream); + + private: + virtual ~AsyncInputStreamWrapper(); + void MaybeCloseStream(); + + nsCOMPtr<nsIAsyncInputStream> mStream; + RefPtr<Http3WebTransportStream> mWebTransportStream; + }; + + class AsyncOutputStreamWrapper : public nsIAsyncOutputStream { + public: + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSIOUTPUTSTREAM + NS_DECL_NSIASYNCOUTPUTSTREAM + + explicit AsyncOutputStreamWrapper(nsIAsyncOutputStream* aStream); + + private: + virtual ~AsyncOutputStreamWrapper(); + + nsCOMPtr<nsIAsyncOutputStream> mStream; + }; + + RefPtr<Http3WebTransportStream> mWebTransportStream; + RefPtr<AsyncOutputStreamWrapper> mWriter; + RefPtr<AsyncInputStreamWrapper> mReader; +}; + +} // namespace mozilla::net + +#endif |