| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 #elif defined(OS_POSIX) | 277 #elif defined(OS_POSIX) |
| 278 use_zygote, | 278 use_zygote, |
| 279 base::EnvironmentVector(), | 279 base::EnvironmentVector(), |
| 280 #endif | 280 #endif |
| 281 cmd_line); | 281 cmd_line); |
| 282 return true; | 282 return true; |
| 283 } | 283 } |
| 284 | 284 |
| 285 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { | 285 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { |
| 286 base::ProcessHandle process_handle; | 286 base::ProcessHandle process_handle; |
| 287 int renderer_id; | 287 int renderer_child_id; |
| 288 client->GetPpapiChannelInfo(&process_handle, &renderer_id); | 288 client->GetPpapiChannelInfo(&process_handle, &renderer_child_id); |
| 289 | 289 |
| 290 // We can't send any sync messages from the browser because it might lead to | 290 // We can't send any sync messages from the browser because it might lead to |
| 291 // a hang. See the similar code in PluginProcessHost for more description. | 291 // a hang. See the similar code in PluginProcessHost for more description. |
| 292 PpapiMsg_CreateChannel* msg = new PpapiMsg_CreateChannel( | 292 PpapiMsg_CreateChannel* msg = new PpapiMsg_CreateChannel( |
| 293 renderer_id, client->OffTheRecord()); | 293 base::GetProcId(process_handle), renderer_child_id, |
| 294 client->OffTheRecord()); |
| 294 msg->set_unblock(true); | 295 msg->set_unblock(true); |
| 295 if (Send(msg)) { | 296 if (Send(msg)) { |
| 296 sent_requests_.push(client); | 297 sent_requests_.push(client); |
| 297 } else { | 298 } else { |
| 298 client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); | 299 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); |
| 299 } | 300 } |
| 300 } | 301 } |
| 301 | 302 |
| 302 void PpapiPluginProcessHost::OnProcessLaunched() { | 303 void PpapiPluginProcessHost::OnProcessLaunched() { |
| 303 host_impl_->set_plugin_process_handle(process_->GetHandle()); | 304 host_impl_->set_plugin_process_handle(process_->GetHandle()); |
| 304 } | 305 } |
| 305 | 306 |
| 306 void PpapiPluginProcessHost::OnProcessCrashed(int exit_code) { | 307 void PpapiPluginProcessHost::OnProcessCrashed(int exit_code) { |
| 307 PluginServiceImpl::GetInstance()->RegisterPluginCrash(plugin_path_); | 308 PluginServiceImpl::GetInstance()->RegisterPluginCrash(plugin_path_); |
| 308 } | 309 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // plugin since they have their own channels which will go into the error | 341 // plugin since they have their own channels which will go into the error |
| 341 // state at the same time. Instead, we just need to notify any renderers | 342 // state at the same time. Instead, we just need to notify any renderers |
| 342 // that have requested a connection but have not yet received one. | 343 // that have requested a connection but have not yet received one. |
| 343 CancelRequests(); | 344 CancelRequests(); |
| 344 } | 345 } |
| 345 | 346 |
| 346 void PpapiPluginProcessHost::CancelRequests() { | 347 void PpapiPluginProcessHost::CancelRequests() { |
| 347 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") | 348 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") |
| 348 << "CancelRequests()"; | 349 << "CancelRequests()"; |
| 349 for (size_t i = 0; i < pending_requests_.size(); i++) { | 350 for (size_t i = 0; i < pending_requests_.size(); i++) { |
| 350 pending_requests_[i]->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); | 351 pending_requests_[i]->OnPpapiChannelOpened(IPC::ChannelHandle(), |
| 352 base::kNullProcessId, 0); |
| 351 } | 353 } |
| 352 pending_requests_.clear(); | 354 pending_requests_.clear(); |
| 353 | 355 |
| 354 while (!sent_requests_.empty()) { | 356 while (!sent_requests_.empty()) { |
| 355 sent_requests_.front()->OnPpapiChannelOpened(IPC::ChannelHandle(), 0); | 357 sent_requests_.front()->OnPpapiChannelOpened(IPC::ChannelHandle(), |
| 358 base::kNullProcessId, 0); |
| 356 sent_requests_.pop(); | 359 sent_requests_.pop(); |
| 357 } | 360 } |
| 358 } | 361 } |
| 359 | 362 |
| 360 // Called when a new plugin <--> renderer channel has been created. | 363 // Called when a new plugin <--> renderer channel has been created. |
| 361 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( | 364 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( |
| 362 const IPC::ChannelHandle& channel_handle) { | 365 const IPC::ChannelHandle& channel_handle) { |
| 363 if (sent_requests_.empty()) | 366 if (sent_requests_.empty()) |
| 364 return; | 367 return; |
| 365 | 368 |
| 366 // All requests should be processed FIFO, so the next item in the | 369 // All requests should be processed FIFO, so the next item in the |
| 367 // sent_requests_ queue should be the one that the plugin just created. | 370 // sent_requests_ queue should be the one that the plugin just created. |
| 368 Client* client = sent_requests_.front(); | 371 Client* client = sent_requests_.front(); |
| 369 sent_requests_.pop(); | 372 sent_requests_.pop(); |
| 370 | 373 |
| 371 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); | 374 const ChildProcessData& data = process_->GetData(); |
| 375 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), |
| 376 data.id); |
| 372 } | 377 } |
| 373 | 378 |
| 374 } // namespace content | 379 } // namespace content |
| OLD | NEW |