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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 SendErrorToRenderer("NaClSocketPair() failed"); | 467 SendErrorToRenderer("NaClSocketPair() failed"); |
| 468 delete this; | 468 delete this; |
| 469 return; | 469 return; |
| 470 } | 470 } |
| 471 internal_->socket_for_renderer = pair[0]; | 471 internal_->socket_for_renderer = pair[0]; |
| 472 internal_->socket_for_sel_ldr = pair[1]; | 472 internal_->socket_for_sel_ldr = pair[1]; |
| 473 SetCloseOnExec(pair[0]); | 473 SetCloseOnExec(pair[0]); |
| 474 SetCloseOnExec(pair[1]); | 474 SetCloseOnExec(pair[1]); |
| 475 } | 475 } |
| 476 | 476 |
| 477 // Create a shared memory region that the renderer and plugin share for | |
| 478 // reporting crash information. | |
| 479 crash_info_shmem_.CreateAnonymous(kNaClCrashInfoShmemSize); | |
| 480 | |
| 477 // Launch the process | 481 // Launch the process |
| 478 if (!LaunchSelLdr()) { | 482 if (!LaunchSelLdr()) { |
| 479 delete this; | 483 delete this; |
| 480 } | 484 } |
| 481 } | 485 } |
| 482 | 486 |
| 483 void NaClProcessHost::OnChannelConnected(int32 peer_pid) { | 487 void NaClProcessHost::OnChannelConnected(int32 peer_pid) { |
| 484 if (!CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 488 if (!CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 485 switches::kNaClGdb).empty()) { | 489 switches::kNaClGdb).empty()) { |
| 486 LaunchNaClGdb(); | 490 LaunchNaClGdb(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 #else | 733 #else |
| 730 // No need to dup the imc_handle - we don't pass it anywhere else so | 734 // No need to dup the imc_handle - we don't pass it anywhere else so |
| 731 // it cannot be closed. | 735 // it cannot be closed. |
| 732 FileDescriptor imc_handle; | 736 FileDescriptor imc_handle; |
| 733 imc_handle.fd = internal_->socket_for_renderer; | 737 imc_handle.fd = internal_->socket_for_renderer; |
| 734 imc_handle.auto_close = true; | 738 imc_handle.auto_close = true; |
| 735 imc_handle_for_renderer = imc_handle; | 739 imc_handle_for_renderer = imc_handle; |
| 736 #endif | 740 #endif |
| 737 | 741 |
| 738 const ChildProcessData& data = process_->GetData(); | 742 const ChildProcessData& data = process_->GetData(); |
| 743 base::SharedMemoryHandle crash_info_shmem_renderer_handle; | |
| 744 if (!crash_info_shmem_.ShareToProcess(nacl_host_message_filter_->PeerHandle(), | |
| 745 &crash_info_shmem_renderer_handle)) { | |
| 746 SendErrorToRenderer("ShareToProcess() failed"); | |
| 747 return false; | |
| 748 } | |
|
Mark Seaborn
2014/08/18 19:04:08
How about doing
crash_info_shmem_.Close()
to unr
teravest
2014/08/19 19:58:16
Done.
| |
| 749 | |
| 739 SendMessageToRenderer( | 750 SendMessageToRenderer( |
| 740 NaClLaunchResult(imc_handle_for_renderer, | 751 NaClLaunchResult(imc_handle_for_renderer, |
| 741 ppapi_channel_handle, | 752 ppapi_channel_handle, |
| 742 trusted_channel_handle, | 753 trusted_channel_handle, |
| 743 manifest_service_channel_handle, | 754 manifest_service_channel_handle, |
| 744 base::GetProcId(data.handle), | 755 base::GetProcId(data.handle), |
| 745 data.id), | 756 data.id, |
| 757 crash_info_shmem_renderer_handle), | |
| 746 std::string() /* error_message */); | 758 std::string() /* error_message */); |
| 747 internal_->socket_for_renderer = NACL_INVALID_HANDLE; | 759 internal_->socket_for_renderer = NACL_INVALID_HANDLE; |
| 748 return true; | 760 return true; |
| 749 } | 761 } |
| 750 | 762 |
| 751 void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) { | 763 void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) { |
| 752 LOG(ERROR) << "NaCl process launch failed: " << error_message; | 764 LOG(ERROR) << "NaCl process launch failed: " << error_message; |
| 753 SendMessageToRenderer(NaClLaunchResult(), error_message); | 765 SendMessageToRenderer(NaClLaunchResult(), error_message); |
| 754 } | 766 } |
| 755 | 767 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 892 } | 904 } |
| 893 #endif | 905 #endif |
| 894 } | 906 } |
| 895 | 907 |
| 896 if (!uses_nonsfi_mode_) { | 908 if (!uses_nonsfi_mode_) { |
| 897 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; | 909 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; |
| 898 } | 910 } |
| 899 | 911 |
| 900 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), | 912 params.nexe_file = IPC::TakeFileHandleForProcess(nexe_file_.Pass(), |
| 901 process_->GetData().handle); | 913 process_->GetData().handle); |
| 914 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, | |
| 915 ¶ms.crash_info_shmem_handle)) { | |
| 916 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; | |
| 917 return false; | |
| 918 } | |
| 902 | 919 |
| 903 process_->Send(new NaClProcessMsg_Start(params)); | 920 process_->Send(new NaClProcessMsg_Start(params)); |
| 904 return true; | 921 return true; |
| 905 } | 922 } |
| 906 | 923 |
| 907 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is | 924 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is |
| 908 // received. | 925 // received. |
| 909 void NaClProcessHost::OnPpapiChannelsCreated( | 926 void NaClProcessHost::OnPpapiChannelsCreated( |
| 910 const IPC::ChannelHandle& browser_channel_handle, | 927 const IPC::ChannelHandle& browser_channel_handle, |
| 911 const IPC::ChannelHandle& ppapi_renderer_channel_handle, | 928 const IPC::ChannelHandle& ppapi_renderer_channel_handle, |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 process_handle.Take(), info, | 1164 process_handle.Take(), info, |
| 1148 base::MessageLoopProxy::current(), | 1165 base::MessageLoopProxy::current(), |
| 1149 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1166 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1150 weak_factory_.GetWeakPtr())); | 1167 weak_factory_.GetWeakPtr())); |
| 1151 return true; | 1168 return true; |
| 1152 } | 1169 } |
| 1153 } | 1170 } |
| 1154 #endif | 1171 #endif |
| 1155 | 1172 |
| 1156 } // namespace nacl | 1173 } // namespace nacl |
| OLD | NEW |