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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 // Returns invalid handle (see comment above for exact definition). | 110 // Returns invalid handle (see comment above for exact definition). |
111 static SharedMemoryHandle NULLHandle(); | 111 static SharedMemoryHandle NULLHandle(); |
112 | 112 |
113 // Closes a shared memory handle. | 113 // Closes a shared memory handle. |
114 static void CloseHandle(const SharedMemoryHandle& handle); | 114 static void CloseHandle(const SharedMemoryHandle& handle); |
115 | 115 |
116 // Returns the maximum number of handles that can be open at once per process. | 116 // Returns the maximum number of handles that can be open at once per process. |
117 static size_t GetHandleLimit(); | 117 static size_t GetHandleLimit(); |
118 | 118 |
| 119 #if defined(OS_WIN) || defined(OS_POSIX) |
| 120 // The copy shares the same underlying OS primitives. The new |
| 121 // SharedMemoryHandle will not clean up the OS primitives when destroyed. The |
| 122 // original must outlive the copy. |
| 123 static SharedMemoryHandle ShallowCopyOfHandle( |
| 124 const SharedMemoryHandle& handle); |
| 125 #endif |
| 126 |
| 127 #if defined(OS_POSIX) |
| 128 // The underlying OS primitives are duplicated. |
| 129 // |clean_up_resources_on_destruction| indicates whether the underlying OS |
| 130 // primitives are cleaned up on destruction. |
| 131 static SharedMemoryHandle DeepCopyOfHandle( |
| 132 const SharedMemoryHandle& handle, |
| 133 bool clean_up_resources_on_destruction); |
| 134 #endif |
| 135 |
119 // Creates a shared memory object as described by the options struct. | 136 // Creates a shared memory object as described by the options struct. |
120 // Returns true on success and false on failure. | 137 // Returns true on success and false on failure. |
121 bool Create(const SharedMemoryCreateOptions& options); | 138 bool Create(const SharedMemoryCreateOptions& options); |
122 | 139 |
123 // Creates and maps an anonymous shared memory segment of size size. | 140 // Creates and maps an anonymous shared memory segment of size size. |
124 // Returns true on success and false on failure. | 141 // Returns true on success and false on failure. |
125 bool CreateAndMapAnonymous(size_t size); | 142 bool CreateAndMapAnonymous(size_t size); |
126 | 143 |
127 // Creates an anonymous shared memory segment of size size. | 144 // Creates an anonymous shared memory segment of size size. |
128 // Returns true on success and false on failure. | 145 // Returns true on success and false on failure. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 334 } |
318 | 335 |
319 private: | 336 private: |
320 SharedMemory* shared_memory_; | 337 SharedMemory* shared_memory_; |
321 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); | 338 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); |
322 }; | 339 }; |
323 | 340 |
324 } // namespace base | 341 } // namespace base |
325 | 342 |
326 #endif // BASE_MEMORY_SHARED_MEMORY_H_ | 343 #endif // BASE_MEMORY_SHARED_MEMORY_H_ |
OLD | NEW |