| Index: base/memory/shared_memory.h
|
| diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h
|
| index f68c861647c88c1c5ccc280063cecd8a7cf6c05c..c7bf7636a981ee30f9ffe400019702259b60f619 100644
|
| --- a/base/memory/shared_memory.h
|
| +++ b/base/memory/shared_memory.h
|
| @@ -34,7 +34,10 @@ class FilePath;
|
|
|
| // Options for creating a shared memory object.
|
| struct BASE_EXPORT SharedMemoryCreateOptions {
|
| -#if !(defined(OS_MACOSX) && !defined(OS_IOS))
|
| +#if defined(OS_MACOSX) && !defined(OS_IOS)
|
| + // The type of OS primitive that should back the SharedMemory object.
|
| + SharedMemoryHandle::Type type = SharedMemoryHandle::MACH;
|
| +#else
|
| // DEPRECATED (crbug.com/345734):
|
| // If NULL, the object is anonymous. This pointer is owned by the caller
|
| // and must live through the call to Create().
|
| @@ -46,7 +49,7 @@ struct BASE_EXPORT SharedMemoryCreateOptions {
|
| // shared memory must not exist. This flag is meaningless unless
|
| // name_deprecated is non-NULL.
|
| bool open_existing_deprecated = false;
|
| -#endif // !(defined(OS_MACOSX) && !defined(OS_IOS))
|
| +#endif // defined(OS_MACOSX) && !defined(OS_IOS)
|
|
|
| // Size of the shared memory object to be created.
|
| // When opening an existing object, this has no effect.
|
| @@ -101,7 +104,7 @@ class BASE_EXPORT SharedMemory {
|
| // The caller is responsible for destroying the duplicated OS primitive.
|
| static SharedMemoryHandle DuplicateHandle(const SharedMemoryHandle& handle);
|
|
|
| -#if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS))
|
| +#if defined(OS_POSIX)
|
| // This method requires that the SharedMemoryHandle is backed by a POSIX fd.
|
| static int GetFdFromSharedMemoryHandle(const SharedMemoryHandle& handle);
|
| #endif
|
| @@ -122,6 +125,16 @@ class BASE_EXPORT SharedMemory {
|
| // Returns true on success and false on failure.
|
| bool CreateAndMapAnonymous(size_t size);
|
|
|
| +#if defined(OS_MACOSX) && !defined(OS_IOS)
|
| + // These two methods are analogs of CreateAndMapAnonymous and CreateAnonymous
|
| + // that force the underlying OS primitive to be a POSIX fd. Do not add new
|
| + // uses of these methods unless absolutely necessary, since constructing a
|
| + // fd-backed SharedMemory object frequently takes 100ms+.
|
| + // http://crbug.com/466437
|
| + bool CreateAndMapAnonymousPosix(size_t size);
|
| + bool CreateAnonymousPosix(size_t size);
|
| +#endif // defined(OS_MACOSX) && !defined(OS_IOS)
|
| +
|
| // Creates an anonymous shared memory segment of size size.
|
| // Returns true on success and false on failure.
|
| bool CreateAnonymous(size_t size) {
|
| @@ -253,11 +266,12 @@ class BASE_EXPORT SharedMemory {
|
| }
|
|
|
| private:
|
| -#if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \
|
| - !(defined(OS_MACOSX) && !defined(OS_IOS))
|
| +#if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID)
|
| bool PrepareMapFile(ScopedFILE fp, ScopedFD readonly);
|
| +#if !(defined(OS_MACOSX) && !defined(OS_IOS))
|
| bool FilePathForMemoryName(const std::string& mem_name, FilePath* path);
|
| #endif
|
| +#endif // defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID)
|
| enum ShareMode {
|
| SHARE_READONLY,
|
| SHARE_CURRENT_MODE,
|
| @@ -276,6 +290,12 @@ class BASE_EXPORT SharedMemory {
|
| #elif defined(OS_MACOSX) && !defined(OS_IOS)
|
| // The OS primitive that backs the shared memory region.
|
| SharedMemoryHandle shm_;
|
| +
|
| + // The mechanism by which the memory is mapped. Only valid if |memory_| is not
|
| + // |nullptr|.
|
| + SharedMemoryHandle::Type mapped_memory_mechanism_;
|
| +
|
| + int readonly_mapped_file_;
|
| #elif defined(OS_POSIX)
|
| int mapped_file_;
|
| int readonly_mapped_file_;
|
|
|