| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 10 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 11 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 12 #include "content/browser/browser_child_process_host_impl.h" | 14 #include "content/browser/browser_child_process_host_impl.h" |
| 13 #include "content/browser/plugin_service_impl.h" | 15 #include "content/browser/plugin_service_impl.h" |
| 14 #include "content/browser/renderer_host/render_message_filter.h" | 16 #include "content/browser/renderer_host/render_message_filter.h" |
| 15 #include "content/common/child_process_host_impl.h" | 17 #include "content/common/child_process_host_impl.h" |
| 16 #include "content/common/child_process_messages.h" | 18 #include "content/common/child_process_messages.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") | 65 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") |
| 64 << "~PpapiPluginProcessHost()"; | 66 << "~PpapiPluginProcessHost()"; |
| 65 CancelRequests(); | 67 CancelRequests(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( | 70 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( |
| 69 const content::PepperPluginInfo& info, | 71 const content::PepperPluginInfo& info, |
| 70 net::HostResolver* host_resolver) { | 72 net::HostResolver* host_resolver) { |
| 71 PpapiPluginProcessHost* plugin_host = | 73 PpapiPluginProcessHost* plugin_host = |
| 72 new PpapiPluginProcessHost(host_resolver); | 74 new PpapiPluginProcessHost(host_resolver); |
| 73 if(plugin_host->Init(info)) | 75 if (plugin_host->Init(info)) |
| 74 return plugin_host; | 76 return plugin_host; |
| 75 | 77 |
| 76 NOTREACHED(); // Init is not expected to fail. | 78 NOTREACHED(); // Init is not expected to fail. |
| 77 return NULL; | 79 return NULL; |
| 78 } | 80 } |
| 79 | 81 |
| 80 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost( | 82 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost( |
| 81 const content::PepperPluginInfo& info) { | 83 const content::PepperPluginInfo& info) { |
| 82 PpapiPluginProcessHost* plugin_host = | 84 PpapiPluginProcessHost* plugin_host = |
| 83 new PpapiPluginProcessHost(); | 85 new PpapiPluginProcessHost(); |
| 84 if(plugin_host->Init(info)) | 86 if (plugin_host->Init(info)) |
| 85 return plugin_host; | 87 return plugin_host; |
| 86 | 88 |
| 87 NOTREACHED(); // Init is not expected to fail. | 89 NOTREACHED(); // Init is not expected to fail. |
| 88 return NULL; | 90 return NULL; |
| 89 } | 91 } |
| 90 | 92 |
| 91 bool PpapiPluginProcessHost::Send(IPC::Message* message) { | 93 bool PpapiPluginProcessHost::Send(IPC::Message* message) { |
| 92 return process_->Send(message); | 94 return process_->Send(message); |
| 93 } | 95 } |
| 94 | 96 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // plugin launcher means we need to use another process instead of just | 184 // plugin launcher means we need to use another process instead of just |
| 183 // forking the zygote. | 185 // forking the zygote. |
| 184 #if defined(OS_POSIX) | 186 #if defined(OS_POSIX) |
| 185 bool use_zygote = !is_broker_ && plugin_launcher.empty() && info.is_sandboxed; | 187 bool use_zygote = !is_broker_ && plugin_launcher.empty() && info.is_sandboxed; |
| 186 #endif // OS_POSIX | 188 #endif // OS_POSIX |
| 187 process_->Launch( | 189 process_->Launch( |
| 188 #if defined(OS_WIN) | 190 #if defined(OS_WIN) |
| 189 FilePath(), | 191 FilePath(), |
| 190 #elif defined(OS_POSIX) | 192 #elif defined(OS_POSIX) |
| 191 use_zygote, | 193 use_zygote, |
| 192 base::environment_vector(), | 194 base::EnvironmentVector(), |
| 193 #endif | 195 #endif |
| 194 cmd_line); | 196 cmd_line); |
| 195 return true; | 197 return true; |
| 196 } | 198 } |
| 197 | 199 |
| 198 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { | 200 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { |
| 199 base::ProcessHandle process_handle; | 201 base::ProcessHandle process_handle; |
| 200 int renderer_id; | 202 int renderer_id; |
| 201 client->GetChannelInfo(&process_handle, &renderer_id); | 203 client->GetChannelInfo(&process_handle, &renderer_id); |
| 202 | 204 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, | 290 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, |
| 289 renderer_process, &renderers_plugin_handle, | 291 renderer_process, &renderers_plugin_handle, |
| 290 0, FALSE, DUPLICATE_SAME_ACCESS); | 292 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 291 #elif defined(OS_POSIX) | 293 #elif defined(OS_POSIX) |
| 292 // Don't need to duplicate anything on POSIX since it's just a PID. | 294 // Don't need to duplicate anything on POSIX since it's just a PID. |
| 293 base::ProcessHandle renderers_plugin_handle = plugin_process; | 295 base::ProcessHandle renderers_plugin_handle = plugin_process; |
| 294 #endif | 296 #endif |
| 295 | 297 |
| 296 client->OnChannelOpened(renderers_plugin_handle, channel_handle); | 298 client->OnChannelOpened(renderers_plugin_handle, channel_handle); |
| 297 } | 299 } |
| OLD | NEW |