| 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 "chrome/browser/nacl_host/nacl_process_host.h" | 5 #include "chrome/browser/nacl_host/nacl_process_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 #else | 903 #else |
| 904 // No need to dup the imc_handle - we don't pass it anywhere else so | 904 // No need to dup the imc_handle - we don't pass it anywhere else so |
| 905 // it cannot be closed. | 905 // it cannot be closed. |
| 906 nacl::FileDescriptor imc_handle; | 906 nacl::FileDescriptor imc_handle; |
| 907 imc_handle.fd = internal_->sockets_for_renderer[i]; | 907 imc_handle.fd = internal_->sockets_for_renderer[i]; |
| 908 imc_handle.auto_close = true; | 908 imc_handle.auto_close = true; |
| 909 handles_for_renderer.push_back(imc_handle); | 909 handles_for_renderer.push_back(imc_handle); |
| 910 #endif | 910 #endif |
| 911 } | 911 } |
| 912 | 912 |
| 913 const ChildProcessData& data = process_->GetData(); | |
| 914 base::ProcessHandle nacl_process_handle; | |
| 915 #if defined(OS_WIN) | 913 #if defined(OS_WIN) |
| 916 // Copy the process handle into the renderer process. | |
| 917 // TODO(mseaborn): Remove this. The renderer process uses this | |
| 918 // handle with NaCl's handle_pass module, but we are replacing | |
| 919 // handle_pass with Chrome's BrokerDuplicateHandle() function. | |
| 920 if (!DuplicateHandle(base::GetCurrentProcessHandle(), | |
| 921 data.handle, | |
| 922 chrome_render_message_filter_->peer_handle(), | |
| 923 &nacl_process_handle, | |
| 924 PROCESS_DUP_HANDLE, | |
| 925 FALSE, | |
| 926 0)) { | |
| 927 DLOG(ERROR) << "DuplicateHandle() failed"; | |
| 928 return false; | |
| 929 } | |
| 930 // If we are on 64-bit Windows, the NaCl process's sandbox is | 914 // If we are on 64-bit Windows, the NaCl process's sandbox is |
| 931 // managed by a different process from the renderer's sandbox. We | 915 // managed by a different process from the renderer's sandbox. We |
| 932 // need to inform the renderer's sandbox about the NaCl process so | 916 // need to inform the renderer's sandbox about the NaCl process so |
| 933 // that the renderer can send handles to the NaCl process using | 917 // that the renderer can send handles to the NaCl process using |
| 934 // BrokerDuplicateHandle(). | 918 // BrokerDuplicateHandle(). |
| 935 if (RunningOnWOW64()) { | 919 if (RunningOnWOW64()) { |
| 936 if (!content::BrokerAddTargetPeer(data.handle)) { | 920 if (!content::BrokerAddTargetPeer(process_->GetData().handle)) { |
| 937 DLOG(ERROR) << "Failed to add NaCl process PID"; | 921 DLOG(ERROR) << "Failed to add NaCl process PID"; |
| 938 return false; | 922 return false; |
| 939 } | 923 } |
| 940 } | 924 } |
| 941 #else | |
| 942 // We use pid as process handle on Posix | |
| 943 nacl_process_handle = data.handle; | |
| 944 #endif | 925 #endif |
| 945 | 926 |
| 946 // Get the pid of the NaCl process | |
| 947 base::ProcessId nacl_process_id = base::GetProcId(data.handle); | |
| 948 | |
| 949 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( | 927 ChromeViewHostMsg_LaunchNaCl::WriteReplyParams( |
| 950 reply_msg_, handles_for_renderer, nacl_process_handle, nacl_process_id); | 928 reply_msg_, handles_for_renderer); |
| 951 chrome_render_message_filter_->Send(reply_msg_); | 929 chrome_render_message_filter_->Send(reply_msg_); |
| 952 chrome_render_message_filter_ = NULL; | 930 chrome_render_message_filter_ = NULL; |
| 953 reply_msg_ = NULL; | 931 reply_msg_ = NULL; |
| 954 internal_->sockets_for_renderer.clear(); | 932 internal_->sockets_for_renderer.clear(); |
| 955 return true; | 933 return true; |
| 956 } | 934 } |
| 957 | 935 |
| 958 bool NaClProcessHost::StartNaClExecution() { | 936 bool NaClProcessHost::StartNaClExecution() { |
| 959 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 937 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| 960 | 938 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 } | 1023 } |
| 1046 | 1024 |
| 1047 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature, | 1025 void NaClProcessHost::OnQueryKnownToValidate(const std::string& signature, |
| 1048 bool* result) { | 1026 bool* result) { |
| 1049 *result = NaClBrowser::GetInstance()->QueryKnownToValidate(signature); | 1027 *result = NaClBrowser::GetInstance()->QueryKnownToValidate(signature); |
| 1050 } | 1028 } |
| 1051 | 1029 |
| 1052 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { | 1030 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { |
| 1053 NaClBrowser::GetInstance()->SetKnownToValidate(signature); | 1031 NaClBrowser::GetInstance()->SetKnownToValidate(signature); |
| 1054 } | 1032 } |
| OLD | NEW |