Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 // mappable with PROT_EXEC. Rather than requiring an extra IPC | 939 // mappable with PROT_EXEC. Rather than requiring an extra IPC |
| 940 // round trip out of the sandbox, we create an FD here. | 940 // round trip out of the sandbox, we create an FD here. |
| 941 base::SharedMemory memory_buffer; | 941 base::SharedMemory memory_buffer; |
| 942 base::SharedMemoryCreateOptions options; | 942 base::SharedMemoryCreateOptions options; |
| 943 options.size = 1; | 943 options.size = 1; |
| 944 options.executable = true; | 944 options.executable = true; |
| 945 if (!memory_buffer.Create(options)) { | 945 if (!memory_buffer.Create(options)) { |
| 946 DLOG(ERROR) << "Failed to allocate memory buffer"; | 946 DLOG(ERROR) << "Failed to allocate memory buffer"; |
| 947 return false; | 947 return false; |
| 948 } | 948 } |
| 949 base::ScopedFD memory_fd(dup(memory_buffer.handle().fd)); | 949 base::SharedMemoryHandle duped_handle = |
| 950 base::SharedMemory::DuplicateHandle(memory_buffer.handle()); | |
| 951 base::ScopedFD memory_fd( | |
| 952 base::SharedMemory::GetFdFromSharedMemoryHandle(duped_handle)); | |
|
Mark Seaborn
2015/06/04 20:17:55
How will this help you switch to having SharedMemo
erikchen
2015/06/04 20:25:42
I have a CL that changes SharedMemoryHandle to be
Mark Seaborn
2015/06/04 20:45:01
Which cases will require you to support storing an
| |
| 950 if (!memory_fd.is_valid()) { | 953 if (!memory_fd.is_valid()) { |
| 951 DLOG(ERROR) << "Failed to dup() a file descriptor"; | 954 DLOG(ERROR) << "Failed to dup() a file descriptor"; |
| 952 return false; | 955 return false; |
| 953 } | 956 } |
| 954 params.mac_shm_fd = IPC::GetFileHandleForProcess( | 957 params.mac_shm_fd = IPC::GetFileHandleForProcess( |
| 955 memory_fd.release(), data.handle, true); | 958 memory_fd.release(), data.handle, true); |
| 956 #endif | 959 #endif |
| 957 | 960 |
| 958 #if defined(OS_POSIX) | 961 #if defined(OS_POSIX) |
| 959 if (params.enable_debug_stub) { | 962 if (params.enable_debug_stub) { |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 NaClStartDebugExceptionHandlerThread( | 1388 NaClStartDebugExceptionHandlerThread( |
| 1386 process.Pass(), info, base::ThreadTaskRunnerHandle::Get(), | 1389 process.Pass(), info, base::ThreadTaskRunnerHandle::Get(), |
| 1387 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1390 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
| 1388 weak_factory_.GetWeakPtr())); | 1391 weak_factory_.GetWeakPtr())); |
| 1389 return true; | 1392 return true; |
| 1390 } | 1393 } |
| 1391 } | 1394 } |
| 1392 #endif | 1395 #endif |
| 1393 | 1396 |
| 1394 } // namespace nacl | 1397 } // namespace nacl |
| OLD | NEW |