Bug 1154990 - Better error messages when IPC send fails (r=bent)

This commit is contained in:
Bill McCloskey 2015-04-15 16:43:21 -07:00
Родитель 8a525c8781
Коммит 86e65c20f2
2 изменённых файлов: 16 добавлений и 7 удалений

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

@ -522,7 +522,7 @@ MessageChannel::Echo(Message* aMsg)
MonitorAutoLock lock(*mMonitor);
if (!Connected()) {
ReportConnectionError("MessageChannel");
ReportConnectionError("MessageChannel", msg);
return false;
}
@ -545,7 +545,7 @@ MessageChannel::Send(Message* aMsg)
MonitorAutoLock lock(*mMonitor);
if (!Connected()) {
ReportConnectionError("MessageChannel");
ReportConnectionError("MessageChannel", msg);
return false;
}
mLink->SendMessage(msg.forget());
@ -778,7 +778,7 @@ MessageChannel::Send(Message* aMsg, Message* aReply)
nsAutoPtr<Message> msg(aMsg);
if (!Connected()) {
ReportConnectionError("MessageChannel::SendAndWait");
ReportConnectionError("MessageChannel::SendAndWait", msg);
return false;
}
@ -871,7 +871,7 @@ MessageChannel::Call(Message* aMsg, Message* aReply)
MonitorAutoLock lock(*mMonitor);
if (!Connected()) {
ReportConnectionError("MessageChannel::Call");
ReportConnectionError("MessageChannel::Call", aMsg);
return false;
}
@ -1527,7 +1527,7 @@ MessageChannel::ReportMessageRouteError(const char* channelName) const
}
void
MessageChannel::ReportConnectionError(const char* aChannelName) const
MessageChannel::ReportConnectionError(const char* aChannelName, Message* aMsg) const
{
AssertWorkerThread();
mMonitor->AssertCurrentThreadOwns();
@ -1554,7 +1554,16 @@ MessageChannel::ReportConnectionError(const char* aChannelName) const
NS_RUNTIMEABORT("unreached");
}
PrintErrorMessage(mSide, aChannelName, errorMsg);
if (aMsg) {
char reason[512];
PR_snprintf(reason, sizeof(reason),
"(msgtype=0x%lX,name=%s) %s",
aMsg->type(), aMsg->name(), errorMsg);
PrintErrorMessage(mSide, aChannelName, reason);
} else {
PrintErrorMessage(mSide, aChannelName, errorMsg);
}
MonitorAutoUnlock unlock(*mMonitor);
mListener->OnProcessingError(MsgDropped, errorMsg);

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

@ -215,7 +215,7 @@ class MessageChannel : HasResultCodes
void PostErrorNotifyTask();
void OnNotifyMaybeChannelError();
void ReportConnectionError(const char* aChannelName) const;
void ReportConnectionError(const char* aChannelName, Message* aMsg = nullptr) const;
void ReportMessageRouteError(const char* channelName) const;
bool MaybeHandleError(Result code, const Message& aMsg, const char* channelName);