Loading ipc/glue/AsyncChannel.cpp +35 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,33 @@ AsyncChannel::Send(Message* msg) return true; } bool AsyncChannel::Echo(Message* msg) { AssertWorkerThread(); mMonitor.AssertNotCurrentThreadOwns(); NS_ABORT_IF_FALSE(MSG_ROUTING_NONE != msg->routing_id(), "need a route"); { MonitorAutoLock lock(mMonitor); if (!Connected()) { ReportConnectionError("AsyncChannel"); return false; } // NB: Go through this OnMessageReceived indirection so that // echoing this message does the right thing for SyncChannel // and RPCChannel too mIOLoop->PostTask( FROM_HERE, NewRunnableMethod(this, &AsyncChannel::OnEchoMessage, msg)); // OnEchoMessage takes ownership of |msg| } return true; } void AsyncChannel::OnDispatchMessage(const Message& msg) { Loading Loading @@ -470,6 +497,14 @@ AsyncChannel::OnMessageReceived(const Message& msg) NewRunnableMethod(this, &AsyncChannel::OnDispatchMessage, msg)); } void AsyncChannel::OnEchoMessage(Message* msg) { AssertIOThread(); OnMessageReceived(*msg); delete msg; } void AsyncChannel::OnChannelOpened() { Loading ipc/glue/AsyncChannel.h +5 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,10 @@ public: // Asynchronously send a message to the other side of the channel virtual bool Send(Message* msg); // Asynchronously deliver a message back to this side of the // channel virtual bool Echo(Message* msg); // Send OnChannelConnected notification to listeners. void DispatchOnChannelConnected(int32 peer_pid); Loading Loading @@ -177,6 +181,7 @@ protected: void OnChannelOpened(); void OnCloseChannel(); void PostErrorNotifyTask(); void OnEchoMessage(Message* msg); // Return true if |msg| is a special message targeted at the IO // thread, in which case it shouldn't be delivered to the worker. Loading Loading
ipc/glue/AsyncChannel.cpp +35 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,33 @@ AsyncChannel::Send(Message* msg) return true; } bool AsyncChannel::Echo(Message* msg) { AssertWorkerThread(); mMonitor.AssertNotCurrentThreadOwns(); NS_ABORT_IF_FALSE(MSG_ROUTING_NONE != msg->routing_id(), "need a route"); { MonitorAutoLock lock(mMonitor); if (!Connected()) { ReportConnectionError("AsyncChannel"); return false; } // NB: Go through this OnMessageReceived indirection so that // echoing this message does the right thing for SyncChannel // and RPCChannel too mIOLoop->PostTask( FROM_HERE, NewRunnableMethod(this, &AsyncChannel::OnEchoMessage, msg)); // OnEchoMessage takes ownership of |msg| } return true; } void AsyncChannel::OnDispatchMessage(const Message& msg) { Loading Loading @@ -470,6 +497,14 @@ AsyncChannel::OnMessageReceived(const Message& msg) NewRunnableMethod(this, &AsyncChannel::OnDispatchMessage, msg)); } void AsyncChannel::OnEchoMessage(Message* msg) { AssertIOThread(); OnMessageReceived(*msg); delete msg; } void AsyncChannel::OnChannelOpened() { Loading
ipc/glue/AsyncChannel.h +5 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,10 @@ public: // Asynchronously send a message to the other side of the channel virtual bool Send(Message* msg); // Asynchronously deliver a message back to this side of the // channel virtual bool Echo(Message* msg); // Send OnChannelConnected notification to listeners. void DispatchOnChannelConnected(int32 peer_pid); Loading Loading @@ -177,6 +181,7 @@ protected: void OnChannelOpened(); void OnCloseChannel(); void PostErrorNotifyTask(); void OnEchoMessage(Message* msg); // Return true if |msg| is a special message targeted at the IO // thread, in which case it shouldn't be delivered to the worker. Loading