Index: mojo/system/raw_shared_buffer.h |
diff --git a/mojo/system/raw_shared_buffer.h b/mojo/system/raw_shared_buffer.h |
index 863584f2ad5346953ce08f56e4d34f4af8f72a33..ba163e072625170400d98e10d7013bcbc0975625 100644 |
--- a/mojo/system/raw_shared_buffer.h |
+++ b/mojo/system/raw_shared_buffer.h |
@@ -37,11 +37,14 @@ class RawSharedBufferMapping; |
class MOJO_SYSTEM_IMPL_EXPORT RawSharedBuffer |
: public base::RefCountedThreadSafe<RawSharedBuffer> { |
public: |
- |
// Creates a shared buffer of size |num_bytes| bytes (initially zero-filled). |
// |num_bytes| must be nonzero. Returns null on failure. |
static RawSharedBuffer* Create(size_t num_bytes); |
+ static RawSharedBuffer* CreateFromPlatformHandle( |
+ size_t num_bytes, |
+ embedder::ScopedPlatformHandle platform_handle); |
+ |
// Maps (some) of the shared buffer into memory; [|offset|, |offset + length|] |
// must be contained in [0, |num_bytes|], and |length| must be at least 1. |
// Returns null on failure. |
@@ -54,6 +57,15 @@ class MOJO_SYSTEM_IMPL_EXPORT RawSharedBuffer |
// preflighted using |IsValidMap()|). |
scoped_ptr<RawSharedBufferMapping> MapNoCheck(size_t offset, size_t length); |
+ // Duplicates the underlying platform handle and passes it to the caller. |
+ embedder::ScopedPlatformHandle DuplicatePlatformHandle(); |
+ |
+ // Passes the underlying platform handle to the caller. This should only be |
+ // called if there's a unique reference to this object (owned by the caller). |
+ // After calling this, this object should no longer be used, but should only |
+ // be disposed of. |
+ embedder::ScopedPlatformHandle PassPlatformHandle(); |
+ |
size_t num_bytes() const { return num_bytes_; } |
private: |
@@ -62,10 +74,18 @@ class MOJO_SYSTEM_IMPL_EXPORT RawSharedBuffer |
explicit RawSharedBuffer(size_t num_bytes); |
~RawSharedBuffer(); |
+ // Implemented in raw_shared_buffer_{posix,win}.cc: |
+ |
// This is called by |Create()| before this object is given to anyone (hence |
// it doesn't need to take |lock_|). |
bool InitNoLock(); |
+ // This is like |InitNoLoock()|, but for |CreateFromPlatformHandle()|. (Note: |
+ // It should verify that |platform_handle| is an appropriate handle for the |
+ // claimed |num_bytes_|.) |
+ bool InitFromPlatformHandleNoLock( |
+ embedder::ScopedPlatformHandle platform_handle); |
+ |
// The platform-dependent part of |Map()|; doesn't check arguments. Called |
// under |lock_|. |
scoped_ptr<RawSharedBufferMapping> MapImplNoLock(size_t offset, |