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 633bace8b53ab92d7133240f4ae2bab9262345c8..c038521962e93ff8c709dccca2316892547ed7d0 100644 |
--- a/components/nacl/browser/nacl_process_host.cc |
+++ b/components/nacl/browser/nacl_process_host.cc |
@@ -255,17 +255,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. |
Mark Seaborn
2016/10/12 00:57:24
It looks like this comment should apply to Windows
Sam McNally
2016/10/12 03:15:32
Done.
|
+ 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) |
Mark Seaborn
2016/10/12 00:57:24
This block shouldn't be necessary if "Only Channel
Sam McNally
2016/10/12 03:15:32
Done.
|
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 |