| 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 "base/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/mman.h> | 9 #include <sys/mman.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return SharedMemoryHandle(); | 59 return SharedMemoryHandle(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { | 63 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { |
| 64 DCHECK_GE(handle.fd, 0); | 64 DCHECK_GE(handle.fd, 0); |
| 65 if (close(handle.fd) < 0) | 65 if (close(handle.fd) < 0) |
| 66 DPLOG(ERROR) << "close"; | 66 DPLOG(ERROR) << "close"; |
| 67 } | 67 } |
| 68 | 68 |
| 69 //static |
| 70 SharedMemoryHandle SharedMemory::DuplicateHandle( |
| 71 const SharedMemoryHandle& handle) { |
| 72 SharedMemoryHandle result; |
| 73 result.fd = dup(handle.fd); |
| 74 result.auto_close = false; |
| 75 return result; |
| 76 } |
| 77 |
| 69 bool SharedMemory::CreateAndMapAnonymous(size_t size) { | 78 bool SharedMemory::CreateAndMapAnonymous(size_t size) { |
| 70 // Untrusted code can't create descriptors or handles. | 79 // Untrusted code can't create descriptors or handles. |
| 71 return false; | 80 return false; |
| 72 } | 81 } |
| 73 | 82 |
| 74 bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { | 83 bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { |
| 75 // Untrusted code can't create descriptors or handles. | 84 // Untrusted code can't create descriptors or handles. |
| 76 return false; | 85 return false; |
| 77 } | 86 } |
| 78 | 87 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 158 |
| 150 new_handle->fd = new_fd; | 159 new_handle->fd = new_fd; |
| 151 new_handle->auto_close = true; | 160 new_handle->auto_close = true; |
| 152 | 161 |
| 153 if (close_self) | 162 if (close_self) |
| 154 Close(); | 163 Close(); |
| 155 return true; | 164 return true; |
| 156 } | 165 } |
| 157 | 166 |
| 158 } // namespace base | 167 } // namespace base |
| OLD | NEW |