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 | 20 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 79 |
81 SharedMemoryHandle SharedMemoryHandle::Duplicate() const { | 80 SharedMemoryHandle SharedMemoryHandle::Duplicate() const { |
82 DCHECK_EQ(type_, POSIX); | 81 DCHECK_EQ(type_, POSIX); |
83 int duped_handle = HANDLE_EINTR(dup(file_descriptor_.fd)); | 82 int duped_handle = HANDLE_EINTR(dup(file_descriptor_.fd)); |
84 if (duped_handle < 0) | 83 if (duped_handle < 0) |
85 return SharedMemoryHandle(); | 84 return SharedMemoryHandle(); |
86 return SharedMemoryHandle(duped_handle, true); | 85 return SharedMemoryHandle(duped_handle, true); |
87 } | 86 } |
88 | 87 |
89 } // namespace base | 88 } // namespace base |
90 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
OLD | NEW |