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

Unified Diff: base/memory/shared_memory.h

Issue 27265002: Implement SharedMemory::NewAnonymousReadOnly(contents). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix signedness on Mac Created 7 years, 2 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 | « no previous file | base/memory/shared_memory_posix.cc » ('j') | base/memory/shared_memory_unittest.cc » ('J')
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 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);
« no previous file with comments | « no previous file | base/memory/shared_memory_posix.cc » ('j') | base/memory/shared_memory_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698