| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 SharedMemoryHandle handle() const; | 193 SharedMemoryHandle handle() const; |
| 194 | 194 |
| 195 #if defined(OS_POSIX) && !defined(OS_NACL) | 195 #if defined(OS_POSIX) && !defined(OS_NACL) |
| 196 // Returns a unique identifier for this shared memory segment. Inode numbers | 196 // Returns a unique identifier for this shared memory segment. Inode numbers |
| 197 // are technically only unique to a single filesystem. However, we always | 197 // are technically only unique to a single filesystem. However, we always |
| 198 // allocate shared memory backing files from the same directory, so will end | 198 // allocate shared memory backing files from the same directory, so will end |
| 199 // up on the same filesystem. | 199 // up on the same filesystem. |
| 200 SharedMemoryId id() const { return inode_; } | 200 SharedMemoryId id() const { return inode_; } |
| 201 #endif | 201 #endif |
| 202 | 202 |
| 203 #if defined(OS_WIN) |
| 204 // Allows the caller to specify if the underlying handle to the shared memory |
| 205 // section is inheritable. |
| 206 void set_inheritable(bool inheritable) { |
| 207 inheritable_ = inheritable; |
| 208 } |
| 209 #endif |
| 210 |
| 203 // Closes the open shared memory segment. The memory will remain mapped if | 211 // Closes the open shared memory segment. The memory will remain mapped if |
| 204 // it was previously mapped. | 212 // it was previously mapped. |
| 205 // It is safe to call Close repeatedly. | 213 // It is safe to call Close repeatedly. |
| 206 void Close(); | 214 void Close(); |
| 207 | 215 |
| 208 // Shares the shared memory to another process. Attempts to create a | 216 // Shares the shared memory to another process. Attempts to create a |
| 209 // platform-specific new_handle which can be used in a remote process to read | 217 // platform-specific new_handle which can be used in a remote process to read |
| 210 // the shared memory file. new_handle is an output parameter to receive the | 218 // the shared memory file. new_handle is an output parameter to receive the |
| 211 // handle for use in the remote process. | 219 // handle for use in the remote process. |
| 212 // | 220 // |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 SHARE_CURRENT_MODE, | 287 SHARE_CURRENT_MODE, |
| 280 }; | 288 }; |
| 281 bool ShareToProcessCommon(ProcessHandle process, | 289 bool ShareToProcessCommon(ProcessHandle process, |
| 282 SharedMemoryHandle* new_handle, | 290 SharedMemoryHandle* new_handle, |
| 283 bool close_self, | 291 bool close_self, |
| 284 ShareMode); | 292 ShareMode); |
| 285 | 293 |
| 286 #if defined(OS_WIN) | 294 #if defined(OS_WIN) |
| 287 std::wstring name_; | 295 std::wstring name_; |
| 288 HANDLE mapped_file_; | 296 HANDLE mapped_file_; |
| 297 // Indicates if the shared memory handle is inhertiable. Defaults to false. |
| 298 bool inheritable_; |
| 289 #elif defined(OS_POSIX) | 299 #elif defined(OS_POSIX) |
| 290 int mapped_file_; | 300 int mapped_file_; |
| 291 int readonly_mapped_file_; | 301 int readonly_mapped_file_; |
| 292 ino_t inode_; | 302 ino_t inode_; |
| 293 #endif | 303 #endif |
| 294 size_t mapped_size_; | 304 size_t mapped_size_; |
| 295 void* memory_; | 305 void* memory_; |
| 296 bool read_only_; | 306 bool read_only_; |
| 297 size_t requested_size_; | 307 size_t requested_size_; |
| 298 #if !defined(OS_POSIX) | 308 #if !defined(OS_POSIX) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 317 } | 327 } |
| 318 | 328 |
| 319 private: | 329 private: |
| 320 SharedMemory* shared_memory_; | 330 SharedMemory* shared_memory_; |
| 321 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); | 331 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); |
| 322 }; | 332 }; |
| 323 | 333 |
| 324 } // namespace base | 334 } // namespace base |
| 325 | 335 |
| 326 #endif // BASE_MEMORY_SHARED_MEMORY_H_ | 336 #endif // BASE_MEMORY_SHARED_MEMORY_H_ |
| OLD | NEW |