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 <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 20 matching lines...) Expand all Loading... |
31 Unmap(); | 31 Unmap(); |
32 Close(); | 32 Close(); |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { | 36 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { |
37 return handle.IsValid(); | 37 return handle.IsValid(); |
38 } | 38 } |
39 | 39 |
40 // static | 40 // static |
41 SharedMemoryHandle SharedMemory::NULLHandle() { | |
42 return SharedMemoryHandle(); | |
43 } | |
44 | |
45 // static | |
46 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { | 41 void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) { |
47 DCHECK(handle.IsValid()); | 42 DCHECK(handle.IsValid()); |
48 handle.Close(); | 43 handle.Close(); |
49 } | 44 } |
50 | 45 |
51 // static | 46 // static |
52 SharedMemoryHandle SharedMemory::DuplicateHandle( | 47 SharedMemoryHandle SharedMemory::DuplicateHandle( |
53 const SharedMemoryHandle& handle) { | 48 const SharedMemoryHandle& handle) { |
54 return handle.Duplicate(); | 49 return handle.Duplicate(); |
55 } | 50 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 *new_handle = shm_.Duplicate(); | 138 *new_handle = shm_.Duplicate(); |
144 | 139 |
145 if (close_self) { | 140 if (close_self) { |
146 Unmap(); | 141 Unmap(); |
147 Close(); | 142 Close(); |
148 } | 143 } |
149 return new_handle->IsValid(); | 144 return new_handle->IsValid(); |
150 } | 145 } |
151 | 146 |
152 } // namespace base | 147 } // namespace base |
OLD | NEW |