| 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 <mach/mach_vm.h> | 9 #include <mach/mach_vm.h> |
| 10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 200 |
| 201 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) | 201 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) |
| 202 : shm_(handle), | 202 : shm_(handle), |
| 203 mapped_memory_mechanism_(SharedMemoryHandle::POSIX), | 203 mapped_memory_mechanism_(SharedMemoryHandle::POSIX), |
| 204 readonly_mapped_file_(-1), | 204 readonly_mapped_file_(-1), |
| 205 mapped_size_(0), | 205 mapped_size_(0), |
| 206 memory_(NULL), | 206 memory_(NULL), |
| 207 read_only_(read_only), | 207 read_only_(read_only), |
| 208 requested_size_(0) {} | 208 requested_size_(0) {} |
| 209 | 209 |
| 210 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, | |
| 211 bool read_only, | |
| 212 ProcessHandle process) | |
| 213 : mapped_memory_mechanism_(SharedMemoryHandle::POSIX), | |
| 214 readonly_mapped_file_(-1), | |
| 215 mapped_size_(0), | |
| 216 memory_(NULL), | |
| 217 read_only_(read_only), | |
| 218 requested_size_(0) { | |
| 219 // We don't handle this case yet (note the ignored parameter); let's die if | |
| 220 // someone comes calling. | |
| 221 NOTREACHED(); | |
| 222 } | |
| 223 | |
| 224 SharedMemory::~SharedMemory() { | 210 SharedMemory::~SharedMemory() { |
| 225 Unmap(); | 211 Unmap(); |
| 226 Close(); | 212 Close(); |
| 227 } | 213 } |
| 228 | 214 |
| 229 // static | 215 // static |
| 230 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { | 216 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { |
| 231 return handle.IsValid(); | 217 return handle.IsValid(); |
| 232 } | 218 } |
| 233 | 219 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 477 |
| 492 if (close_self) { | 478 if (close_self) { |
| 493 Unmap(); | 479 Unmap(); |
| 494 Close(); | 480 Close(); |
| 495 } | 481 } |
| 496 | 482 |
| 497 return true; | 483 return true; |
| 498 } | 484 } |
| 499 | 485 |
| 500 } // namespace base | 486 } // namespace base |
| OLD | NEW |