| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_SHARED_MEMORY_H_ | 5 #ifndef BASE_SHARED_MEMORY_H_ |
| 6 #define BASE_SHARED_MEMORY_H_ | 6 #define BASE_SHARED_MEMORY_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| 11 #include <sys/types.h> | 11 #include <sys/types.h> |
| 12 #include <semaphore.h> | 12 #include <semaphore.h> |
| 13 #include "base/file_descriptor_posix.h" | 13 #include "base/file_descriptor_posix.h" |
| 14 #endif | 14 #endif |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/process.h" | 18 #include "base/process.h" |
| 19 | 19 |
| 20 class FilePath; |
| 21 |
| 20 namespace base { | 22 namespace base { |
| 21 | 23 |
| 22 // SharedMemoryHandle is a platform specific type which represents | 24 // SharedMemoryHandle is a platform specific type which represents |
| 23 // the underlying OS handle to a shared memory segment. | 25 // the underlying OS handle to a shared memory segment. |
| 24 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 25 typedef HANDLE SharedMemoryHandle; | 27 typedef HANDLE SharedMemoryHandle; |
| 26 typedef HANDLE SharedMemoryLock; | 28 typedef HANDLE SharedMemoryLock; |
| 27 #elif defined(OS_POSIX) | 29 #elif defined(OS_POSIX) |
| 28 // A SharedMemoryId is sufficient to identify a given shared memory segment on a | 30 // A SharedMemoryId is sufficient to identify a given shared memory segment on a |
| 29 // system, but insufficient to map it. | 31 // system, but insufficient to map it. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // (futex, lockf+anon_semaphore) but none are both clean and common | 155 // (futex, lockf+anon_semaphore) but none are both clean and common |
| 154 // across Mac and Linux. | 156 // across Mac and Linux. |
| 155 void Lock(); | 157 void Lock(); |
| 156 | 158 |
| 157 // Release the shared memory lock. | 159 // Release the shared memory lock. |
| 158 void Unlock(); | 160 void Unlock(); |
| 159 | 161 |
| 160 private: | 162 private: |
| 161 #if defined(OS_POSIX) | 163 #if defined(OS_POSIX) |
| 162 bool CreateOrOpen(const std::wstring &name, int posix_flags, size_t size); | 164 bool CreateOrOpen(const std::wstring &name, int posix_flags, size_t size); |
| 163 bool FilenameForMemoryName(const std::wstring &memname, | 165 bool FilePathForMemoryName(const std::wstring& memname, FilePath* path); |
| 164 std::wstring *filename); | |
| 165 void LockOrUnlockCommon(int function); | 166 void LockOrUnlockCommon(int function); |
| 166 | 167 |
| 167 #endif | 168 #endif |
| 168 bool ShareToProcessCommon(ProcessHandle process, | 169 bool ShareToProcessCommon(ProcessHandle process, |
| 169 SharedMemoryHandle* new_handle, | 170 SharedMemoryHandle* new_handle, |
| 170 bool close_self); | 171 bool close_self); |
| 171 | 172 |
| 172 #if defined(OS_WIN) | 173 #if defined(OS_WIN) |
| 173 std::wstring name_; | 174 std::wstring name_; |
| 174 HANDLE mapped_file_; | 175 HANDLE mapped_file_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 200 } | 201 } |
| 201 | 202 |
| 202 private: | 203 private: |
| 203 SharedMemory* shared_memory_; | 204 SharedMemory* shared_memory_; |
| 204 DISALLOW_EVIL_CONSTRUCTORS(SharedMemoryAutoLock); | 205 DISALLOW_EVIL_CONSTRUCTORS(SharedMemoryAutoLock); |
| 205 }; | 206 }; |
| 206 | 207 |
| 207 } // namespace base | 208 } // namespace base |
| 208 | 209 |
| 209 #endif // BASE_SHARED_MEMORY_H_ | 210 #endif // BASE_SHARED_MEMORY_H_ |
| OLD | NEW |