WebTransportSessionBase.h (1590B)
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_WebTransportSessionBase_h 7 #define mozilla_net_WebTransportSessionBase_h 8 9 #include <functional> 10 11 #include "nsISupportsImpl.h" 12 #include "nsTArray.h" 13 14 class WebTransportSessionEventListener; 15 16 namespace mozilla::net { 17 18 class WebTransportStreamBase; 19 20 class WebTransportSessionBase { 21 public: 22 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING 23 24 WebTransportSessionBase() = default; 25 26 void SetWebTransportSessionEventListener( 27 WebTransportSessionEventListener* listener); 28 29 virtual uint64_t GetStreamId() const = 0; 30 virtual void CloseSession(uint32_t aStatus, const nsACString& aReason) = 0; 31 virtual void GetMaxDatagramSize() = 0; 32 virtual void SendDatagram(nsTArray<uint8_t>&& aData, 33 uint64_t aTrackingId) = 0; 34 virtual void CreateOutgoingBidirectionalStream( 35 std::function<void(Result<RefPtr<WebTransportStreamBase>, nsresult>&&)>&& 36 aCallback) = 0; 37 virtual void CreateOutgoingUnidirectionalStream( 38 std::function<void(Result<RefPtr<WebTransportStreamBase>, nsresult>&&)>&& 39 aCallback) = 0; 40 virtual void StartReading() {} 41 42 protected: 43 virtual ~WebTransportSessionBase() = default; 44 45 RefPtr<WebTransportSessionEventListener> mListener; 46 }; 47 48 } // namespace mozilla::net 49 50 #endif // mozilla_net_WebTransportSessionBase_h