Index: base/memory/shared_memory.h |
diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h |
index 23f6973374a0da00e1f1fb94cb99f8723ecae352..214afb7c0d71ea915977f9c00db18e0ba5854d5d 100644 |
--- a/base/memory/shared_memory.h |
+++ b/base/memory/shared_memory.h |
@@ -17,6 +17,7 @@ |
#include "base/base_export.h" |
#include "base/basictypes.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/process/process_handle.h" |
#if defined(OS_POSIX) |
@@ -80,6 +81,11 @@ class BASE_EXPORT SharedMemory { |
// Create a new SharedMemory object from an existing, open |
// shared memory file. |
+ // |
+ // WARNING: This does not reduce the OS-level permissions on the handle; it |
+ // only affects how the SharedMemory will be mmapped. TODO(jln,jyasskin): |
+ // remove this overload or DCHECK that read_only matches the permissions of |
+ // the handle. |
SharedMemory(SharedMemoryHandle handle, bool read_only); |
// Create a new SharedMemory object from an existing, open |
@@ -104,6 +110,11 @@ class BASE_EXPORT SharedMemory { |
// Returns the maximum number of handles that can be open at once per process. |
static size_t GetHandleLimit(); |
+ // Returns a new, read-only, unmapped SharedMemory with |contents| written |
+ // into it. Use this to send data to untrusted processes. Returns NULL if |
+ // creation fails. |
+ static scoped_ptr<SharedMemory> NewAnonymousReadOnly(StringPiece contents); |
+ |
// Creates a shared memory object as described by the options struct. |
// Returns true on success and false on failure. |
bool Create(const SharedMemoryCreateOptions& options); |