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(SharedMemoryHandle handle, bool read_only) | 27 SharedMemory::SharedMemory(const 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(SharedMemoryHandle handle, bool read_only, | 35 SharedMemory::SharedMemory(const SharedMemoryHandle& handle, |
| 36 bool read_only, |
36 ProcessHandle process) | 37 ProcessHandle process) |
37 : mapped_file_(handle.fd), | 38 : mapped_file_(handle.fd), |
38 mapped_size_(0), | 39 mapped_size_(0), |
39 memory_(NULL), | 40 memory_(NULL), |
40 read_only_(read_only), | 41 read_only_(read_only), |
41 requested_size_(0) { | 42 requested_size_(0) { |
42 NOTREACHED(); | 43 NOTREACHED(); |
43 } | 44 } |
44 | 45 |
45 SharedMemory::~SharedMemory() { | 46 SharedMemory::~SharedMemory() { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 new_handle->auto_close = true; | 159 new_handle->auto_close = true; |
159 | 160 |
160 if (close_self) { | 161 if (close_self) { |
161 Unmap(); | 162 Unmap(); |
162 Close(); | 163 Close(); |
163 } | 164 } |
164 return true; | 165 return true; |
165 } | 166 } |
166 | 167 |
167 } // namespace base | 168 } // namespace base |
OLD | NEW |