Chromium Code Reviews| 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 "components/nacl/browser/nacl_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 // The process failed to launch for some reason. | 329 // The process failed to launch for some reason. |
| 330 // Don't keep the renderer hanging. | 330 // Don't keep the renderer hanging. |
| 331 reply_msg_->set_reply_error(); | 331 reply_msg_->set_reply_error(); |
| 332 nacl_host_message_filter_->Send(reply_msg_); | 332 nacl_host_message_filter_->Send(reply_msg_); |
| 333 } | 333 } |
| 334 #if defined(OS_WIN) | 334 #if defined(OS_WIN) |
| 335 if (process_launched_by_broker_) { | 335 if (process_launched_by_broker_) { |
| 336 NaClBrokerService::GetInstance()->OnLoaderDied(); | 336 NaClBrokerService::GetInstance()->OnLoaderDied(); |
| 337 } | 337 } |
| 338 #endif | 338 #endif |
| 339 | |
| 340 if (base::SharedMemory::IsHandleValid(crash_info_shmem_plugin_handle_)) | |
| 341 base::SharedMemory::CloseHandle(crash_info_shmem_plugin_handle_); | |
|
Mark Seaborn
2014/08/17 20:13:45
Is this a handle in another process's handle names
teravest
2014/08/18 16:16:26
Good point. I've changed this to only share the sh
| |
| 342 if (base::SharedMemory::IsHandleValid(crash_info_shmem_renderer_handle_)) | |
| 343 base::SharedMemory::CloseHandle(crash_info_shmem_renderer_handle_); | |
| 339 } | 344 } |
| 340 | 345 |
| 341 void NaClProcessHost::OnProcessCrashed(int exit_status) { | 346 void NaClProcessHost::OnProcessCrashed(int exit_status) { |
| 342 if (enable_crash_throttling_ && | 347 if (enable_crash_throttling_ && |
| 343 !CommandLine::ForCurrentProcess()->HasSwitch( | 348 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 344 switches::kDisablePnaclCrashThrottling)) { | 349 switches::kDisablePnaclCrashThrottling)) { |
| 345 NaClBrowser::GetInstance()->OnProcessCrashed(); | 350 NaClBrowser::GetInstance()->OnProcessCrashed(); |
| 346 } | 351 } |
| 347 } | 352 } |
| 348 | 353 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 SendErrorToRenderer("NaClSocketPair() failed"); | 472 SendErrorToRenderer("NaClSocketPair() failed"); |
| 468 delete this; | 473 delete this; |
| 469 return; | 474 return; |
| 470 } | 475 } |
| 471 internal_->socket_for_renderer = pair[0]; | 476 internal_->socket_for_renderer = pair[0]; |
| 472 internal_->socket_for_sel_ldr = pair[1]; | 477 internal_->socket_for_sel_ldr = pair[1]; |
| 473 SetCloseOnExec(pair[0]); | 478 SetCloseOnExec(pair[0]); |
| 474 SetCloseOnExec(pair[1]); | 479 SetCloseOnExec(pair[1]); |
| 475 } | 480 } |
| 476 | 481 |
| 482 // Create a shared memory region that the renderer and plugin share for | |
| 483 // reporting crash information. | |
| 484 { | |
| 485 base::SharedMemory crash_info_shmem; | |
| 486 if (crash_info_shmem.CreateAnonymous(kNaClCrashInfoShmemSize)) { | |
| 487 crash_info_shmem.ShareToProcess(process_->GetData().handle, | |
|
Mark Seaborn
2014/08/17 20:13:45
Should this check for an error?
teravest
2014/08/18 16:16:26
I've added error checking at the ShareToProcess()
| |
| 488 &crash_info_shmem_plugin_handle_); | |
| 489 crash_info_shmem.ShareToProcess(nacl_host_message_filter_->PeerHandle(), | |
| 490 &crash_info_shmem_renderer_handle_); | |
| 491 } | |
| 492 } | |
| 493 | |
| 477 // Launch the process | 494 // Launch the process |
| 478 if (!LaunchSelLdr()) { | 495 if (!LaunchSelLdr()) { |
| 479 delete this; | 496 delete this; |
| 480 } | 497 } |
| 481 } | 498 } |
| 482 | 499 |
| 483 void NaClProcessHost::OnChannelConnected(int32 peer_pid) { | 500 void NaClProcessHost::OnChannelConnected(int32 peer_pid) { |
| 484 if (!CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 501 if (!CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 485 switches::kNaClGdb).empty()) { | 502 switches::kNaClGdb).empty()) { |
| 486 LaunchNaClGdb(); | 503 LaunchNaClGdb(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 imc_handle_for_renderer = imc_handle; | 752 imc_handle_for_renderer = imc_handle; |
| 736 #endif | 753 #endif |
| 737 | 754 |
| 738 const ChildProcessData& data = process_->GetData(); | 755 const ChildProcessData& data = process_->GetData(); |
| 739 SendMessageToRenderer( | 756 SendMessageToRenderer( |
| 740 NaClLaunchResult(imc_handle_for_renderer, | 757 NaClLaunchResult(imc_handle_for_renderer, |
| 741 ppapi_channel_handle, | 758 ppapi_channel_handle, |
| 742 trusted_channel_handle, | 759 trusted_channel_handle, |
| 743 manifest_service_channel_handle, | 760 manifest_service_channel_handle, |
| 744 base::GetProcId(data.handle), | 761 base::GetProcId(data.handle), |
| 745 data.id), | 762 data.id, |
| 763 crash_info_shmem_renderer_handle_), | |
| 746 std::string() /* error_message */); | 764 std::string() /* error_message */); |
| 747 internal_->socket_for_renderer = NACL_INVALID_HANDLE; | 765 internal_->socket_for_renderer = NACL_INVALID_HANDLE; |
| 766 crash_info_shmem_renderer_handle_ = base::SharedMemory::NULLHandle(); | |
| 748 return true; | 767 return true; |
| 749 } | 768 } |
| 750 | 769 |
| 751 void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) { | 770 void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) { |
| 752 LOG(ERROR) << "NaCl process launch failed: " << error_message; | 771 LOG(ERROR) << "NaCl process launch failed: " << error_message; |
| 753 SendMessageToRenderer(NaClLaunchResult(), error_message); | 772 SendMessageToRenderer(NaClLaunchResult(), error_message); |
| 754 } | 773 } |
| 755 | 774 |
| 756 void NaClProcessHost::SendMessageToRenderer( | 775 void NaClProcessHost::SendMessageToRenderer( |
| 757 const NaClLaunchResult& result, | 776 const NaClLaunchResult& result, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 #endif | 912 #endif |
| 894 } | 913 } |
| 895 | 914 |
| 896 if (!uses_nonsfi_mode_) { | 915 if (!uses_nonsfi_mode_) { |
| 897 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; | 916 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; |
| 898 } | 917 } |
| 899 | 918 |
| 900 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), | 919 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), |
| 901 process_->GetData().handle); | 920 process_->GetData().handle); |
| 902 | 921 |
| 922 params.crash_info_shmem_handle = crash_info_shmem_plugin_handle_; | |
| 923 crash_info_shmem_plugin_handle_ = base::SharedMemory::NULLHandle(); | |
| 924 | |
| 903 process_->Send(new NaClProcessMsg_Start(params)); | 925 process_->Send(new NaClProcessMsg_Start(params)); |
| 904 return true; | 926 return true; |
| 905 } | 927 } |
| 906 | 928 |
| 907 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is | 929 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is |
| 908 // received. | 930 // received. |
| 909 void NaClProcessHost::OnPpapiChannelsCreated( | 931 void NaClProcessHost::OnPpapiChannelsCreated( |
| 910 const IPC::ChannelHandle& browser_channel_handle, | 932 const IPC::ChannelHandle& browser_channel_handle, |
| 911 const IPC::ChannelHandle& ppapi_renderer_channel_handle, | 933 const IPC::ChannelHandle& ppapi_renderer_channel_handle, |
| 912 const IPC::ChannelHandle& trusted_renderer_channel_handle, | 934 const IPC::ChannelHandle& trusted_renderer_channel_handle, |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 process_handle.Take(), info, | 1169 process_handle.Take(), info, |
| 1148 base::MessageLoopProxy::current(), | 1170 base::MessageLoopProxy::current(), |
| 1149 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1171 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1150 weak_factory_.GetWeakPtr())); | 1172 weak_factory_.GetWeakPtr())); |
| 1151 return true; | 1173 return true; |
| 1152 } | 1174 } |
| 1153 } | 1175 } |
| 1154 #endif | 1176 #endif |
| 1155 | 1177 |
| 1156 } // namespace nacl | 1178 } // namespace nacl |
| OLD | NEW |