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 #ifndef BASE_MEMORY_SHARED_MEMORY_H_ | 5 #ifndef BASE_MEMORY_SHARED_MEMORY_H_ |
6 #define BASE_MEMORY_SHARED_MEMORY_H_ | 6 #define BASE_MEMORY_SHARED_MEMORY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 | 185 |
186 // Gets a pointer to the opened memory space if it has been | 186 // Gets a pointer to the opened memory space if it has been |
187 // Mapped via Map(). Returns NULL if it is not mapped. | 187 // Mapped via Map(). Returns NULL if it is not mapped. |
188 void* memory() const { return memory_; } | 188 void* memory() const { return memory_; } |
189 | 189 |
190 // Returns the underlying OS handle for this segment. | 190 // Returns the underlying OS handle for this segment. |
191 // Use of this handle for anything other than an opaque | 191 // Use of this handle for anything other than an opaque |
192 // identifier is not portable. | 192 // identifier is not portable. |
193 SharedMemoryHandle handle() const; | 193 SharedMemoryHandle handle() const; |
194 | 194 |
195 // Returns the underlying OS handle for this segment. The caller also gets | |
196 // ownership of the handle. This is logically equivalent to: | |
197 // SharedMemoryHandle dup = DuplicateHandle(handle()); | |
198 // Close(); | |
199 // return dup; | |
200 SharedMemoryHandle TakeHandle(); | |
Nico
2016/11/14 18:53:51
make this WARN_UNUSED_RESULT
| |
201 | |
195 // Closes the open shared memory segment. The memory will remain mapped if | 202 // Closes the open shared memory segment. The memory will remain mapped if |
196 // it was previously mapped. | 203 // it was previously mapped. |
197 // It is safe to call Close repeatedly. | 204 // It is safe to call Close repeatedly. |
198 void Close(); | 205 void Close(); |
199 | 206 |
200 // Shares the shared memory to another process. Attempts to create a | 207 // Shares the shared memory to another process. Attempts to create a |
201 // platform-specific new_handle which can be used in a remote process to read | 208 // platform-specific new_handle which can be used in a remote process to read |
202 // the shared memory file. new_handle is an output parameter to receive the | 209 // the shared memory file. new_handle is an output parameter to receive the |
203 // handle for use in the remote process. | 210 // handle for use in the remote process. |
204 // | 211 // |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 size_t mapped_size_; | 283 size_t mapped_size_; |
277 void* memory_; | 284 void* memory_; |
278 bool read_only_; | 285 bool read_only_; |
279 size_t requested_size_; | 286 size_t requested_size_; |
280 | 287 |
281 DISALLOW_COPY_AND_ASSIGN(SharedMemory); | 288 DISALLOW_COPY_AND_ASSIGN(SharedMemory); |
282 }; | 289 }; |
283 } // namespace base | 290 } // namespace base |
284 | 291 |
285 #endif // BASE_MEMORY_SHARED_MEMORY_H_ | 292 #endif // BASE_MEMORY_SHARED_MEMORY_H_ |
OLD | NEW |