nsIWebTransport.idl (5873B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 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 #include "nsISupports.idl" 7 #include "nsIURI.idl" 8 #include "nsIPrincipal.idl" 9 10 interface WebTransportSessionEventListener; 11 interface nsIWebTransportStreamCallback; 12 interface nsIWebTransportBidirectionalStream; 13 interface nsIWebTransportSendStream; 14 interface nsIWebTransportReceiveStream; 15 interface nsIWebTransportHash; 16 17 %{C++ 18 namespace mozilla::dom { 19 class ClientInfo; 20 } 21 namespace mozilla::net { 22 class WebTransportSessionBase; 23 class WebTransportStreamBase; 24 } 25 %} 26 27 [ptr] native WebTransportSessionPtr(mozilla::net::WebTransportSessionBase); 28 [ptr] native WebTransportStreamPtr(mozilla::net::WebTransportStreamBase); 29 native Datagram(nsTArray<uint8_t>&&); 30 [ref] native const_MaybeClientInfoRef(const mozilla::Maybe<mozilla::dom::ClientInfo>); 31 32 [builtinclass, scriptable, uuid(c20d6e77-8cb1-4838-a88d-fff826080aa3)] 33 interface nsIWebTransport : nsISupports { 34 cenum WebTransportError : 16 { 35 UNKNOWN_ERROR, 36 INVALID_STATE_ERROR, 37 }; 38 39 cenum HTTPVersion: 8 { 40 h3 = 0, 41 h2 = 1, 42 }; 43 44 // When called, perform steps in "Initialization WebTransport over HTTP". 45 void asyncConnect(in nsIURI aURI, 46 in boolean aDedicated, 47 in Array<nsIWebTransportHash> aServerCertHashes, 48 in nsIPrincipal aLoadingPrincipal, 49 in unsigned long aSecurityFlags, 50 in WebTransportSessionEventListener aListener, 51 [optional] in nsIWebTransport_HTTPVersion aVersion); 52 53 [noscript] 54 void asyncConnectWithClient(in nsIURI aURI, 55 in boolean aDedicated, 56 in Array<nsIWebTransportHash> aServerCertHashes, 57 in nsIPrincipal aLoadingPrincipal, 58 in uint64_t aBrowsingContextID, 59 in unsigned long aSecurityFlags, 60 in WebTransportSessionEventListener aListener, 61 in const_MaybeClientInfoRef aClientInfo, 62 in nsIWebTransport_HTTPVersion aVersion); 63 64 // Asynchronously get stats. 65 void getStats(); 66 67 // Close the session. 68 void closeSession(in uint32_t aErrorCode, 69 in ACString aReason); 70 71 // Create and open a new WebTransport stream. 72 void createOutgoingBidirectionalStream(in nsIWebTransportStreamCallback aListener); 73 void createOutgoingUnidirectionalStream(in nsIWebTransportStreamCallback aListener); 74 75 void sendDatagram(in Array<uint8_t> aData, in uint64_t aTrackingId); 76 77 void getMaxDatagramSize(); 78 79 uint64_t getHttpChannelID(); 80 81 // This can be only called after onSessionReady(). 82 // After this point, we can retarget the underlying WebTransportSessionProxy 83 // object off main thread. 84 [noscript] void retargetTo(in nsIEventTarget aTarget); 85 }; 86 87 // Events related to a WebTransport session. 88 [scriptable, uuid(0e3cb269-f318-43c8-959e-897f57894b71)] 89 interface WebTransportSessionEventListener : nsISupports { 90 // This is used to let the consumer of nsIWebTransport know that the 91 // underlying WebTransportSession object is ready to use. 92 void onSessionReady(in uint64_t aSessionId); 93 void onSessionClosed(in boolean aCleanly, 94 in uint32_t aErrorCode, 95 in ACString aReason); 96 97 // When a new stream has been received. 98 void onIncomingBidirectionalStreamAvailable(in nsIWebTransportBidirectionalStream aStream); 99 void onIncomingUnidirectionalStreamAvailable(in nsIWebTransportReceiveStream aStream); 100 101 void onStopSending(in uint64_t aStreamId, in nsresult aError); 102 void onResetReceived(in uint64_t aStreamId, in nsresult aError); 103 104 // When a new datagram has been received. 105 void onDatagramReceived(in Array<uint8_t> aData); 106 107 void onMaxDatagramSize(in uint64_t aSize); 108 109 cenum DatagramOutcome: 32 { 110 UNKNOWN = 0, 111 DROPPED_TOO_MUCH_DATA = 1, 112 SENT = 2, 113 }; 114 115 void onOutgoingDatagramOutCome( 116 in uint64_t aId, 117 in WebTransportSessionEventListener_DatagramOutcome aOutCome); 118 119 // void onStatsAvailable(in WebTransportStats aStats); 120 }; 121 122 [uuid(8fb30aa9-5163-4eb3-81f3-371e1ccb5b0e)] 123 interface WebTransportSessionEventListenerInternal : nsISupports { 124 // This is used internally to pass the reference of WebTransportSession 125 // object to WebTransportSessionProxy. 126 void onSessionReadyInternal(in WebTransportSessionPtr aSession); 127 128 // This is used internally to pass the reference of WebTransportStream 129 // object to WebTransportSessionProxy. 130 void onIncomingStreamAvailableInternal(in WebTransportStreamPtr aStream); 131 132 // This is used internally to pass the datagram to WebTransportSessionProxy. 133 void onDatagramReceivedInternal(in Datagram aData); 134 }; 135 136 [uuid(faad75bd-83c6-420b-9fdb-a70bd70be449)] 137 interface WebTransportConnectionSettings : nsISupports { 138 // WebTransport specific connection information 139 readonly attribute boolean dedicated; 140 void getServerCertificateHashes(out Array<nsIWebTransportHash> aServerCertHashes); 141 readonly attribute nsIWebTransport_HTTPVersion httpVersion; 142 }; 143 144 // This interface is used as a callback when creating an outgoing 145 // unidirectional or bidirectional stream. 146 [scriptable, uuid(c6eeff1d-599b-40a8-9157-c7a40c3d51a2)] 147 interface nsIWebTransportStreamCallback : nsISupports { 148 void onBidirectionalStreamReady(in nsIWebTransportBidirectionalStream aStream); 149 void onUnidirectionalStreamReady(in nsIWebTransportSendStream aStream); 150 void onError(in uint8_t aError); 151 }; 152 153 [scriptable, uuid(2523a26e-94be-4de6-8c27-9b4ffff742f0)] 154 interface nsIWebTransportHash : nsISupports { 155 readonly attribute ACString algorithm; 156 readonly attribute Array<uint8_t> value; 157 };