| 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 <sys/mman.h> | 9 #include <sys/mman.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) | 117 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) |
| 118 : mapped_file_(handle.fd), | 118 : mapped_file_(handle.fd), |
| 119 readonly_mapped_file_(-1), | 119 readonly_mapped_file_(-1), |
| 120 mapped_size_(0), | 120 mapped_size_(0), |
| 121 memory_(NULL), | 121 memory_(NULL), |
| 122 read_only_(read_only), | 122 read_only_(read_only), |
| 123 requested_size_(0) { | 123 requested_size_(0) { |
| 124 } | 124 } |
| 125 | 125 |
| 126 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, | |
| 127 bool read_only, | |
| 128 ProcessHandle process) | |
| 129 : mapped_file_(handle.fd), | |
| 130 readonly_mapped_file_(-1), | |
| 131 mapped_size_(0), | |
| 132 memory_(NULL), | |
| 133 read_only_(read_only), | |
| 134 requested_size_(0) { | |
| 135 // We don't handle this case yet (note the ignored parameter); let's die if | |
| 136 // someone comes calling. | |
| 137 NOTREACHED(); | |
| 138 } | |
| 139 | |
| 140 SharedMemory::~SharedMemory() { | 126 SharedMemory::~SharedMemory() { |
| 141 Unmap(); | 127 Unmap(); |
| 142 Close(); | 128 Close(); |
| 143 } | 129 } |
| 144 | 130 |
| 145 // static | 131 // static |
| 146 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { | 132 bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) { |
| 147 return handle.fd >= 0; | 133 return handle.fd >= 0; |
| 148 } | 134 } |
| 149 | 135 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 492 |
| 507 if (close_self) { | 493 if (close_self) { |
| 508 Unmap(); | 494 Unmap(); |
| 509 Close(); | 495 Close(); |
| 510 } | 496 } |
| 511 | 497 |
| 512 return true; | 498 return true; |
| 513 } | 499 } |
| 514 | 500 |
| 515 } // namespace base | 501 } // namespace base |
| OLD | NEW |