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> |
11 | 11 |
12 #if defined(OS_POSIX) | 12 #if defined(OS_POSIX) |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 #include <sys/types.h> | 14 #include <sys/types.h> |
15 #include <semaphore.h> | 15 #include <semaphore.h> |
16 #endif | 16 #endif |
17 | 17 |
18 #include "base/base_export.h" | 18 #include "base/base_export.h" |
19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
20 #include "base/process/process_handle.h" | 20 #include "base/process/process_handle.h" |
21 | 21 |
22 #if defined(OS_POSIX) | 22 #if defined(OS_POSIX) |
23 #include "base/file_descriptor_posix.h" | 23 #include "base/file_descriptor_posix.h" |
24 #include "base/file_util.h" | 24 #include "base/file_util.h" |
25 #include "base/files/scoped_file.h" | |
26 #endif | 25 #endif |
27 | 26 |
28 namespace base { | 27 namespace base { |
29 | 28 |
30 class FilePath; | 29 class FilePath; |
31 | 30 |
32 // SharedMemoryHandle is a platform specific type which represents | 31 // SharedMemoryHandle is a platform specific type which represents |
33 // the underlying OS handle to a shared memory segment. | 32 // the underlying OS handle to a shared memory segment. |
34 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
35 typedef HANDLE SharedMemoryHandle; | 34 typedef HANDLE SharedMemoryHandle; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // used in inner loops, so we protect against multiple threads in a | 252 // used in inner loops, so we protect against multiple threads in a |
254 // critical section using a class global lock. | 253 // critical section using a class global lock. |
255 void LockDeprecated(); | 254 void LockDeprecated(); |
256 | 255 |
257 // DEPRECATED (crbug.com/345734): | 256 // DEPRECATED (crbug.com/345734): |
258 // Releases the shared memory lock. | 257 // Releases the shared memory lock. |
259 void UnlockDeprecated(); | 258 void UnlockDeprecated(); |
260 | 259 |
261 private: | 260 private: |
262 #if defined(OS_POSIX) && !defined(OS_NACL) | 261 #if defined(OS_POSIX) && !defined(OS_NACL) |
263 bool PrepareMapFile(file_util::ScopedFILE fp, base::ScopedFD readonly); | 262 bool PrepareMapFile(file_util::ScopedFILE fp, file_util::ScopedFD readonly); |
264 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); | 263 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); |
265 void LockOrUnlockCommon(int function); | 264 void LockOrUnlockCommon(int function); |
266 #endif | 265 #endif |
267 enum ShareMode { | 266 enum ShareMode { |
268 SHARE_READONLY, | 267 SHARE_READONLY, |
269 SHARE_CURRENT_MODE, | 268 SHARE_CURRENT_MODE, |
270 }; | 269 }; |
271 bool ShareToProcessCommon(ProcessHandle process, | 270 bool ShareToProcessCommon(ProcessHandle process, |
272 SharedMemoryHandle* new_handle, | 271 SharedMemoryHandle* new_handle, |
273 bool close_self, | 272 bool close_self, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 306 } |
308 | 307 |
309 private: | 308 private: |
310 SharedMemory* shared_memory_; | 309 SharedMemory* shared_memory_; |
311 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); | 310 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLockDeprecated); |
312 }; | 311 }; |
313 | 312 |
314 } // namespace base | 313 } // namespace base |
315 | 314 |
316 #endif // BASE_MEMORY_SHARED_MEMORY_H_ | 315 #endif // BASE_MEMORY_SHARED_MEMORY_H_ |
OLD | NEW |