| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 return; | 479 return; |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 // Send over the IRT file handle. We don't close our own copy! | 483 // Send over the IRT file handle. We don't close our own copy! |
| 484 if (!SendHandleToSelLdr(handle(), irt_file, false, &handles_for_sel_ldr)) { | 484 if (!SendHandleToSelLdr(handle(), irt_file, false, &handles_for_sel_ldr)) { |
| 485 delete this; | 485 delete this; |
| 486 return; | 486 return; |
| 487 } | 487 } |
| 488 | 488 |
| 489 #if defined(OS_POSIX) | 489 #if defined(OS_MACOSX) |
| 490 // For dynamic loading support, NaCl requires a file descriptor on an | 490 // For dynamic loading support, NaCl requires a file descriptor that |
| 491 // anonymous file that can have PROT_EXEC applied to its mappings. | 491 // was created in /tmp, since those created with shm_open() are not |
| 492 // Rather than requiring an extra IPC round trip out of the sandbox, | 492 // mappable with PROT_EXEC. Rather than requiring an extra IPC |
| 493 // we create an FD here. | 493 // round trip out of the sandbox, we create an FD here. |
| 494 base::SharedMemory memory_buffer; | 494 base::SharedMemory memory_buffer; |
| 495 if (!memory_buffer.CreateAnonymous(/* size= */ 1)) { | 495 if (!memory_buffer.CreateAnonymous(/* size= */ 1)) { |
| 496 LOG(ERROR) << "Failed to allocate memory buffer"; | 496 LOG(ERROR) << "Failed to allocate memory buffer"; |
| 497 delete this; | 497 delete this; |
| 498 return; | 498 return; |
| 499 } | 499 } |
| 500 nacl::FileDescriptor memory_fd; | 500 nacl::FileDescriptor memory_fd; |
| 501 memory_fd.fd = dup(memory_buffer.handle().fd); | 501 memory_fd.fd = dup(memory_buffer.handle().fd); |
| 502 if (memory_fd.fd < 0) { | 502 if (memory_fd.fd < 0) { |
| 503 LOG(ERROR) << "Failed to dup() a file descriptor"; | 503 LOG(ERROR) << "Failed to dup() a file descriptor"; |
| 504 delete this; | 504 delete this; |
| 505 return; | 505 return; |
| 506 } | 506 } |
| 507 memory_fd.auto_close = true; | 507 memory_fd.auto_close = true; |
| 508 handles_for_sel_ldr.push_back(memory_fd); | 508 handles_for_sel_ldr.push_back(memory_fd); |
| 509 #endif | 509 #endif |
| 510 | 510 |
| 511 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); | 511 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); |
| 512 internal_->sockets_for_sel_ldr.clear(); | 512 internal_->sockets_for_sel_ldr.clear(); |
| 513 } | 513 } |
| 514 | 514 |
| 515 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { | 515 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 516 NOTREACHED() << "Invalid message with type = " << msg.type(); | 516 NOTREACHED() << "Invalid message with type = " << msg.type(); |
| 517 return false; | 517 return false; |
| 518 } | 518 } |
| 519 | 519 |
| 520 bool NaClProcessHost::CanShutdown() { | 520 bool NaClProcessHost::CanShutdown() { |
| 521 return true; | 521 return true; |
| 522 } | 522 } |
| OLD | NEW |