Backed out changeset 88fbb17e3c20 (bug 1865637) for causing animation related mochite...
[gecko.git] / netwerk / socket / neqo_glue / NeqoHttp3Conn.h
blob63fbe389f3f2b5b8aa69fa4d3834a92b3988173b
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef NeqoHttp3Conn_h__
6 #define NeqoHttp3Conn_h__
8 #include <cstdint>
9 #include "mozilla/net/neqo_glue_ffi_generated.h"
11 namespace mozilla {
12 namespace net {
14 class NeqoHttp3Conn final {
15 public:
16 static nsresult Init(const nsACString& aOrigin, const nsACString& aAlpn,
17 const NetAddr& aLocalAddr, const NetAddr& aRemoteAddr,
18 uint32_t aMaxTableSize, uint16_t aMaxBlockedStreams,
19 uint64_t aMaxData, uint64_t aMaxStreamData,
20 bool aVersionNegotiation, bool aWebTransport,
21 const nsACString& aQlogDir, uint32_t aDatagramSize,
22 uint32_t aMaxAccumulatedTime, NeqoHttp3Conn** aConn) {
23 return neqo_http3conn_new(
24 &aOrigin, &aAlpn, &aLocalAddr, &aRemoteAddr, aMaxTableSize,
25 aMaxBlockedStreams, aMaxData, aMaxStreamData, aVersionNegotiation,
26 aWebTransport, &aQlogDir, aDatagramSize, aMaxAccumulatedTime,
27 (const mozilla::net::NeqoHttp3Conn**)aConn);
30 void Close(uint64_t aError) { neqo_http3conn_close(this, aError); }
32 nsresult GetSecInfo(NeqoSecretInfo* aSecInfo) {
33 return neqo_http3conn_tls_info(this, aSecInfo);
36 nsresult PeerCertificateInfo(NeqoCertificateInfo* aCertInfo) {
37 return neqo_http3conn_peer_certificate_info(this, aCertInfo);
40 void PeerAuthenticated(PRErrorCode aError) {
41 neqo_http3conn_authenticated(this, aError);
44 nsresult ProcessInput(const NetAddr& aRemoteAddr,
45 const nsTArray<uint8_t>& aPacket) {
46 return neqo_http3conn_process_input(this, &aRemoteAddr, &aPacket);
49 nsresult ProcessOutputAndSend(void* aContext, SendFunc aSendFunc,
50 SetTimerFunc aSetTimerFunc) {
51 return neqo_http3conn_process_output_and_send(this, aContext, aSendFunc,
52 aSetTimerFunc);
55 nsresult GetEvent(Http3Event* aEvent, nsTArray<uint8_t>& aData) {
56 return neqo_http3conn_event(this, aEvent, &aData);
59 nsresult Fetch(const nsACString& aMethod, const nsACString& aScheme,
60 const nsACString& aHost, const nsACString& aPath,
61 const nsACString& aHeaders, uint64_t* aStreamId,
62 uint8_t aUrgency, bool aIncremental) {
63 return neqo_http3conn_fetch(this, &aMethod, &aScheme, &aHost, &aPath,
64 &aHeaders, aStreamId, aUrgency, aIncremental);
67 nsresult PriorityUpdate(uint64_t aStreamId, uint8_t aUrgency,
68 bool aIncremental) {
69 return neqo_http3conn_priority_update(this, aStreamId, aUrgency,
70 aIncremental);
73 nsresult SendRequestBody(uint64_t aStreamId, const uint8_t* aBuf,
74 uint32_t aCount, uint32_t* aCountRead) {
75 return neqo_htttp3conn_send_request_body(this, aStreamId, aBuf, aCount,
76 aCountRead);
79 // This closes only the sending side of a stream.
80 nsresult CloseStream(uint64_t aStreamId) {
81 return neqo_http3conn_close_stream(this, aStreamId);
84 nsresult ReadResponseData(uint64_t aStreamId, uint8_t* aBuf, uint32_t aLen,
85 uint32_t* aRead, bool* aFin) {
86 return neqo_http3conn_read_response_data(this, aStreamId, aBuf, aLen, aRead,
87 aFin);
90 void CancelFetch(uint64_t aStreamId, uint64_t aError) {
91 neqo_http3conn_cancel_fetch(this, aStreamId, aError);
94 void ResetStream(uint64_t aStreamId, uint64_t aError) {
95 neqo_http3conn_reset_stream(this, aStreamId, aError);
98 void StreamStopSending(uint64_t aStreamId, uint64_t aError) {
99 neqo_http3conn_stream_stop_sending(this, aStreamId, aError);
102 void SetResumptionToken(nsTArray<uint8_t>& aToken) {
103 neqo_http3conn_set_resumption_token(this, &aToken);
106 void SetEchConfig(nsTArray<uint8_t>& aEchConfig) {
107 neqo_http3conn_set_ech_config(this, &aEchConfig);
110 bool IsZeroRtt() { return neqo_http3conn_is_zero_rtt(this); }
112 void AddRef() { neqo_http3conn_addref(this); }
113 void Release() { neqo_http3conn_release(this); }
115 void GetStats(Http3Stats* aStats) {
116 return neqo_http3conn_get_stats(this, aStats);
119 nsresult CreateWebTransport(const nsACString& aHost, const nsACString& aPath,
120 const nsACString& aHeaders,
121 uint64_t* aSessionId) {
122 return neqo_http3conn_webtransport_create_session(this, &aHost, &aPath,
123 &aHeaders, aSessionId);
126 nsresult CloseWebTransport(uint64_t aSessionId, uint32_t aError,
127 const nsACString& aMessage) {
128 return neqo_http3conn_webtransport_close_session(this, aSessionId, aError,
129 &aMessage);
132 nsresult CreateWebTransportStream(uint64_t aSessionId,
133 WebTransportStreamType aStreamType,
134 uint64_t* aStreamId) {
135 return neqo_http3conn_webtransport_create_stream(this, aSessionId,
136 aStreamType, aStreamId);
139 nsresult WebTransportSendDatagram(uint64_t aSessionId,
140 nsTArray<uint8_t>& aData,
141 uint64_t aTrackingId) {
142 return neqo_http3conn_webtransport_send_datagram(this, aSessionId, &aData,
143 aTrackingId);
146 nsresult WebTransportMaxDatagramSize(uint64_t aSessionId, uint64_t* aResult) {
147 return neqo_http3conn_webtransport_max_datagram_size(this, aSessionId,
148 aResult);
151 nsresult WebTransportSetSendOrder(uint64_t aSessionId,
152 Maybe<int64_t> aSendOrder) {
153 return neqo_http3conn_webtransport_set_sendorder(this, aSessionId,
154 aSendOrder.ptrOr(nullptr));
157 private:
158 NeqoHttp3Conn() = delete;
159 ~NeqoHttp3Conn() = delete;
160 NeqoHttp3Conn(const NeqoHttp3Conn&) = delete;
161 NeqoHttp3Conn& operator=(const NeqoHttp3Conn&) = delete;
164 } // namespace net
165 } // namespace mozilla
167 #endif