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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 11469015: Renderer process can allocate anonymous shared memory without help from browser process on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 years 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/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
===================================================================
--- content/renderer/render_thread_impl.cc (revision 172434)
+++ content/renderer/render_thread_impl.cc (working copy)
@@ -719,12 +719,37 @@
Send(new ViewHostMsg_UserMetricsRecordAction(action));
}
-base::SharedMemoryHandle RenderThreadImpl::HostAllocateSharedMemoryBuffer(
- uint32 buffer_size) {
- base::SharedMemoryHandle mem_handle = base::SharedMemoryHandle();
- Send(new ChildProcessHostMsg_SyncAllocateSharedMemory(
- buffer_size, &mem_handle));
- return mem_handle;
+scoped_ptr<base::SharedMemory>
+ RenderThreadImpl::HostAllocateSharedMemoryBuffer(uint32 size) {
+ //if (!size)
+ // return scoped_ptr<base::SharedMemory>();
+
+//#if defined(OS_WIN)
+// scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
+// if (!shared_memory->CreateAnonymous(size))
+// return scoped_ptr<base::SharedMemory>();
+//
+// return scoped_ptr<base::SharedMemory>(shared_memory.release());
+//#else
+ base::SharedMemoryHandle handle;
+ bool success;
+ IPC::Message* message =
+ new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle);
+
+ // Allow calling this from the compositor thread.
+ if (MessageLoop::current() == message_loop())
+ success = ChildThread::Send(message);
+ else
+ success = sync_message_filter()->Send(message);
+
+ if (!success)
+ return scoped_ptr<base::SharedMemory>();
+
+ if (!base::SharedMemory::IsHandleValid(handle))
+ return scoped_ptr<base::SharedMemory>();
+
+ return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false));
+//#endif // defined(OS_WIN)
}
void RenderThreadImpl::RegisterExtension(v8::Extension* extension) {
@@ -910,23 +935,8 @@
scoped_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory(
uint32 size) {
- base::SharedMemoryHandle handle;
- bool success;
- IPC::Message* message =
- new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle);
-
- // Allow calling this from the compositor thread.
- if (MessageLoop::current() == message_loop())
- success = ChildThread::Send(message);
- else
- success = sync_message_filter()->Send(message);
-
- if (!success)
- return scoped_ptr<base::SharedMemory>();
-
- if (!base::SharedMemory::IsHandleValid(handle))
- return scoped_ptr<base::SharedMemory>();
- return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false));
+ return scoped_ptr<base::SharedMemory>(
+ HostAllocateSharedMemoryBuffer(size));
}
int32 RenderThreadImpl::CreateViewCommandBuffer(
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698