OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/posix/eintr_wrapper.h" | 9 #include "base/posix/eintr_wrapper.h" |
10 | 10 |
11 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
12 namespace base { | 11 namespace base { |
13 | 12 |
14 static_assert(sizeof(SharedMemoryHandle::Type) <= | 13 static_assert(sizeof(SharedMemoryHandle::Type) <= |
15 sizeof(SharedMemoryHandle::TypeWireFormat), | 14 sizeof(SharedMemoryHandle::TypeWireFormat), |
16 "Size of enum SharedMemoryHandle::Type exceeds size of type " | 15 "Size of enum SharedMemoryHandle::Type exceeds size of type " |
17 "transmitted over wire."); | 16 "transmitted over wire."); |
18 | 17 |
19 SharedMemoryHandle::SharedMemoryHandle() : type_(POSIX), file_descriptor_() {} | 18 SharedMemoryHandle::SharedMemoryHandle() : type_(POSIX), file_descriptor_() {} |
20 | 19 |
21 SharedMemoryHandle::SharedMemoryHandle( | 20 SharedMemoryHandle::SharedMemoryHandle( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 75 |
77 SharedMemoryHandle SharedMemoryHandle::Duplicate() const { | 76 SharedMemoryHandle SharedMemoryHandle::Duplicate() const { |
78 DCHECK_EQ(type_, POSIX); | 77 DCHECK_EQ(type_, POSIX); |
79 int duped_handle = HANDLE_EINTR(dup(file_descriptor_.fd)); | 78 int duped_handle = HANDLE_EINTR(dup(file_descriptor_.fd)); |
80 if (duped_handle < 0) | 79 if (duped_handle < 0) |
81 return SharedMemoryHandle(); | 80 return SharedMemoryHandle(); |
82 return SharedMemoryHandle(duped_handle, true); | 81 return SharedMemoryHandle(duped_handle, true); |
83 } | 82 } |
84 | 83 |
85 } // namespace base | 84 } // namespace base |
86 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
OLD | NEW |