| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/ppapi_plugin_process_host.h" | 5 #include "chrome/browser/ppapi_plugin_process_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "chrome/browser/renderer_host/render_message_filter.h" | 10 #include "chrome/browser/renderer_host/render_message_filter.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
| 13 #include "ipc/ipc_channel_handle.h" | |
| 14 #include "ipc/ipc_switches.h" | 13 #include "ipc/ipc_switches.h" |
| 15 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
| 16 | 15 |
| 17 PpapiPluginProcessHost::PpapiPluginProcessHost(RenderMessageFilter* filter) | 16 PpapiPluginProcessHost::PpapiPluginProcessHost(RenderMessageFilter* filter) |
| 18 : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS, | 17 : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS, |
| 19 filter->resource_dispatcher_host()), | 18 filter->resource_dispatcher_host()), |
| 20 filter_(filter) { | 19 filter_(filter) { |
| 21 } | 20 } |
| 22 | 21 |
| 23 PpapiPluginProcessHost::~PpapiPluginProcessHost() { | 22 PpapiPluginProcessHost::~PpapiPluginProcessHost() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #elif defined(OS_POSIX) | 58 #elif defined(OS_POSIX) |
| 60 plugin_launcher.empty(), | 59 plugin_launcher.empty(), |
| 61 base::environment_vector(), | 60 base::environment_vector(), |
| 62 #endif | 61 #endif |
| 63 cmd_line); | 62 cmd_line); |
| 64 } | 63 } |
| 65 | 64 |
| 66 void PpapiPluginProcessHost::OnProcessLaunched() { | 65 void PpapiPluginProcessHost::OnProcessLaunched() { |
| 67 } | 66 } |
| 68 | 67 |
| 69 URLRequestContext* PpapiPluginProcessHost::GetRequestContext( | |
| 70 uint32 request_id, | |
| 71 const ViewHostMsg_Resource_Request& request_data) { | |
| 72 return NULL; | |
| 73 } | |
| 74 | |
| 75 void PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { | 68 void PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 76 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) | 69 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) |
| 77 IPC_MESSAGE_HANDLER(PpapiHostMsg_PluginLoaded, OnPluginLoaded) | 70 IPC_MESSAGE_HANDLER(PpapiHostMsg_PluginLoaded, OnPluginLoaded) |
| 78 IPC_MESSAGE_UNHANDLED_ERROR(); | 71 IPC_MESSAGE_UNHANDLED_ERROR(); |
| 79 IPC_END_MESSAGE_MAP() | 72 IPC_END_MESSAGE_MAP() |
| 80 } | 73 } |
| 81 | 74 |
| 82 void PpapiPluginProcessHost::OnChannelConnected(int32 peer_pid) { | 75 void PpapiPluginProcessHost::OnChannelConnected(int32 peer_pid) { |
| 83 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 84 base::ProcessHandle plugins_renderer_handle = NULL; | 77 base::ProcessHandle plugins_renderer_handle = NULL; |
| 85 ::DuplicateHandle(::GetCurrentProcess(), filter_->handle(), | 78 ::DuplicateHandle(::GetCurrentProcess(), filter_->peer_handle(), |
| 86 GetChildProcessHandle(), &plugins_renderer_handle, | 79 GetChildProcessHandle(), &plugins_renderer_handle, |
| 87 0, FALSE, DUPLICATE_SAME_ACCESS); | 80 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 88 #elif defined(OS_POSIX) | 81 #elif defined(OS_POSIX) |
| 89 base::ProcessHandle plugins_renderer_handle = filter_->handle(); | 82 base::ProcessHandle plugins_renderer_handle = filter_->peer_handle(); |
| 90 #endif | 83 #endif |
| 91 | 84 |
| 92 PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin(plugins_renderer_handle, | 85 PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin( |
| 93 plugin_path_, | 86 plugins_renderer_handle, plugin_path_, filter_->render_process_id()); |
| 94 filter_->id()); | |
| 95 if (!Send(msg)) // Just send an empty handle on failure. | 87 if (!Send(msg)) // Just send an empty handle on failure. |
| 96 ReplyToRenderer(NULL, IPC::ChannelHandle()); | 88 ReplyToRenderer(NULL, IPC::ChannelHandle()); |
| 97 // This function will result in OnChannelCreated getting called to finish. | 89 // This function will result in OnChannelCreated getting called to finish. |
| 98 } | 90 } |
| 99 | 91 |
| 100 void PpapiPluginProcessHost::OnChannelError() { | 92 void PpapiPluginProcessHost::OnChannelError() { |
| 101 if (reply_msg_.get()) | 93 if (reply_msg_.get()) |
| 102 ReplyToRenderer(NULL, IPC::ChannelHandle()); | 94 ReplyToRenderer(NULL, IPC::ChannelHandle()); |
| 103 } | 95 } |
| 104 | 96 |
| 105 void PpapiPluginProcessHost::OnPluginLoaded( | 97 void PpapiPluginProcessHost::OnPluginLoaded( |
| 106 const IPC::ChannelHandle& channel_handle) { | 98 const IPC::ChannelHandle& channel_handle) { |
| 107 base::ProcessHandle plugin_process = GetChildProcessHandle(); | 99 base::ProcessHandle plugin_process = GetChildProcessHandle(); |
| 108 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
| 109 base::ProcessHandle renderers_plugin_handle = NULL; | 101 base::ProcessHandle renderers_plugin_handle = NULL; |
| 110 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, | 102 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, |
| 111 filter_->handle(), &renderers_plugin_handle, | 103 filter_->peer_handle(), &renderers_plugin_handle, |
| 112 0, FALSE, DUPLICATE_SAME_ACCESS); | 104 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 113 #elif defined(OS_POSIX) | 105 #elif defined(OS_POSIX) |
| 114 // Don't need to duplicate anything on POSIX since it's just a PID. | 106 // Don't need to duplicate anything on POSIX since it's just a PID. |
| 115 base::ProcessHandle renderers_plugin_handle = plugin_process; | 107 base::ProcessHandle renderers_plugin_handle = plugin_process; |
| 116 #endif | 108 #endif |
| 117 ReplyToRenderer(renderers_plugin_handle, channel_handle); | 109 ReplyToRenderer(renderers_plugin_handle, channel_handle); |
| 118 } | 110 } |
| 119 | 111 |
| 120 void PpapiPluginProcessHost::ReplyToRenderer( | 112 void PpapiPluginProcessHost::ReplyToRenderer( |
| 121 base::ProcessHandle plugin_handle, | 113 base::ProcessHandle plugin_handle, |
| 122 const IPC::ChannelHandle& channel_handle) { | 114 const IPC::ChannelHandle& channel_handle) { |
| 123 DCHECK(reply_msg_.get()); | 115 DCHECK(reply_msg_.get()); |
| 124 ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(reply_msg_.get(), | 116 ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(reply_msg_.get(), |
| 125 plugin_handle, | 117 plugin_handle, |
| 126 channel_handle); | 118 channel_handle); |
| 127 filter_->Send(reply_msg_.release()); | 119 filter_->Send(reply_msg_.release()); |
| 128 } | 120 } |
| OLD | NEW |