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

Unified Diff: chrome/nacl/nacl_ipc_adapter.cc

Issue 10912011: Change NaCl IPC PPAPI proxy startup to support a NaCl-Browser process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | « chrome/browser/renderer_host/chrome_render_message_filter.h ('k') | chrome/nacl/nacl_listener.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/nacl/nacl_ipc_adapter.cc
===================================================================
--- chrome/nacl/nacl_ipc_adapter.cc (revision 154143)
+++ chrome/nacl/nacl_ipc_adapter.cc (working copy)
@@ -89,9 +89,9 @@
delete channel;
}
-void WriteFileDescriptor(int handle_index,
- const ppapi::proxy::SerializedHandle& handle,
- IPC::Message* message) {
+void WriteHandle(int handle_index,
+ const ppapi::proxy::SerializedHandle& handle,
+ IPC::Message* message) {
ppapi::proxy::SerializedHandle::WriteHeader(handle.header(), message);
// Now write the handle itself in POSIX style.
@@ -108,7 +108,7 @@
Handles* handles, IPC::Message* msg, int* handle_index) {
handles->push_back(handle);
if (msg)
- WriteFileDescriptor((*handle_index)++, handle, msg);
+ WriteHandle((*handle_index)++, handle, msg);
}
// This overload is to catch all types other than SerializedHandle. On Windows,
@@ -434,6 +434,7 @@
return false; \
break; \
}
+
bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) {
{
base::AutoLock lock(lock_);
@@ -443,12 +444,21 @@
// Pointer to the "new" message we will rewrite on Windows. On posix, this
// isn't necessary, so it will stay NULL.
IPC::Message* new_msg_ptr = NULL;
+ IPC::Message new_msg(msg.routing_id(), msg.type(), msg.priority());
#if defined(OS_WIN)
- IPC::Message new_msg(msg.routing_id(), msg.type(), msg.priority());
new_msg_ptr = &new_msg;
+#else
+ // Even on POSIX, we have to rewrite messages to create channels, because
+ // these contain a handle with an invalid (place holder) descriptor. The
+ // message sending code sees this and doesn't pass the descriptor over
+ // correctly.
+ if (msg.type() == PpapiMsg_CreateNaClChannel::ID)
+ new_msg_ptr = &new_msg;
#endif
+
Handles handles;
switch (msg.type()) {
+ CASE_FOR_MESSAGE(PpapiMsg_CreateNaClChannel)
CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated)
CASE_FOR_MESSAGE(PpapiMsg_PPBAudioInput_OpenACK)
case IPC_REPLY_ID: {
@@ -502,10 +512,33 @@
iter->descriptor().fd
#endif
));
+ break;
}
+ case ppapi::proxy::SerializedHandle::CHANNEL_HANDLE: {
+ // Check that this came from a PpapiMsg_CreateNaClChannel message.
+ // This code here is only appropriate for that message.
+ DCHECK(msg.type() == PpapiMsg_CreateNaClChannel::ID);
+ IPC::ChannelHandle channel_handle =
+ IPC::Channel::GenerateVerifiedChannelID("nacl");
+ scoped_refptr<NaClIPCAdapter> ipc_adapter(
+ new NaClIPCAdapter(channel_handle, task_runner_));
+#if defined(OS_POSIX)
+ channel_handle.socket = base::FileDescriptor(
+ ipc_adapter->TakeClientFileDescriptor(), true);
+#endif
+ nacl_desc.reset(factory.MakeGeneric(ipc_adapter->MakeNaClDesc()));
+ // Send back a message that the channel was created.
+ scoped_ptr<IPC::Message> response(
+ new PpapiHostMsg_ChannelCreated(channel_handle));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&NaClIPCAdapter::SendMessageOnIOThread, this,
+ base::Passed(&response)));
+ break;
+ }
case ppapi::proxy::SerializedHandle::INVALID: {
// Nothing to do. TODO(dmichael): Should we log this? Or is it
// sometimes okay to pass an INVALID handle?
+ break;
}
// No default, so the compiler will warn us if new types get added.
}
« no previous file with comments | « chrome/browser/renderer_host/chrome_render_message_filter.h ('k') | chrome/nacl/nacl_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698