OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_handle.h" | 5 #include "base/memory/shared_memory_handle.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 int old_fd = file_descriptor_.fd; | 50 int old_fd = file_descriptor_.fd; |
51 file_descriptor_.fd = -1; | 51 file_descriptor_.fd = -1; |
52 return old_fd; | 52 return old_fd; |
53 } | 53 } |
54 | 54 |
55 SharedMemoryHandle SharedMemoryHandle::Duplicate() const { | 55 SharedMemoryHandle SharedMemoryHandle::Duplicate() const { |
56 if (!IsValid()) | 56 if (!IsValid()) |
57 return SharedMemoryHandle(); | 57 return SharedMemoryHandle(); |
58 | 58 |
59 int duped_handle = HANDLE_EINTR(dup(file_descriptor_.fd)); | 59 int duped_handle = HANDLE_EINTR(dup(file_descriptor_.fd)); |
60 if (duped_handle < 0) | 60 if (duped_handle < 0) { |
| 61 DPLOG(ERROR) << "dup() failed."; |
61 return SharedMemoryHandle(); | 62 return SharedMemoryHandle(); |
| 63 } |
62 return SharedMemoryHandle(FileDescriptor(duped_handle, true)); | 64 return SharedMemoryHandle(FileDescriptor(duped_handle, true)); |
63 } | 65 } |
64 | 66 |
65 void SharedMemoryHandle::SetOwnershipPassesToIPC(bool ownership_passes) { | 67 void SharedMemoryHandle::SetOwnershipPassesToIPC(bool ownership_passes) { |
66 file_descriptor_.auto_close = ownership_passes; | 68 file_descriptor_.auto_close = ownership_passes; |
67 } | 69 } |
68 | 70 |
69 bool SharedMemoryHandle::OwnershipPassesToIPC() const { | 71 bool SharedMemoryHandle::OwnershipPassesToIPC() const { |
70 return file_descriptor_.auto_close; | 72 return file_descriptor_.auto_close; |
71 } | 73 } |
72 | 74 |
73 } // namespace base | 75 } // namespace base |
OLD | NEW |