Bug 1892325 - Introduce WebTransportSessionEventListenerInternal, r=nika

Differential Revision: https://phabricator.services.mozilla.com/D207919
This commit is contained in:
Kershaw Chang 2024-04-22 08:57:42 +00:00
Родитель ebc75d7896
Коммит e9599d34ea
6 изменённых файлов: 36 добавлений и 47 удалений

Просмотреть файл

@ -625,25 +625,6 @@ void WebTransportParent::NotifyRemoteClosed(bool aCleanly, uint32_t aErrorCode,
}));
}
// This method is currently not used by WebTransportSessionProxy to inform of
// any session related events. All notification is recieved via
// WebTransportSessionProxy::OnSessionReady and
// WebTransportSessionProxy::OnSessionClosed methods
NS_IMETHODIMP
WebTransportParent::OnSessionReadyInternal(
mozilla::net::Http3WebTransportSession* aSession) {
Unused << aSession;
return NS_OK;
}
NS_IMETHODIMP
WebTransportParent::OnIncomingStreamAvailableInternal(
mozilla::net::Http3WebTransportStream* aStream) {
// XXX implement once DOM WebAPI supports creation of streams
Unused << aStream;
return NS_OK;
}
NS_IMETHODIMP
WebTransportParent::OnIncomingUnidirectionalStreamAvailable(
nsIWebTransportReceiveStream* aStream) {
@ -795,13 +776,6 @@ NS_IMETHODIMP WebTransportParent::OnDatagramReceived(
return NS_OK;
}
NS_IMETHODIMP WebTransportParent::OnDatagramReceivedInternal(
nsTArray<uint8_t>&& aData) {
// this method is used only for internal notificaiton within necko
// we dont expect to receive any notification with on this interface
return NS_OK;
}
NS_IMETHODIMP
WebTransportParent::OnOutgoingDatagramOutCome(
uint64_t aId, WebTransportSessionEventListener::DatagramOutcome aOutCome) {

Просмотреть файл

@ -447,7 +447,10 @@ Http3WebTransportSession::OnIncomingWebTransportStream(
return nullptr;
}
mListener->OnIncomingStreamAvailableInternal(stream);
if (nsCOMPtr<WebTransportSessionEventListenerInternal> listener =
do_QueryInterface(mListener)) {
listener->OnIncomingStreamAvailableInternal(stream);
}
return stream.forget();
}
@ -470,7 +473,10 @@ void Http3WebTransportSession::OnDatagramReceived(nsTArray<uint8_t>&& aData) {
return;
}
mListener->OnDatagramReceivedInternal(std::move(aData));
if (nsCOMPtr<WebTransportSessionEventListenerInternal> listener =
do_QueryInterface(mListener)) {
listener->OnDatagramReceivedInternal(std::move(aData));
}
}
void Http3WebTransportSession::GetMaxDatagramSize() {

Просмотреть файл

@ -2198,8 +2198,9 @@ bool nsHttpTransaction::HandleWebTransportResponse(uint16_t aStatus) {
webTransportListener = mWebTransportSessionEventListener;
mWebTransportSessionEventListener = nullptr;
}
if (webTransportListener) {
webTransportListener->OnSessionReadyInternal(wtSession);
if (nsCOMPtr<WebTransportSessionEventListenerInternal> listener =
do_QueryInterface(webTransportListener)) {
listener->OnSessionReadyInternal(wtSession);
wtSession->SetWebTransportSessionEventListener(webTransportListener);
}

Просмотреть файл

@ -27,6 +27,7 @@ namespace mozilla::net {
LazyLogModule webTransportLog("nsWebTransport");
NS_IMPL_ISUPPORTS(WebTransportSessionProxy, WebTransportSessionEventListener,
WebTransportSessionEventListenerInternal,
WebTransportConnectionSettings, nsIWebTransport,
nsIRedirectResultListener, nsIStreamListener,
nsIChannelEventSink, nsIInterfaceRequestor);

Просмотреть файл

@ -119,17 +119,20 @@ namespace mozilla::net {
class WebTransportStreamCallbackWrapper;
class WebTransportSessionProxy final : public nsIWebTransport,
public WebTransportSessionEventListener,
public WebTransportConnectionSettings,
public nsIStreamListener,
public nsIChannelEventSink,
public nsIRedirectResultListener,
public nsIInterfaceRequestor {
class WebTransportSessionProxy final
: public nsIWebTransport,
public WebTransportSessionEventListener,
public WebTransportSessionEventListenerInternal,
public WebTransportConnectionSettings,
public nsIStreamListener,
public nsIChannelEventSink,
public nsIRedirectResultListener,
public nsIInterfaceRequestor {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIWEBTRANSPORT
NS_DECL_WEBTRANSPORTSESSIONEVENTLISTENER
NS_DECL_WEBTRANSPORTSESSIONEVENTLISTENERINTERNAL
NS_DECL_WEBTRANSPORTCONNECTIONSETTINGS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER

Просмотреть файл

@ -79,9 +79,6 @@ 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);
// This is used internally to pass the reference of WebTransportSession
// object to WebTransportSessionProxy.
void onSessionReadyInternal(in Http3WebTransportSessionPtr aSession);
void onSessionClosed(in boolean aCleanly,
in uint32_t aErrorCode,
in ACString aReason);
@ -90,19 +87,12 @@ interface WebTransportSessionEventListener : nsISupports {
void onIncomingBidirectionalStreamAvailable(in nsIWebTransportBidirectionalStream aStream);
void onIncomingUnidirectionalStreamAvailable(in nsIWebTransportReceiveStream aStream);
// This is used internally to pass the reference of Http3WebTransportStream
// object to WebTransportSessionProxy.
void onIncomingStreamAvailableInternal(in Http3WebTransportStreamPtr aStream);
void onStopSending(in uint64_t aStreamId, in nsresult aError);
void onResetReceived(in uint64_t aStreamId, in nsresult aError);
// When a new datagram has been received.
void onDatagramReceived(in Array<uint8_t> aData);
// This is used internally to pass the datagram to WebTransportSessionProxy.
void onDatagramReceivedInternal(in Datagram aData);
void onMaxDatagramSize(in uint64_t aSize);
cenum DatagramOutcome: 32 {
@ -118,6 +108,20 @@ interface WebTransportSessionEventListener : nsISupports {
// void onStatsAvailable(in WebTransportStats aStats);
};
[uuid(8fb30aa9-5163-4eb3-81f3-371e1ccb5b0e)]
interface WebTransportSessionEventListenerInternal : nsISupports {
// This is used internally to pass the reference of WebTransportSession
// object to WebTransportSessionProxy.
void onSessionReadyInternal(in Http3WebTransportSessionPtr aSession);
// This is used internally to pass the reference of Http3WebTransportStream
// object to WebTransportSessionProxy.
void onIncomingStreamAvailableInternal(in Http3WebTransportStreamPtr aStream);
// This is used internally to pass the datagram to WebTransportSessionProxy.
void onDatagramReceivedInternal(in Datagram aData);
};
[uuid(faad75bd-83c6-420b-9fdb-a70bd70be449)]
interface WebTransportConnectionSettings : nsISupports {
// WebTransport specific connection information