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> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 use_zygote, | 193 use_zygote, |
194 base::EnvironmentVector(), | 194 base::EnvironmentVector(), |
195 #endif | 195 #endif |
196 cmd_line); | 196 cmd_line); |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { | 200 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { |
201 base::ProcessHandle process_handle; | 201 base::ProcessHandle process_handle; |
202 int renderer_id; | 202 int renderer_id; |
203 client->GetChannelInfo(&process_handle, &renderer_id); | 203 client->GetPpapiChannelInfo(&process_handle, &renderer_id); |
204 | 204 |
205 // We can't send any sync messages from the browser because it might lead to | 205 // We can't send any sync messages from the browser because it might lead to |
206 // a hang. See the similar code in PluginProcessHost for more description. | 206 // a hang. See the similar code in PluginProcessHost for more description. |
207 PpapiMsg_CreateChannel* msg = new PpapiMsg_CreateChannel(process_handle, | 207 PpapiMsg_CreateChannel* msg = new PpapiMsg_CreateChannel(process_handle, |
208 renderer_id); | 208 renderer_id); |
209 msg->set_unblock(true); | 209 msg->set_unblock(true); |
210 if (Send(msg)) | 210 if (Send(msg)) { |
211 sent_requests_.push(client); | 211 sent_requests_.push(client); |
212 else | 212 } else { |
213 client->OnChannelOpened(base::kNullProcessHandle, IPC::ChannelHandle()); | 213 client->OnPpapiChannelOpened(base::kNullProcessHandle, |
| 214 IPC::ChannelHandle()); |
| 215 } |
214 } | 216 } |
215 | 217 |
216 void PpapiPluginProcessHost::OnProcessLaunched() { | 218 void PpapiPluginProcessHost::OnProcessLaunched() { |
217 } | 219 } |
218 | 220 |
219 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { | 221 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { |
220 bool handled = true; | 222 bool handled = true; |
221 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) | 223 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) |
222 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, | 224 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, |
223 OnRendererPluginChannelCreated) | 225 OnRendererPluginChannelCreated) |
(...skipping 25 matching lines...) Expand all Loading... |
249 // plugin since they have their own channels which will go into the error | 251 // plugin since they have their own channels which will go into the error |
250 // state at the same time. Instead, we just need to notify any renderers | 252 // state at the same time. Instead, we just need to notify any renderers |
251 // that have requested a connection but have not yet received one. | 253 // that have requested a connection but have not yet received one. |
252 CancelRequests(); | 254 CancelRequests(); |
253 } | 255 } |
254 | 256 |
255 void PpapiPluginProcessHost::CancelRequests() { | 257 void PpapiPluginProcessHost::CancelRequests() { |
256 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") | 258 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") |
257 << "CancelRequests()"; | 259 << "CancelRequests()"; |
258 for (size_t i = 0; i < pending_requests_.size(); i++) { | 260 for (size_t i = 0; i < pending_requests_.size(); i++) { |
259 pending_requests_[i]->OnChannelOpened(base::kNullProcessHandle, | 261 pending_requests_[i]->OnPpapiChannelOpened(base::kNullProcessHandle, |
260 IPC::ChannelHandle()); | 262 IPC::ChannelHandle()); |
261 } | 263 } |
262 pending_requests_.clear(); | 264 pending_requests_.clear(); |
263 | 265 |
264 while (!sent_requests_.empty()) { | 266 while (!sent_requests_.empty()) { |
265 sent_requests_.front()->OnChannelOpened(base::kNullProcessHandle, | 267 sent_requests_.front()->OnPpapiChannelOpened(base::kNullProcessHandle, |
266 IPC::ChannelHandle()); | 268 IPC::ChannelHandle()); |
267 sent_requests_.pop(); | 269 sent_requests_.pop(); |
268 } | 270 } |
269 } | 271 } |
270 | 272 |
271 // Called when a new plugin <--> renderer channel has been created. | 273 // Called when a new plugin <--> renderer channel has been created. |
272 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( | 274 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( |
273 const IPC::ChannelHandle& channel_handle) { | 275 const IPC::ChannelHandle& channel_handle) { |
274 if (sent_requests_.empty()) | 276 if (sent_requests_.empty()) |
275 return; | 277 return; |
276 | 278 |
277 // All requests should be processed FIFO, so the next item in the | 279 // All requests should be processed FIFO, so the next item in the |
278 // sent_requests_ queue should be the one that the plugin just created. | 280 // sent_requests_ queue should be the one that the plugin just created. |
279 Client* client = sent_requests_.front(); | 281 Client* client = sent_requests_.front(); |
280 sent_requests_.pop(); | 282 sent_requests_.pop(); |
281 | 283 |
282 // Prepare the handle to send to the renderer. | 284 // Prepare the handle to send to the renderer. |
283 base::ProcessHandle plugin_process = process_->GetHandle(); | 285 base::ProcessHandle plugin_process = process_->GetHandle(); |
284 #if defined(OS_WIN) | 286 #if defined(OS_WIN) |
285 base::ProcessHandle renderer_process; | 287 base::ProcessHandle renderer_process; |
286 int renderer_id; | 288 int renderer_id; |
287 client->GetChannelInfo(&renderer_process, &renderer_id); | 289 client->GetPpapiChannelInfo(&renderer_process, &renderer_id); |
288 | 290 |
289 base::ProcessHandle renderers_plugin_handle = NULL; | 291 base::ProcessHandle renderers_plugin_handle = NULL; |
290 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, | 292 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, |
291 renderer_process, &renderers_plugin_handle, | 293 renderer_process, &renderers_plugin_handle, |
292 0, FALSE, DUPLICATE_SAME_ACCESS); | 294 0, FALSE, DUPLICATE_SAME_ACCESS); |
293 #elif defined(OS_POSIX) | 295 #elif defined(OS_POSIX) |
294 // Don't need to duplicate anything on POSIX since it's just a PID. | 296 // Don't need to duplicate anything on POSIX since it's just a PID. |
295 base::ProcessHandle renderers_plugin_handle = plugin_process; | 297 base::ProcessHandle renderers_plugin_handle = plugin_process; |
296 #endif | 298 #endif |
297 | 299 |
298 client->OnChannelOpened(renderers_plugin_handle, channel_handle); | 300 client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle); |
299 } | 301 } |
OLD | NEW |