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(1); // size |
Mark Mentovai
2011/12/01 19:31:16
Yeah, see, this |// size| is cumbersome. It’d be b
| |
496 options.executable = true; | |
497 if (!memory_buffer.Create(options)) { | |
496 LOG(ERROR) << "Failed to allocate memory buffer"; | 498 LOG(ERROR) << "Failed to allocate memory buffer"; |
497 delete this; | 499 delete this; |
498 return; | 500 return; |
499 } | 501 } |
500 nacl::FileDescriptor memory_fd; | 502 nacl::FileDescriptor memory_fd; |
501 memory_fd.fd = dup(memory_buffer.handle().fd); | 503 memory_fd.fd = dup(memory_buffer.handle().fd); |
502 if (memory_fd.fd < 0) { | 504 if (memory_fd.fd < 0) { |
503 LOG(ERROR) << "Failed to dup() a file descriptor"; | 505 LOG(ERROR) << "Failed to dup() a file descriptor"; |
504 delete this; | 506 delete this; |
505 return; | 507 return; |
506 } | 508 } |
507 memory_fd.auto_close = true; | 509 memory_fd.auto_close = true; |
508 handles_for_sel_ldr.push_back(memory_fd); | 510 handles_for_sel_ldr.push_back(memory_fd); |
509 #endif | 511 #endif |
510 | 512 |
511 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); | 513 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); |
512 internal_->sockets_for_sel_ldr.clear(); | 514 internal_->sockets_for_sel_ldr.clear(); |
513 } | 515 } |
514 | 516 |
515 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { | 517 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
516 NOTREACHED() << "Invalid message with type = " << msg.type(); | 518 NOTREACHED() << "Invalid message with type = " << msg.type(); |
517 return false; | 519 return false; |
518 } | 520 } |
519 | 521 |
520 bool NaClProcessHost::CanShutdown() { | 522 bool NaClProcessHost::CanShutdown() { |
521 return true; | 523 return true; |
522 } | 524 } |
OLD | NEW |