| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/ppapi_plugin/ppapi_thread.h" | 5 #include "chrome/ppapi_plugin/ppapi_thread.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "chrome/common/child_process.h" | 11 #include "chrome/common/child_process.h" |
| 12 #include "chrome/ppapi_plugin/plugin_process_dispatcher.h" |
| 12 #include "ipc/ipc_channel_handle.h" | 13 #include "ipc/ipc_channel_handle.h" |
| 13 #include "ipc/ipc_sync_channel.h" | 14 #include "ipc/ipc_sync_channel.h" |
| 14 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
| 15 #include "ppapi/c/ppp.h" | 16 #include "ppapi/c/ppp.h" |
| 16 #include "ppapi/proxy/plugin_dispatcher.h" | |
| 17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
| 18 | 18 |
| 19 PpapiThread::PpapiThread() | 19 PpapiThread::PpapiThread() |
| 20 : get_plugin_interface_(NULL), | 20 : get_plugin_interface_(NULL), |
| 21 local_pp_module_( | 21 local_pp_module_( |
| 22 base::RandInt(0, std::numeric_limits<PP_Module>::max())) { | 22 base::RandInt(0, std::numeric_limits<PP_Module>::max())) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 PpapiThread::~PpapiThread() { | 25 PpapiThread::~PpapiThread() { |
| 26 if (library_.is_valid()) { | 26 if (library_.is_valid()) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); | 90 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); | 94 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle, | 97 bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle, |
| 98 int renderer_id, | 98 int renderer_id, |
| 99 IPC::ChannelHandle* handle) { | 99 IPC::ChannelHandle* handle) { |
| 100 pp::proxy::PluginDispatcher* dispatcher = new pp::proxy::PluginDispatcher( | 100 PluginProcessDispatcher* dispatcher = new PluginProcessDispatcher( |
| 101 host_process_handle, get_plugin_interface_); | 101 host_process_handle, get_plugin_interface_); |
| 102 | 102 |
| 103 IPC::ChannelHandle plugin_handle; | 103 IPC::ChannelHandle plugin_handle; |
| 104 plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(), | 104 plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(), |
| 105 renderer_id); | 105 renderer_id); |
| 106 if (!dispatcher->InitWithChannel( | 106 if (!dispatcher->InitWithChannel( |
| 107 ChildProcess::current()->io_message_loop(), | 107 ChildProcess::current()->io_message_loop(), |
| 108 plugin_handle, false, | 108 plugin_handle, false, |
| 109 ChildProcess::current()->GetShutDownEvent())) | 109 ChildProcess::current()->GetShutDownEvent())) |
| 110 return false; | 110 return false; |
| 111 | 111 |
| 112 handle->name = plugin_handle.name; | 112 handle->name = plugin_handle.name; |
| 113 #if defined(OS_POSIX) | 113 #if defined(OS_POSIX) |
| 114 // On POSIX, pass the renderer-side FD. | 114 // On POSIX, pass the renderer-side FD. |
| 115 handle->socket = base::FileDescriptor(dispatcher->GetRendererFD(), false); | 115 handle->socket = base::FileDescriptor(dispatcher->GetRendererFD(), false); |
| 116 #endif | 116 #endif |
| 117 | 117 |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| 120 | 120 |
| OLD | NEW |