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

Unified Diff: mojo/system/raw_shared_buffer.cc

Issue 304233005: Mojo: Implement passing of shared buffers across processes on POSIX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 7 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 | « mojo/system/raw_shared_buffer.h ('k') | mojo/system/raw_shared_buffer_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/raw_shared_buffer.cc
diff --git a/mojo/system/raw_shared_buffer.cc b/mojo/system/raw_shared_buffer.cc
index fb67cca71a77e8cfb3ddee8f13c7c3fbc50a45ec..e6e3ebce2390eb7525da0c6c59b7cd53085818c4 100644
--- a/mojo/system/raw_shared_buffer.cc
+++ b/mojo/system/raw_shared_buffer.cc
@@ -5,6 +5,7 @@
#include "mojo/system/raw_shared_buffer.h"
#include "base/logging.h"
+#include "mojo/embedder/platform_handle_utils.h"
namespace mojo {
namespace system {
@@ -14,9 +15,28 @@ RawSharedBuffer* RawSharedBuffer::Create(size_t num_bytes) {
DCHECK_GT(num_bytes, 0u);
RawSharedBuffer* rv = new RawSharedBuffer(num_bytes);
- // No need to take the lock since we haven't given the object to anyone yet.
- if (!rv->InitNoLock())
+ if (!rv->Init()) {
+ // We can't just delete it directly, due to the "in destructor" (debug)
+ // check.
+ scoped_refptr<RawSharedBuffer> deleter(rv);
return NULL;
+ }
+
+ return rv;
+}
+
+RawSharedBuffer* RawSharedBuffer::CreateFromPlatformHandle(
+ size_t num_bytes,
+ embedder::ScopedPlatformHandle platform_handle) {
+ DCHECK_GT(num_bytes, 0u);
+
+ RawSharedBuffer* rv = new RawSharedBuffer(num_bytes);
+ if (!rv->InitFromPlatformHandle(platform_handle.Pass())) {
+ // We can't just delete it directly, due to the "in destructor" (debug)
+ // check.
+ scoped_refptr<RawSharedBuffer> deleter(rv);
+ return NULL;
+ }
return rv;
}
@@ -44,9 +64,16 @@ bool RawSharedBuffer::IsValidMap(size_t offset, size_t length) {
scoped_ptr<RawSharedBufferMapping> RawSharedBuffer::MapNoCheck(size_t offset,
size_t length) {
DCHECK(IsValidMap(offset, length));
+ return MapImpl(offset, length);
+}
+
+embedder::ScopedPlatformHandle RawSharedBuffer::DuplicatePlatformHandle() {
+ return embedder::DuplicatePlatformHandle(handle_.get());
+}
- base::AutoLock locker(lock_);
- return MapImplNoLock(offset, length);
+embedder::ScopedPlatformHandle RawSharedBuffer::PassPlatformHandle() {
+ DCHECK(HasOneRef());
+ return handle_.Pass();
}
RawSharedBuffer::RawSharedBuffer(size_t num_bytes) : num_bytes_(num_bytes) {
« no previous file with comments | « mojo/system/raw_shared_buffer.h ('k') | mojo/system/raw_shared_buffer_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698