OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/shared_memory.h" | 5 #include "base/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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 munmap(memory_, max_size_); | 257 munmap(memory_, max_size_); |
258 memory_ = NULL; | 258 memory_ = NULL; |
259 max_size_ = 0; | 259 max_size_ = 0; |
260 return true; | 260 return true; |
261 } | 261 } |
262 | 262 |
263 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, | 263 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, |
264 SharedMemoryHandle *new_handle, | 264 SharedMemoryHandle *new_handle, |
265 bool close_self) { | 265 bool close_self) { |
266 const int new_fd = dup(mapped_file_); | 266 const int new_fd = dup(mapped_file_); |
267 DCHECK(new_fd >= -1); | 267 DCHECK(new_fd >= 0); |
268 new_handle->fd = new_fd; | 268 new_handle->fd = new_fd; |
269 new_handle->auto_close = true; | 269 new_handle->auto_close = true; |
270 | 270 |
271 if (close_self) | 271 if (close_self) |
272 Close(); | 272 Close(); |
273 | 273 |
274 return true; | 274 return true; |
275 } | 275 } |
276 | 276 |
277 | 277 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 309 |
310 void SharedMemory::Unlock() { | 310 void SharedMemory::Unlock() { |
311 LockOrUnlockCommon(F_ULOCK); | 311 LockOrUnlockCommon(F_ULOCK); |
312 } | 312 } |
313 | 313 |
314 SharedMemoryHandle SharedMemory::handle() const { | 314 SharedMemoryHandle SharedMemory::handle() const { |
315 return FileDescriptor(mapped_file_, false); | 315 return FileDescriptor(mapped_file_, false); |
316 } | 316 } |
317 | 317 |
318 } // namespace base | 318 } // namespace base |
OLD | NEW |