Source code

Revision control

Copy as Markdown

Other Tools

/* 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/. */
#include "nsISupports.idl"
#include "nsIURI.idl"
#include "nsIPrincipal.idl"
interface WebTransportSessionEventListener;
interface nsIWebTransportStreamCallback;
interface nsIWebTransportBidirectionalStream;
interface nsIWebTransportSendStream;
interface nsIWebTransportReceiveStream;
interface nsIWebTransportHash;
%{C++
namespace mozilla {
class TimeStamp;
}
namespace mozilla::dom {
class ClientInfo;
class WebTransportStatsData;
}
namespace mozilla::net {
class WebTransportSessionBase;
class WebTransportStreamBase;
}
%}
[ptr] native WebTransportStatsDataPtr(mozilla::dom::WebTransportStatsData);
[ptr] native WebTransportSessionPtr(mozilla::net::WebTransportSessionBase);
[ptr] native WebTransportStreamPtr(mozilla::net::WebTransportStreamBase);
native Datagram(nsTArray<uint8_t>&&);
native TimeStamp(mozilla::TimeStamp);
[ref] native const_MaybeClientInfoRef(const mozilla::Maybe<mozilla::dom::ClientInfo>);
[builtinclass, scriptable, uuid(c20d6e77-8cb1-4838-a88d-fff826080aa3)]
interface nsIWebTransport : nsISupports {
cenum WebTransportError : 16 {
UNKNOWN_ERROR,
INVALID_STATE_ERROR,
};
cenum HTTPVersion: 8 {
h3 = 0,
h2 = 1,
};
// When called, perform steps in "Initialization WebTransport over HTTP".
void asyncConnect(in nsIURI aURI,
in boolean aDedicated,
in Array<nsIWebTransportHash> aServerCertHashes,
in nsIPrincipal aLoadingPrincipal,
in unsigned long aSecurityFlags,
in WebTransportSessionEventListener aListener,
[optional] in nsIWebTransport_HTTPVersion aVersion);
// aHeaderNames and aHeaderValues are parallel arrays of extra request
// headers; the caller has already applied the Fetch request-header
// restrictions.
[noscript]
void asyncConnectWithClient(in nsIURI aURI,
in boolean aDedicated,
in Array<nsIWebTransportHash> aServerCertHashes,
in nsIPrincipal aLoadingPrincipal,
in uint64_t aBrowsingContextID,
in unsigned long aSecurityFlags,
in WebTransportSessionEventListener aListener,
in const_MaybeClientInfoRef aClientInfo,
in Array<AString> aProtocols,
in Array<ACString> aHeaderNames,
in Array<ACString> aHeaderValues,
in nsIWebTransport_HTTPVersion aVersion,
in unsigned short aAnticipatedConcurrentIncomingUnidirectionalStreams,
in unsigned short aAnticipatedConcurrentIncomingBidirectionalStreams);
// Asynchronously get stats. On success (NS_OK), results in exactly one
// call to onStatsAvailable(), even if stats could not be gathered (in
// which case aStats is null) -- unless the session is torn down before the
// gather completes, since there is then no listener left to call back. On
// failure, no callback follows; the caller must treat that the same as a
// null aStats.
void getStats();
// Largest aOutputLength exportKeyingMaterial() accepts.
const unsigned long MAX_KEYING_MATERIAL_LENGTH = 4096;
// Export keying material using TLS exporter (RFC 5705).
// Returns the exported keying material in the output array.
void exportKeyingMaterial(in Array<uint8_t> aLabel,
in Array<uint8_t> aContext,
in uint32_t aOutputLength,
out Array<uint8_t> aKeyingMaterial);
// Close the session.
void closeSession(in uint32_t aErrorCode,
in ACString aReason);
// Create and open a new WebTransport stream.
void createOutgoingBidirectionalStream(in nsIWebTransportStreamCallback aListener);
void createOutgoingUnidirectionalStream(in nsIWebTransportStreamCallback aListener);
void sendDatagram(in Array<uint8_t> aData, in uint64_t aTrackingId,
in uint64_t aSendGroupId, in int64_t aSendOrder);
// As sendDatagram(), for a datagram written at aTimestamp: outgoingMaxAge
// is measured from then, not from when it reaches the queue.
[noscript] void sendDatagramAt(in Array<uint8_t> aData,
in uint64_t aTrackingId,
in uint64_t aSendGroupId,
in int64_t aSendOrder,
in TimeStamp aTimestamp);
void getMaxDatagramSize();
uint64_t getHttpChannelID();
// Set the outgoing datagram queue's maximum buffered datagram count
void setDatagramMaxBufferedDatagrams(in uint32_t aMaxBufferedDatagrams);
// Set the outgoing datagram queue max age in milliseconds
void setDatagramMaxAge(in double aMaxAge);
// Get the negotiated protocol (subprotocol) for the session.
// Returns empty string if no protocol was negotiated.
ACString getNegotiatedProtocol();
// Get the HTTP response headers from the session establishment.
// Returns empty arrays if no headers were received.
[noscript] void getResponseHeaders(out Array<ACString> aNames,
out Array<ACString> aValues);
// Register a send group with a caller-provided ID.
void registerSendGroup(in uint64_t groupId);
// Set anticipated concurrent incoming stream limits. These raise the peer's
// stream limit via MAX_STREAMS frames; they cannot lower it. Callable from
// any thread, and before the session is ready, in which case the value is
// applied once it comes up.
void setAnticipatedConcurrentIncomingUnidirectionalStreams(in unsigned short aValue);
void setAnticipatedConcurrentIncomingBidirectionalStreams(in unsigned short aValue);
// This can be only called after onSessionReady().
// After this point, we can retarget the underlying WebTransportSessionProxy
// object off main thread.
[noscript] void retargetTo(in nsIEventTarget aTarget);
};
// Wraps a WebTransportStatsData snapshot so it can be passed through a
// scriptable interface. The raw data is only accessible to native (C++)
// consumers, since WebTransportStatsData itself is not scriptable.
[builtinclass, scriptable, uuid(bd8549d7-002f-4032-96a4-19430399d081)]
interface nsIWebTransportSessionStats : nsISupports {
[noscript] readonly attribute WebTransportStatsDataPtr rawStats;
};
// Events related to a WebTransport session.
[scriptable, uuid(0e3cb269-f318-43c8-959e-897f57894b71)]
interface WebTransportSessionEventListener : nsISupports {
// This is used to let the consumer of nsIWebTransport know that the
// underlying WebTransportSession object is ready to use.
void onSessionReady(in uint64_t aSessionId);
void onSessionClosed(in boolean aCleanly,
in uint32_t aErrorCode,
in ACString aReason,
in nsIWebTransportSessionStats aStats);
void onDraining();
// When a new stream has been received.
void onIncomingBidirectionalStreamAvailable(in nsIWebTransportBidirectionalStream aStream);
void onIncomingUnidirectionalStreamAvailable(in nsIWebTransportReceiveStream aStream);
// aErrorCode is the application error code. A value above 0xffffffff means
// the peer sent no code that maps to one.
void onStopSending(in uint64_t aStreamId, in uint64_t aErrorCode);
void onResetReceived(in uint64_t aStreamId, in uint64_t aErrorCode);
// When a new datagram has been received.
void onDatagramReceived(in Array<uint8_t> aData);
void onMaxDatagramSize(in uint64_t aSize);
cenum DatagramOutcome: 32 {
UNKNOWN = 0,
DROPPED_TOO_MUCH_DATA = 1,
SENT = 2,
DROPPED_TOO_OLD = 3,
DROPPED_QUEUE_FULL = 4,
};
void onOutgoingDatagramOutCome(
in uint64_t aId,
in WebTransportSessionEventListener_DatagramOutcome aOutCome);
// aStats is null if stats could not be gathered for this session.
void onStatsAvailable(in nsIWebTransportSessionStats aStats);
};
[uuid(8d265242-8a8c-46d2-a9e2-8859bf9b9a88)]
interface WebTransportSessionEventListenerInternal : nsISupports {
// This is used internally to pass the reference of WebTransportSession
// object to WebTransportSessionProxy.
void onSessionReadyInternal(in WebTransportSessionPtr aSession);
// This is used internally to pass the reference of WebTransportStream
// object to WebTransportSessionProxy.
void onIncomingStreamAvailableInternal(in WebTransportStreamPtr aStream);
// This is used internally to pass the datagram to WebTransportSessionProxy.
void onDatagramReceivedInternal(in Datagram aData);
// The anticipatedConcurrentIncoming{Uni,Bi}directionalStreams values to
// apply once the CONNECT has been sent. 0 means not requested.
void getAnticipatedConcurrentIncomingStreams(out uint16_t aUni,
out uint16_t aBidi);
};
[uuid(faad75bd-83c6-420b-9fdb-a70bd70be449)]
interface WebTransportConnectionSettings : nsISupports {
// WebTransport specific connection information
readonly attribute boolean dedicated;
void getServerCertificateHashes(out Array<nsIWebTransportHash> aServerCertHashes);
readonly attribute nsIWebTransport_HTTPVersion httpVersion;
};
// This interface is used as a callback when creating an outgoing
// unidirectional or bidirectional stream.
[scriptable, uuid(c6eeff1d-599b-40a8-9157-c7a40c3d51a2)]
interface nsIWebTransportStreamCallback : nsISupports {
void onBidirectionalStreamReady(in nsIWebTransportBidirectionalStream aStream);
void onUnidirectionalStreamReady(in nsIWebTransportSendStream aStream);
void onError(in uint8_t aError);
};
[scriptable, uuid(2523a26e-94be-4de6-8c27-9b4ffff742f0)]
interface nsIWebTransportHash : nsISupports {
readonly attribute ACString algorithm;
readonly attribute Array<uint8_t> value;
};