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

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

Issue 2301103003: Use ChannelMojo for NaCl PPAPI channels. (Closed)
Patch Set: Created 4 years, 2 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_ipc_adapter.h » ('j') | components/nacl/loader/nacl_listener.cc » ('J')
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 7f23abe40968d1c33c9b072d797382ea5849cd61..df6018b162810f99527fe9f9a96ace5e69bb0f08 100644
--- a/components/nacl/browser/nacl_process_host.cc
+++ b/components/nacl/browser/nacl_process_host.cc
@@ -239,13 +239,16 @@ class NaClProcessHost::ScopedChannelHandle {
return result;
}
- void reset(const IPC::ChannelHandle& handle = IPC::ChannelHandle()) {
+ void reset() {
+ CloseIfNecessary();
+ handle_ = IPC::ChannelHandle();
+ }
+
+ void reset(const IPC::ChannelHandle& handle) {
DCHECK(IsSupportedHandle(handle));
-#if defined(OS_POSIX)
// Following the manner of base::ScopedGeneric, we do not support
// reset() with same handle for simplicity of the implementation.
- CHECK(handle.socket.fd == -1 || handle.socket.fd != handle_.socket.fd);
-#endif
+ CHECK(handle.mojo_handle.value() != handle_.mojo_handle.value());
CloseIfNecessary();
handle_ = handle;
}
@@ -254,23 +257,13 @@ 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)
- // 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
+ // Only ChannelMojo is supported.
+ return handle.mojo_handle.is_valid();
}
void CloseIfNecessary() {
-#if defined(OS_POSIX)
- if (handle_.socket.auto_close) {
- // Defer closing task to the ScopedFD.
- base::ScopedFD(handle_.socket.fd);
- }
-#endif
+ if (handle_.mojo_handle.is_valid())
+ handle_.mojo_handle.Close();
}
IPC::ChannelHandle handle_;
@@ -1033,17 +1026,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_ipc_adapter.h » ('j') | components/nacl/loader/nacl_listener.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698