Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 860453002: Move OpenProcessHandleWithAccess to Process::OpenWithAccess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ServiceProcessControlBrowserTest.Setup again Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 return false; 1136 return false;
1137 } 1137 }
1138 if (debug_exception_handler_requested_) { 1138 if (debug_exception_handler_requested_) {
1139 // The NaCl process should not request this multiple times. 1139 // The NaCl process should not request this multiple times.
1140 DLOG(ERROR) << "Multiple AttachDebugExceptionHandler requests received"; 1140 DLOG(ERROR) << "Multiple AttachDebugExceptionHandler requests received";
1141 return false; 1141 return false;
1142 } 1142 }
1143 debug_exception_handler_requested_ = true; 1143 debug_exception_handler_requested_ = true;
1144 1144
1145 base::ProcessId nacl_pid = base::GetProcId(process_->GetData().handle); 1145 base::ProcessId nacl_pid = base::GetProcId(process_->GetData().handle);
1146 base::ProcessHandle temp_handle;
1147 // We cannot use process_->GetData().handle because it does not have 1146 // We cannot use process_->GetData().handle because it does not have
1148 // the necessary access rights. We open the new handle here rather 1147 // the necessary access rights. We open the new handle here rather
1149 // than in the NaCl broker process in case the NaCl loader process 1148 // than in the NaCl broker process in case the NaCl loader process
1150 // dies before the NaCl broker process receives the message we send. 1149 // dies before the NaCl broker process receives the message we send.
1151 // The debug exception handler uses DebugActiveProcess() to attach, 1150 // The debug exception handler uses DebugActiveProcess() to attach,
1152 // but this takes a PID. We need to prevent the NaCl loader's PID 1151 // but this takes a PID. We need to prevent the NaCl loader's PID
1153 // from being reused before DebugActiveProcess() is called, and 1152 // from being reused before DebugActiveProcess() is called, and
1154 // holding a process handle open achieves this. 1153 // holding a process handle open achieves this.
1155 if (!base::OpenProcessHandleWithAccess( 1154 base::Process process =
1156 nacl_pid, 1155 base::Process::OpenWithAccess(nacl_pid,
1157 base::kProcessAccessQueryInformation | 1156 PROCESS_QUERY_INFORMATION |
1158 base::kProcessAccessSuspendResume | 1157 PROCESS_SUSPEND_RESUME |
1159 base::kProcessAccessTerminate | 1158 PROCESS_TERMINATE |
1160 base::kProcessAccessVMOperation | 1159 PROCESS_VM_OPERATION |
1161 base::kProcessAccessVMRead | 1160 PROCESS_VM_READ |
1162 base::kProcessAccessVMWrite | 1161 PROCESS_VM_WRITE |
1163 base::kProcessAccessDuplicateHandle | 1162 PROCESS_DUP_HANDLE |
1164 base::kProcessAccessWaitForTermination, 1163 SYNCHRONIZE);
1165 &temp_handle)) { 1164 if (!process.IsValid()) {
1166 LOG(ERROR) << "Failed to get process handle"; 1165 LOG(ERROR) << "Failed to get process handle";
1167 return false; 1166 return false;
1168 } 1167 }
1169 base::win::ScopedHandle process_handle(temp_handle);
1170 1168
1171 attach_debug_exception_handler_reply_msg_.reset(reply_msg); 1169 attach_debug_exception_handler_reply_msg_.reset(reply_msg);
1172 // If the NaCl loader is 64-bit, the process running its debug 1170 // If the NaCl loader is 64-bit, the process running its debug
1173 // exception handler must be 64-bit too, so we use the 64-bit NaCl 1171 // exception handler must be 64-bit too, so we use the 64-bit NaCl
1174 // broker process for this. Otherwise, on a 32-bit system, we use 1172 // broker process for this. Otherwise, on a 32-bit system, we use
1175 // the 32-bit browser process to run the debug exception handler. 1173 // the 32-bit browser process to run the debug exception handler.
1176 if (RunningOnWOW64()) { 1174 if (RunningOnWOW64()) {
1177 return NaClBrokerService::GetInstance()->LaunchDebugExceptionHandler( 1175 return NaClBrokerService::GetInstance()->LaunchDebugExceptionHandler(
1178 weak_factory_.GetWeakPtr(), nacl_pid, process_handle.Get(), 1176 weak_factory_.GetWeakPtr(), nacl_pid, process.Handle(),
1179 info); 1177 info);
1180 } else { 1178 } else {
1181 NaClStartDebugExceptionHandlerThread( 1179 NaClStartDebugExceptionHandlerThread(
1182 process_handle.Take(), info, 1180 process.Pass(), info,
1183 base::MessageLoopProxy::current(), 1181 base::MessageLoopProxy::current(),
1184 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1182 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1185 weak_factory_.GetWeakPtr())); 1183 weak_factory_.GetWeakPtr()));
1186 return true; 1184 return true;
1187 } 1185 }
1188 } 1186 }
1189 #endif 1187 #endif
1190 1188
1191 } // namespace nacl 1189 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698