| 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> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 | 12 |
| 13 #include <limits> | 13 #include <limits> |
| 14 | 14 |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 | 18 |
| 19 SharedMemory::SharedMemory() | 19 SharedMemory::SharedMemory() |
| 20 : mapped_file_(-1), | 20 : mapped_file_(-1), |
| 21 mapped_size_(0), | 21 mapped_size_(0), |
| 22 memory_(NULL), | 22 memory_(NULL), |
| 23 read_only_(false), | 23 read_only_(false), |
| 24 requested_size_(0) { | 24 requested_size_(0) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, bool read_only) | 27 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only) |
| 28 : mapped_file_(handle.fd), | 28 : mapped_file_(handle.fd), |
| 29 mapped_size_(0), | 29 mapped_size_(0), |
| 30 memory_(NULL), | 30 memory_(NULL), |
| 31 read_only_(read_only), | 31 read_only_(read_only), |
| 32 requested_size_(0) { | 32 requested_size_(0) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, | 35 SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only, |
| 36 bool read_only, | |
| 37 ProcessHandle process) | 36 ProcessHandle process) |
| 38 : mapped_file_(handle.fd), | 37 : mapped_file_(handle.fd), |
| 39 mapped_size_(0), | 38 mapped_size_(0), |
| 40 memory_(NULL), | 39 memory_(NULL), |
| 41 read_only_(read_only), | 40 read_only_(read_only), |
| 42 requested_size_(0) { | 41 requested_size_(0) { |
| 43 NOTREACHED(); | 42 NOTREACHED(); |
| 44 } | 43 } |
| 45 | 44 |
| 46 SharedMemory::~SharedMemory() { | 45 SharedMemory::~SharedMemory() { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 new_handle->auto_close = true; | 158 new_handle->auto_close = true; |
| 160 | 159 |
| 161 if (close_self) { | 160 if (close_self) { |
| 162 Unmap(); | 161 Unmap(); |
| 163 Close(); | 162 Close(); |
| 164 } | 163 } |
| 165 return true; | 164 return true; |
| 166 } | 165 } |
| 167 | 166 |
| 168 } // namespace base | 167 } // namespace base |
| OLD | NEW |