Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: base/memory/shared_memory.h

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/memory_pressure_monitor_win_unittest.cc ('k') | base/memory/shared_memory_nacl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory.h
diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h
index d76e01c6e57612024fe35dc7c430229d89cd5112..008bb0106688c56f66e7edea893de42b5c5c0f5a 100644
--- a/base/memory/shared_memory.h
+++ b/base/memory/shared_memory.h
@@ -34,10 +34,7 @@ class FilePath;
#if defined(OS_WIN)
typedef HANDLE SharedMemoryHandle;
#elif defined(OS_POSIX)
-// A SharedMemoryId is sufficient to identify a given shared memory segment on a
-// system, but insufficient to map it.
typedef FileDescriptor SharedMemoryHandle;
-typedef ino_t SharedMemoryId;
#endif
// Options for creating a shared memory object.
@@ -116,6 +113,21 @@ class BASE_EXPORT SharedMemory {
// Returns the maximum number of handles that can be open at once per process.
static size_t GetHandleLimit();
+ // Duplicates The underlying OS primitive. Returns NULLHandle() on failure.
+ // The caller is responsible for destroying the duplicated OS primitive.
+ static SharedMemoryHandle DuplicateHandle(const SharedMemoryHandle& handle);
+
+#if defined(OS_POSIX)
+ // This method requires that the SharedMemoryHandle is backed by a POSIX fd.
+ static int GetFdFromSharedMemoryHandle(const SharedMemoryHandle& handle);
+#endif
+
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ // Returns the size of the shared memory region referred to by |handle|.
+ // Returns '-1' on a failure to determine the size.
+ static int GetSizeFromSharedMemoryHandle(const SharedMemoryHandle& handle);
+#endif // defined(OS_POSIX) && !defined(OS_ANDROID)
+
// Creates a shared memory object as described by the options struct.
// Returns true on success and false on failure.
bool Create(const SharedMemoryCreateOptions& options);
@@ -192,14 +204,6 @@ class BASE_EXPORT SharedMemory {
// identifier is not portable.
SharedMemoryHandle handle() const;
-#if defined(OS_POSIX) && !defined(OS_NACL)
- // Returns a unique identifier for this shared memory segment. Inode numbers
- // are technically only unique to a single filesystem. However, we always
- // allocate shared memory backing files from the same directory, so will end
- // up on the same filesystem.
- SharedMemoryId id() const { return inode_; }
-#endif
-
// Closes the open shared memory segment. The memory will remain mapped if
// it was previously mapped.
// It is safe to call Close repeatedly.
@@ -289,7 +293,6 @@ class BASE_EXPORT SharedMemory {
#elif defined(OS_POSIX)
int mapped_file_;
int readonly_mapped_file_;
- ino_t inode_;
#endif
size_t mapped_size_;
void* memory_;
« no previous file with comments | « base/memory/memory_pressure_monitor_win_unittest.cc ('k') | base/memory/shared_memory_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698