Index: components/nacl/browser/nacl_process_host.cc |
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc |
index 4339d24dd56ed1f9c17ffba0a320f380285ca5e5..9a605a71da02ffc14cd687586cf0621d6db33da0 100644 |
--- a/components/nacl/browser/nacl_process_host.cc |
+++ b/components/nacl/browser/nacl_process_host.cc |
@@ -254,17 +254,23 @@ class NaClProcessHost::ScopedChannelHandle { |
// Returns true if the given handle is closable automatically by this |
// class. This function is just a helper for validation. |
static bool IsSupportedHandle(const IPC::ChannelHandle& handle) { |
-#if defined(OS_WIN) |
+#if defined(OS_POSIX) |
+ // Only ChannelMojo is supported. |
+ return handle.socket.fd == -1; |
+#elif defined(OS_WIN) |
// On Windows, it is not supported to marshal the |pipe.handle|. |
// In our case, we wrap a transferred ChannelHandle (or one to be |
// transferred) via IPC, so we can assume |handle.pipe.handle| is NULL. |
return handle.pipe.handle == NULL; |
#else |
return true; |
-#endif |
+#endif // defined(OS_POSIX) |
} |
void CloseIfNecessary() { |
+ if (handle_.mojo_handle.is_valid()) |
+ handle_.mojo_handle.Close(); |
+ |
#if defined(OS_POSIX) |
if (handle_.socket.auto_close) { |
// Defer closing task to the ScopedFD. |
@@ -1034,17 +1040,12 @@ bool NaClProcessHost::CreateChannelHandlePair( |
DCHECK(channel_handle1); |
DCHECK(channel_handle2); |
- int fd1 = -1; |
- int fd2 = -1; |
- if (!IPC::SocketPair(&fd1, &fd2)) { |
- return false; |
- } |
+ IPC::ChannelHandle handle1; |
+ IPC::ChannelHandle handle2; |
+ IPC::Channel::GenerateMojoChannelHandlePair("NaCl", &handle1, &handle2); |
+ channel_handle1->reset(handle1); |
+ channel_handle2->reset(handle2); |
- IPC::ChannelHandle handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
- handle.socket = base::FileDescriptor(fd1, true); |
- channel_handle1->reset(handle); |
- handle.socket = base::FileDescriptor(fd2, true); |
- channel_handle2->reset(handle); |
return true; |
} |
#endif |