mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1696776 - Expose error code in TCPSocketErrorEvent. r=valentin
Thunderbird cares about it and it's hackily trying to reverse-infer it from the name: https://searchfox.org/comm-central/rev/73f8cad1726bfcabc5d9498346abca6f9b7b97fc/mailnews/compose/src/SmtpClient.jsm#438-453 Differential Revision: https://phabricator.services.mozilla.com/D107378
This commit is contained in:
parent
0686831376
commit
767b8672fa
@ -14,6 +14,7 @@ using struct mozilla::void_t from "mozilla/ipc/IPCCore.h";
|
||||
struct TCPError {
|
||||
nsString name;
|
||||
nsString message;
|
||||
nsresult errorCode;
|
||||
};
|
||||
|
||||
union SendableData {
|
||||
|
@ -461,9 +461,10 @@ void TCPSocket::ActivateTLS() {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TCPSocket::FireErrorEvent(const nsAString& aName, const nsAString& aType) {
|
||||
TCPSocket::FireErrorEvent(const nsAString& aName, const nsAString& aType,
|
||||
nsresult aErrorCode) {
|
||||
if (mSocketBridgeParent) {
|
||||
mSocketBridgeParent->FireErrorEvent(aName, aType, mReadyState);
|
||||
mSocketBridgeParent->FireErrorEvent(aName, aType, aErrorCode, mReadyState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -472,6 +473,8 @@ TCPSocket::FireErrorEvent(const nsAString& aName, const nsAString& aType) {
|
||||
init.mCancelable = false;
|
||||
init.mName = aName;
|
||||
init.mMessage = aType;
|
||||
static_assert(std::is_same_v<std::underlying_type_t<nsresult>, uint32_t>);
|
||||
init.mErrorCode = uint32_t(aErrorCode);
|
||||
|
||||
RefPtr<TCPSocketErrorEvent> event =
|
||||
TCPSocketErrorEvent::Constructor(this, u"error"_ns, init);
|
||||
@ -698,7 +701,7 @@ nsresult TCPSocket::MaybeReportErrorAndCloseIfOpen(nsresult status) {
|
||||
}
|
||||
}
|
||||
|
||||
Unused << NS_WARN_IF(NS_FAILED(FireErrorEvent(errName, errorType)));
|
||||
Unused << NS_WARN_IF(NS_FAILED(FireErrorEvent(errName, errorType, status)));
|
||||
}
|
||||
|
||||
return FireEvent(u"close"_ns);
|
||||
|
@ -130,7 +130,7 @@ mozilla::ipc::IPCResult TCPSocketChild::RecvCallback(
|
||||
|
||||
} else if (aData.type() == CallbackData::TTCPError) {
|
||||
const TCPError& err(aData.get_TCPError());
|
||||
mSocket->FireErrorEvent(err.name(), err.message());
|
||||
mSocket->FireErrorEvent(err.name(), err.message(), err.errorCode());
|
||||
|
||||
} else if (aData.type() == CallbackData::TSendableData) {
|
||||
const SendableData& data = aData.get_SendableData();
|
||||
|
@ -152,9 +152,9 @@ mozilla::ipc::IPCResult TCPSocketParent::RecvClose() {
|
||||
}
|
||||
|
||||
void TCPSocketParent::FireErrorEvent(const nsAString& aName,
|
||||
const nsAString& aType,
|
||||
const nsAString& aType, nsresult aError,
|
||||
TCPReadyState aReadyState) {
|
||||
SendEvent(u"error"_ns, TCPError(nsString(aName), nsString(aType)),
|
||||
SendEvent(u"error"_ns, TCPError(nsString(aName), nsString(aType), aError),
|
||||
aReadyState);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class TCPSocketParent : public mozilla::net::PTCPSocketParent,
|
||||
mozilla::ipc::IPCResult RecvRequestDelete();
|
||||
|
||||
void FireErrorEvent(const nsAString& aName, const nsAString& aType,
|
||||
TCPReadyState aReadyState);
|
||||
nsresult aError, TCPReadyState aReadyState);
|
||||
void FireEvent(const nsAString& aType, TCPReadyState aReadyState);
|
||||
void FireArrayBufferDataEvent(nsTArray<uint8_t>& aBuffer,
|
||||
TCPReadyState aReadyState);
|
||||
|
@ -30,7 +30,7 @@ interface nsITCPSocketCallback : nsISupports {
|
||||
const unsigned long BUFFER_SIZE = 65536;
|
||||
|
||||
// Dispatch an "error" event at this object with the given name and type.
|
||||
void fireErrorEvent(in AString name, in AString type);
|
||||
void fireErrorEvent(in AString name, in AString type, in nsresult errorCode);
|
||||
|
||||
// Dispatch a "data" event at this object with a string
|
||||
void fireDataStringEvent(in AString type, in ACString data);
|
||||
|
@ -17,10 +17,12 @@ interface TCPSocketErrorEvent : Event {
|
||||
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute DOMString message;
|
||||
readonly attribute unsigned long errorCode; // The internal nsresult error code.
|
||||
};
|
||||
|
||||
dictionary TCPSocketErrorEventInit : EventInit
|
||||
{
|
||||
DOMString name = "";
|
||||
DOMString message = "";
|
||||
unsigned long errorCode = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user