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

Unified Diff: content/common/child_thread.cc

Issue 8229039: Make shared memory allocation possible for all child process types. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | « content/common/child_thread.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/child_thread.cc
===================================================================
--- content/common/child_thread.cc (revision 105562)
+++ content/common/child_thread.cc (working copy)
@@ -125,6 +125,39 @@
return resource_dispatcher()->CreateBridge(request_info);
}
+base::SharedMemory* ChildThread::AllocateSharedMemory(
+ size_t buf_size) {
+ scoped_ptr<base::SharedMemory> shared_buf;
+#if defined(OS_WIN)
+ shared_buf.reset(new base::SharedMemory);
+ if (!shared_buf->CreateAndMapAnonymous(buf_size)) {
+ NOTREACHED();
+ return NULL;
+ }
+#else
+ // On POSIX, we need to ask the browser to create the shared memory for us,
+ // since this is blocked by the sandbox.
+ base::SharedMemoryHandle shared_mem_handle;
+ if (Send(new ChildProcessHostMsg_SyncAllocateSharedMemory(
+ buf_size, &shared_mem_handle))) {
+ if (base::SharedMemory::IsHandleValid(shared_mem_handle)) {
+ shared_buf.reset(new base::SharedMemory(shared_mem_handle, false));
+ if (!shared_buf->Map(buf_size)) {
+ NOTREACHED() << "Map failed";
+ return NULL;
+ }
+ } else {
+ NOTREACHED() << "Browser failed to allocate shared memory";
+ return NULL;
+ }
+ } else {
+ NOTREACHED() << "Browser allocation request message failed";
+ return NULL;
+ }
+#endif
+ return shared_buf.release();
+}
+
ResourceDispatcher* ChildThread::resource_dispatcher() {
return resource_dispatcher_.get();
}
« no previous file with comments | « content/common/child_thread.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698