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

Unified Diff: content/common/child_process_host_impl.cc

Issue 2491763003: Revert of Removing the ChildProcessHostMsg_SyncAllocateSharedMemory IPC message. (Closed)
Patch Set: Created 4 years, 1 month 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_process_host_impl.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/child_process_host_impl.cc
diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc
index 59325c330ddfeece1e2a14bdcd3a87c708736a7a..71a34fcc6d9e244060725270f20ecda6b6fa252a 100644
--- a/content/common/child_process_host_impl.cc
+++ b/content/common/child_process_host_impl.cc
@@ -185,6 +185,18 @@
return channel_->Send(message);
}
+void ChildProcessHostImpl::AllocateSharedMemory(
+ size_t buffer_size, base::ProcessHandle child_process_handle,
+ base::SharedMemoryHandle* shared_memory_handle) {
+ base::SharedMemory shared_buf;
+ if (!shared_buf.CreateAnonymous(buffer_size)) {
+ *shared_memory_handle = base::SharedMemory::NULLHandle();
+ NOTREACHED() << "Cannot create shared memory buffer";
+ return;
+ }
+ shared_buf.GiveToProcess(child_process_handle, shared_memory_handle);
+}
+
int ChildProcessHostImpl::GenerateChildProcessUniqueId() {
// This function must be threadsafe.
//
@@ -243,9 +255,12 @@
IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
OnShutdownRequest)
- // NB: The SyncAllocateGpuMemoryBuffer and DeletedGpuMemoryBuffer IPCs are
- // handled here for non-renderer child processes. For renderer processes,
- // they are handled in RenderMessageFilter.
+ // NB: The SyncAllocateSharedMemory, SyncAllocateGpuMemoryBuffer, and
+ // DeletedGpuMemoryBuffer IPCs are handled here for non-renderer child
+ // processes. For renderer processes, they are handled in
+ // RenderMessageFilter.
+ IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
+ OnAllocateSharedMemory)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
OnAllocateGpuMemoryBuffer)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer,
@@ -290,6 +305,12 @@
void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) {
delegate_->OnBadMessageReceived(message);
+}
+
+void ChildProcessHostImpl::OnAllocateSharedMemory(
+ uint32_t buffer_size,
+ base::SharedMemoryHandle* handle) {
+ AllocateSharedMemory(buffer_size, peer_process_.Handle(), handle);
}
void ChildProcessHostImpl::OnShutdownRequest() {
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698