| Index: base/memory/shared_memory.h
|
| diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h
|
| index b7e5a050603d52fce8e41b513c13454b2e5c6be6..13238aabacb1fb4f6924f4bf9b596e9517952861 100644
|
| --- a/base/memory/shared_memory.h
|
| +++ b/base/memory/shared_memory.h
|
| @@ -32,7 +32,10 @@
|
| struct BASE_EXPORT SharedMemoryCreateOptions {
|
| 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;
|
| +#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().
|
| @@ -44,7 +47,7 @@
|
| // shared memory must not exist. This flag is meaningless unless
|
| // name_deprecated is non-NULL.
|
| bool open_existing_deprecated;
|
| -#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.
|
| @@ -99,7 +102,7 @@
|
| // 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
|
| @@ -119,6 +122,16 @@
|
| // Creates and maps an anonymous shared memory segment of size size.
|
| // 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.
|
| @@ -244,11 +257,12 @@
|
| }
|
|
|
| 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,
|
| @@ -268,6 +282,10 @@
|
| // 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_;
|
|
|