Bug 933821 - Replace IPC_ASSERT(MSG_ROUTING_NONE != msg->routing_id(), "need a route") with PrintMessageRouteError. r=bent

This commit is contained in:
Peiyong Lin 2013-11-14 15:24:18 -05:00
parent bbe2da67fa
commit 7929d92b91
2 changed files with 22 additions and 9 deletions

View File

@ -84,6 +84,15 @@ MessageChannel::~MessageChannel()
Clear();
}
static void
PrintErrorMessage(Side side, const char* channelName, const char* msg)
{
const char *from = (side == ChildSide)
? "Child"
: ((side == ParentSide) ? "Parent" : "Unknown");
printf_stderr("\n###!!! [%s][%s] Error: %s\n\n", from, channelName, msg);
}
bool
MessageChannel::Connected() const
{
@ -213,7 +222,10 @@ MessageChannel::Echo(Message* aMsg)
nsAutoPtr<Message> msg(aMsg);
AssertWorkerThread();
mMonitor->AssertNotCurrentThreadOwns();
IPC_ASSERT(MSG_ROUTING_NONE != msg->routing_id(), "need a route");
if (MSG_ROUTING_NONE == msg->routing_id()) {
ReportMessageRouteError("MessageChannel::Echo");
return false;
}
MonitorAutoLock lock(*mMonitor);
@ -235,7 +247,10 @@ MessageChannel::Send(Message* aMsg)
nsAutoPtr<Message> msg(aMsg);
AssertWorkerThread();
mMonitor->AssertNotCurrentThreadOwns();
IPC_ASSERT(MSG_ROUTING_NONE != msg->routing_id(), "need a route");
if (MSG_ROUTING_NONE == msg->routing_id()) {
ReportMessageRouteError("MessageChannel::Send");
return false;
}
MonitorAutoLock lock(*mMonitor);
if (!Connected()) {
@ -1254,14 +1269,11 @@ MessageChannel::DispatchOnChannelConnected(int32_t peer_pid)
mListener->OnChannelConnected(peer_pid);
}
static void
PrintErrorMessage(Side side, const char* channelName, const char* msg)
void
MessageChannel::ReportMessageRouteError(const char* channelName) const
{
const char *from = (side == ChildSide)
? "Child"
: ((side == ParentSide) ? "Parent" : "Unknown");
printf_stderr("\n###!!! [%s][%s] Error: %s\n\n", from, channelName, msg);
PrintErrorMessage(mSide, channelName, "Need a route");
mListener->OnProcessingError(MsgRouteError);
}
void

View File

@ -169,6 +169,7 @@ class MessageChannel : HasResultCodes
void PostErrorNotifyTask();
void OnNotifyMaybeChannelError();
void ReportConnectionError(const char* aChannelName) const;
void ReportMessageRouteError(const char* channelName) const;
bool MaybeHandleError(Result code, const char* channelName);
void Clear();