Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: components/nacl/browser/nacl_process_host.cc

Issue 2151153002: Use ChannelMojo for NaCl IRT channels in non-sfi mode. Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-nacl-channel-mojo
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/nacl/loader/nacl_listener.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | components/nacl/loader/nacl_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698