| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #if defined(OS_POSIX) | 11 #if defined(OS_POSIX) |
| 12 #include <sys/types.h> | 12 #include <sys/types.h> |
| 13 #include <semaphore.h> | 13 #include <semaphore.h> |
| 14 #include "base/file_descriptor_posix.h" | 14 #include "base/file_descriptor_posix.h" |
| 15 #endif | 15 #endif |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/base_api.h" | 18 #include "base/base_export.h" |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/process.h" | 20 #include "base/process.h" |
| 21 | 21 |
| 22 class FilePath; | 22 class FilePath; |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 | 25 |
| 26 // SharedMemoryHandle is a platform specific type which represents | 26 // SharedMemoryHandle is a platform specific type which represents |
| 27 // the underlying OS handle to a shared memory segment. | 27 // the underlying OS handle to a shared memory segment. |
| 28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 29 typedef HANDLE SharedMemoryHandle; | 29 typedef HANDLE SharedMemoryHandle; |
| 30 typedef HANDLE SharedMemoryLock; | 30 typedef HANDLE SharedMemoryLock; |
| 31 #elif defined(OS_POSIX) | 31 #elif defined(OS_POSIX) |
| 32 // A SharedMemoryId is sufficient to identify a given shared memory segment on a | 32 // A SharedMemoryId is sufficient to identify a given shared memory segment on a |
| 33 // system, but insufficient to map it. | 33 // system, but insufficient to map it. |
| 34 typedef FileDescriptor SharedMemoryHandle; | 34 typedef FileDescriptor SharedMemoryHandle; |
| 35 typedef ino_t SharedMemoryId; | 35 typedef ino_t SharedMemoryId; |
| 36 // On POSIX, the lock is implemented as a lockf() on the mapped file, | 36 // On POSIX, the lock is implemented as a lockf() on the mapped file, |
| 37 // so no additional member (or definition of SharedMemoryLock) is | 37 // so no additional member (or definition of SharedMemoryLock) is |
| 38 // needed. | 38 // needed. |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 // Platform abstraction for shared memory. Provides a C++ wrapper | 41 // Platform abstraction for shared memory. Provides a C++ wrapper |
| 42 // around the OS primitive for a memory mapped file. | 42 // around the OS primitive for a memory mapped file. |
| 43 class BASE_API SharedMemory { | 43 class BASE_EXPORT SharedMemory { |
| 44 public: | 44 public: |
| 45 SharedMemory(); | 45 SharedMemory(); |
| 46 | 46 |
| 47 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 48 // Similar to the default constructor, except that this allows for | 48 // Similar to the default constructor, except that this allows for |
| 49 // calling Lock() to acquire the named mutex before either Create or Open | 49 // calling Lock() to acquire the named mutex before either Create or Open |
| 50 // are called on Windows. | 50 // are called on Windows. |
| 51 explicit SharedMemory(const std::wstring& name); | 51 explicit SharedMemory(const std::wstring& name); |
| 52 #endif | 52 #endif |
| 53 | 53 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 | 227 |
| 228 private: | 228 private: |
| 229 SharedMemory* shared_memory_; | 229 SharedMemory* shared_memory_; |
| 230 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLock); | 230 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLock); |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 } // namespace base | 233 } // namespace base |
| 234 | 234 |
| 235 #endif // BASE_SHARED_MEMORY_H_ | 235 #endif // BASE_SHARED_MEMORY_H_ |
| OLD | NEW |