Index: components/nacl/loader/nacl_trusted_listener.cc |
diff --git a/components/nacl/loader/nacl_trusted_listener.cc b/components/nacl/loader/nacl_trusted_listener.cc |
index 4c67a09f490644cb55857f4ac307e779919ddea7..76d0cee523d6462593fd4021af128e8085182a52 100644 |
--- a/components/nacl/loader/nacl_trusted_listener.cc |
+++ b/components/nacl/loader/nacl_trusted_listener.cc |
@@ -5,6 +5,32 @@ |
#include "components/nacl/loader/nacl_trusted_listener.h" |
#include "base/single_thread_task_runner.h" |
+#include "ipc/message_filter.h" |
+#include "native_client/src/public/chrome_main.h" |
+ |
+namespace { |
+ |
+// The OnChannelError() event must be processed in a MessageFilter so it can |
+// be handled on the IO thread. The main thread used by NaClListener is busy |
+// in NaClChromeMainAppStart(), so it can't be used for servicing messages. |
+class EOFMessageFilter : public IPC::MessageFilter { |
+ public: |
+ void OnChannelError() override { |
+ // The renderer process dropped its connection to this process (the NaCl |
+ // loader process), either because the <embed> element was removed |
+ // (perhaps implicitly if the tab was closed) or because the renderer |
+ // crashed. The NaCl loader process should therefore exit. |
+ // |
+ // For SFI NaCl, trusted code does this exit voluntarily, but untrusted |
+ // code cannot disable it. However, for Non-SFI NaCl, the following exit |
+ // call could be disabled by untrusted code. |
+ NaClExit(0); |
+ } |
+ private: |
+ ~EOFMessageFilter() override {} |
+}; |
+ |
+} |
NaClTrustedListener::NaClTrustedListener( |
const IPC::ChannelHandle& handle, |
@@ -17,6 +43,7 @@ NaClTrustedListener::NaClTrustedListener( |
ipc_task_runner, |
true, /* create_channel_now */ |
shutdown_event).Pass(); |
+ channel_->AddFilter(new EOFMessageFilter()); |
} |
NaClTrustedListener::~NaClTrustedListener() { |
@@ -35,10 +62,6 @@ bool NaClTrustedListener::OnMessageReceived(const IPC::Message& msg) { |
return false; |
} |
-void NaClTrustedListener::OnChannelError() { |
- channel_->Close(); |
-} |
- |
bool NaClTrustedListener::Send(IPC::Message* msg) { |
return channel_->Send(msg); |
} |