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 1356223e27
commit a222197cc2
2 changed files with 22 additions and 9 deletions

View File

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

View File

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