| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 PpapiPluginProcessHost::~PpapiPluginProcessHost() { | 22 PpapiPluginProcessHost::~PpapiPluginProcessHost() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void PpapiPluginProcessHost::Init(const FilePath& path, | 25 void PpapiPluginProcessHost::Init(const FilePath& path, |
| 26 IPC::Message* reply_msg) { | 26 IPC::Message* reply_msg) { |
| 27 plugin_path_ = path; | 27 plugin_path_ = path; |
| 28 reply_msg_.reset(reply_msg); | 28 reply_msg_.reset(reply_msg); |
| 29 | 29 |
| 30 if (!CreateChannel()) { | 30 if (!CreateChannel()) { |
| 31 ReplyToRenderer(NULL, IPC::ChannelHandle()); | 31 ReplyToRenderer(base::kNullProcessHandle, IPC::ChannelHandle()); |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 | 34 |
| 35 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 35 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 36 CommandLine::StringType plugin_launcher = | 36 CommandLine::StringType plugin_launcher = |
| 37 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher); | 37 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher); |
| 38 | 38 |
| 39 FilePath exe_path = ChildProcessHost::GetChildPath(plugin_launcher.empty()); | 39 FilePath exe_path = ChildProcessHost::GetChildPath(plugin_launcher.empty()); |
| 40 if (exe_path.empty()) { | 40 if (exe_path.empty()) { |
| 41 ReplyToRenderer(NULL, IPC::ChannelHandle()); | 41 ReplyToRenderer(base::kNullProcessHandle, IPC::ChannelHandle()); |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 | 44 |
| 45 CommandLine* cmd_line = new CommandLine(exe_path); | 45 CommandLine* cmd_line = new CommandLine(exe_path); |
| 46 cmd_line->AppendSwitchASCII(switches::kProcessType, | 46 cmd_line->AppendSwitchASCII(switches::kProcessType, |
| 47 switches::kPpapiPluginProcess); | 47 switches::kPpapiPluginProcess); |
| 48 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); | 48 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); |
| 49 | 49 |
| 50 if (!plugin_launcher.empty()) | 50 if (!plugin_launcher.empty()) |
| 51 cmd_line->PrependWrapper(plugin_launcher); | 51 cmd_line->PrependWrapper(plugin_launcher); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 ::DuplicateHandle(::GetCurrentProcess(), filter_->peer_handle(), | 85 ::DuplicateHandle(::GetCurrentProcess(), filter_->peer_handle(), |
| 86 GetChildProcessHandle(), &plugins_renderer_handle, | 86 GetChildProcessHandle(), &plugins_renderer_handle, |
| 87 0, FALSE, DUPLICATE_SAME_ACCESS); | 87 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 88 #elif defined(OS_POSIX) | 88 #elif defined(OS_POSIX) |
| 89 base::ProcessHandle plugins_renderer_handle = filter_->peer_handle(); | 89 base::ProcessHandle plugins_renderer_handle = filter_->peer_handle(); |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin( | 92 PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin( |
| 93 plugins_renderer_handle, plugin_path_, filter_->render_process_id()); | 93 plugins_renderer_handle, plugin_path_, filter_->render_process_id()); |
| 94 if (!Send(msg)) // Just send an empty handle on failure. | 94 if (!Send(msg)) // Just send an empty handle on failure. |
| 95 ReplyToRenderer(NULL, IPC::ChannelHandle()); | 95 ReplyToRenderer(base::kNullProcessHandle, IPC::ChannelHandle()); |
| 96 // This function will result in OnChannelCreated getting called to finish. | 96 // This function will result in OnChannelCreated getting called to finish. |
| 97 } | 97 } |
| 98 | 98 |
| 99 void PpapiPluginProcessHost::OnChannelError() { | 99 void PpapiPluginProcessHost::OnChannelError() { |
| 100 if (reply_msg_.get()) | 100 if (reply_msg_.get()) |
| 101 ReplyToRenderer(NULL, IPC::ChannelHandle()); | 101 ReplyToRenderer(base::kNullProcessHandle, IPC::ChannelHandle()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void PpapiPluginProcessHost::OnPluginLoaded( | 104 void PpapiPluginProcessHost::OnPluginLoaded( |
| 105 const IPC::ChannelHandle& channel_handle) { | 105 const IPC::ChannelHandle& channel_handle) { |
| 106 base::ProcessHandle plugin_process = GetChildProcessHandle(); | 106 base::ProcessHandle plugin_process = GetChildProcessHandle(); |
| 107 #if defined(OS_WIN) | 107 #if defined(OS_WIN) |
| 108 base::ProcessHandle renderers_plugin_handle = NULL; | 108 base::ProcessHandle renderers_plugin_handle = NULL; |
| 109 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, | 109 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, |
| 110 filter_->peer_handle(), &renderers_plugin_handle, | 110 filter_->peer_handle(), &renderers_plugin_handle, |
| 111 0, FALSE, DUPLICATE_SAME_ACCESS); | 111 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 112 #elif defined(OS_POSIX) | 112 #elif defined(OS_POSIX) |
| 113 // Don't need to duplicate anything on POSIX since it's just a PID. | 113 // Don't need to duplicate anything on POSIX since it's just a PID. |
| 114 base::ProcessHandle renderers_plugin_handle = plugin_process; | 114 base::ProcessHandle renderers_plugin_handle = plugin_process; |
| 115 #endif | 115 #endif |
| 116 ReplyToRenderer(renderers_plugin_handle, channel_handle); | 116 ReplyToRenderer(renderers_plugin_handle, channel_handle); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void PpapiPluginProcessHost::ReplyToRenderer( | 119 void PpapiPluginProcessHost::ReplyToRenderer( |
| 120 base::ProcessHandle plugin_handle, | 120 base::ProcessHandle plugin_handle, |
| 121 const IPC::ChannelHandle& channel_handle) { | 121 const IPC::ChannelHandle& channel_handle) { |
| 122 DCHECK(reply_msg_.get()); | 122 DCHECK(reply_msg_.get()); |
| 123 ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(reply_msg_.get(), | 123 ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(reply_msg_.get(), |
| 124 plugin_handle, | 124 plugin_handle, |
| 125 channel_handle); | 125 channel_handle); |
| 126 filter_->Send(reply_msg_.release()); | 126 filter_->Send(reply_msg_.release()); |
| 127 } | 127 } |
| OLD | NEW |