OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/nacl_host/nacl_process_host.h" | 7 #include "chrome/browser/nacl_host/nacl_process_host.h" |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 169 matching lines...) Loading... |
180 void NaClProcessHost::OnProcessLaunched() { | 180 void NaClProcessHost::OnProcessLaunched() { |
181 std::vector<nacl::FileDescriptor> handles_for_renderer; | 181 std::vector<nacl::FileDescriptor> handles_for_renderer; |
182 base::ProcessHandle nacl_process_handle; | 182 base::ProcessHandle nacl_process_handle; |
183 | 183 |
184 for (size_t i = 0; i < sockets_for_renderer_.size(); i++) { | 184 for (size_t i = 0; i < sockets_for_renderer_.size(); i++) { |
185 #if defined(OS_WIN) | 185 #if defined(OS_WIN) |
186 // Copy the handle into the renderer process. | 186 // Copy the handle into the renderer process. |
187 HANDLE handle_in_renderer; | 187 HANDLE handle_in_renderer; |
188 DuplicateHandle(base::GetCurrentProcessHandle(), | 188 DuplicateHandle(base::GetCurrentProcessHandle(), |
189 reinterpret_cast<HANDLE>(sockets_for_renderer_[i]), | 189 reinterpret_cast<HANDLE>(sockets_for_renderer_[i]), |
190 render_message_filter_->handle(), | 190 render_message_filter_->peer_handle(), |
191 &handle_in_renderer, | 191 &handle_in_renderer, |
192 GENERIC_READ | GENERIC_WRITE, | 192 GENERIC_READ | GENERIC_WRITE, |
193 FALSE, | 193 FALSE, |
194 DUPLICATE_CLOSE_SOURCE); | 194 DUPLICATE_CLOSE_SOURCE); |
195 handles_for_renderer.push_back( | 195 handles_for_renderer.push_back( |
196 reinterpret_cast<nacl::FileDescriptor>(handle_in_renderer)); | 196 reinterpret_cast<nacl::FileDescriptor>(handle_in_renderer)); |
197 #else | 197 #else |
198 // No need to dup the imc_handle - we don't pass it anywhere else so | 198 // No need to dup the imc_handle - we don't pass it anywhere else so |
199 // it cannot be closed. | 199 // it cannot be closed. |
200 nacl::FileDescriptor imc_handle; | 200 nacl::FileDescriptor imc_handle; |
201 imc_handle.fd = sockets_for_renderer_[i]; | 201 imc_handle.fd = sockets_for_renderer_[i]; |
202 imc_handle.auto_close = true; | 202 imc_handle.auto_close = true; |
203 handles_for_renderer.push_back(imc_handle); | 203 handles_for_renderer.push_back(imc_handle); |
204 #endif | 204 #endif |
205 } | 205 } |
206 | 206 |
207 #if defined(OS_WIN) | 207 #if defined(OS_WIN) |
208 // Copy the process handle into the renderer process. | 208 // Copy the process handle into the renderer process. |
209 DuplicateHandle(base::GetCurrentProcessHandle(), | 209 DuplicateHandle(base::GetCurrentProcessHandle(), |
210 handle(), | 210 handle(), |
211 render_message_filter_->handle(), | 211 render_message_filter_->peer_handle(), |
212 &nacl_process_handle, | 212 &nacl_process_handle, |
213 PROCESS_DUP_HANDLE, | 213 PROCESS_DUP_HANDLE, |
214 FALSE, | 214 FALSE, |
215 0); | 215 0); |
216 #else | 216 #else |
217 // We use pid as process handle on Posix | 217 // We use pid as process handle on Posix |
218 nacl_process_handle = handle(); | 218 nacl_process_handle = handle(); |
219 #endif | 219 #endif |
220 | 220 |
221 // Get the pid of the NaCl process | 221 // Get the pid of the NaCl process |
(...skipping 57 matching lines...) Loading... |
279 #endif | 279 #endif |
280 | 280 |
281 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); | 281 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); |
282 sockets_for_sel_ldr_.clear(); | 282 sockets_for_sel_ldr_.clear(); |
283 } | 283 } |
284 | 284 |
285 void NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { | 285 void NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
286 NOTREACHED() << "Invalid message with type = " << msg.type(); | 286 NOTREACHED() << "Invalid message with type = " << msg.type(); |
287 } | 287 } |
288 | 288 |
289 URLRequestContext* NaClProcessHost::GetRequestContext( | |
290 uint32 request_id, | |
291 const ViewHostMsg_Resource_Request& request_data) { | |
292 return NULL; | |
293 } | |
294 | |
295 bool NaClProcessHost::CanShutdown() { | 289 bool NaClProcessHost::CanShutdown() { |
296 return true; | 290 return true; |
297 } | 291 } |
298 | 292 |
299 #if defined(OS_WIN) | 293 #if defined(OS_WIN) |
300 // TODO(gregoryd): invoke CheckIsWow64 only once, not for each NaClProcessHost | 294 // TODO(gregoryd): invoke CheckIsWow64 only once, not for each NaClProcessHost |
301 typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | 295 typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); |
302 void NaClProcessHost::CheckIsWow64() { | 296 void NaClProcessHost::CheckIsWow64() { |
303 LPFN_ISWOW64PROCESS fnIsWow64Process; | 297 LPFN_ISWOW64PROCESS fnIsWow64Process; |
304 | 298 |
305 fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( | 299 fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( |
306 GetModuleHandle(TEXT("kernel32")), | 300 GetModuleHandle(TEXT("kernel32")), |
307 "IsWow64Process"); | 301 "IsWow64Process"); |
308 | 302 |
309 if (fnIsWow64Process != NULL) { | 303 if (fnIsWow64Process != NULL) { |
310 BOOL bIsWow64 = FALSE; | 304 BOOL bIsWow64 = FALSE; |
311 if (fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { | 305 if (fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { |
312 if (bIsWow64) { | 306 if (bIsWow64) { |
313 running_on_wow64_ = true; | 307 running_on_wow64_ = true; |
314 } | 308 } |
315 } | 309 } |
316 } | 310 } |
317 } | 311 } |
318 #endif | 312 #endif |
OLD | NEW |