| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 delete this; | 485 delete this; |
| 486 return; | 486 return; |
| 487 } | 487 } |
| 488 | 488 |
| 489 #if defined(OS_MACOSX) | 489 #if defined(OS_MACOSX) |
| 490 // For dynamic loading support, NaCl requires a file descriptor that | 490 // For dynamic loading support, NaCl requires a file descriptor that |
| 491 // was created in /tmp, since those created with shm_open() are not | 491 // was created in /tmp, since those created with shm_open() are not |
| 492 // mappable with PROT_EXEC. Rather than requiring an extra IPC | 492 // mappable with PROT_EXEC. Rather than requiring an extra IPC |
| 493 // round trip out of the sandbox, 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 base::SharedMemoryCreateOptions options; |
| 496 options.size = 1; |
| 497 options.executable = true; |
| 498 if (!memory_buffer.Create(options)) { |
| 496 LOG(ERROR) << "Failed to allocate memory buffer"; | 499 LOG(ERROR) << "Failed to allocate memory buffer"; |
| 497 delete this; | 500 delete this; |
| 498 return; | 501 return; |
| 499 } | 502 } |
| 500 nacl::FileDescriptor memory_fd; | 503 nacl::FileDescriptor memory_fd; |
| 501 memory_fd.fd = dup(memory_buffer.handle().fd); | 504 memory_fd.fd = dup(memory_buffer.handle().fd); |
| 502 if (memory_fd.fd < 0) { | 505 if (memory_fd.fd < 0) { |
| 503 LOG(ERROR) << "Failed to dup() a file descriptor"; | 506 LOG(ERROR) << "Failed to dup() a file descriptor"; |
| 504 delete this; | 507 delete this; |
| 505 return; | 508 return; |
| 506 } | 509 } |
| 507 memory_fd.auto_close = true; | 510 memory_fd.auto_close = true; |
| 508 handles_for_sel_ldr.push_back(memory_fd); | 511 handles_for_sel_ldr.push_back(memory_fd); |
| 509 #endif | 512 #endif |
| 510 | 513 |
| 511 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); | 514 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); |
| 512 internal_->sockets_for_sel_ldr.clear(); | 515 internal_->sockets_for_sel_ldr.clear(); |
| 513 } | 516 } |
| 514 | 517 |
| 515 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { | 518 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 516 NOTREACHED() << "Invalid message with type = " << msg.type(); | 519 NOTREACHED() << "Invalid message with type = " << msg.type(); |
| 517 return false; | 520 return false; |
| 518 } | 521 } |
| 519 | 522 |
| 520 bool NaClProcessHost::CanShutdown() { | 523 bool NaClProcessHost::CanShutdown() { |
| 521 return true; | 524 return true; |
| 522 } | 525 } |
| OLD | NEW |