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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/child_process_host_impl.h" 5 #include "content/common/child_process_host_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 178 }
179 179
180 bool ChildProcessHostImpl::Send(IPC::Message* message) { 180 bool ChildProcessHostImpl::Send(IPC::Message* message) {
181 if (!channel_) { 181 if (!channel_) {
182 delete message; 182 delete message;
183 return false; 183 return false;
184 } 184 }
185 return channel_->Send(message); 185 return channel_->Send(message);
186 } 186 }
187 187
188 void ChildProcessHostImpl::AllocateSharedMemory(
189 size_t buffer_size, base::ProcessHandle child_process_handle,
190 base::SharedMemoryHandle* shared_memory_handle) {
191 base::SharedMemory shared_buf;
192 if (!shared_buf.CreateAnonymous(buffer_size)) {
193 *shared_memory_handle = base::SharedMemory::NULLHandle();
194 NOTREACHED() << "Cannot create shared memory buffer";
195 return;
196 }
197 shared_buf.GiveToProcess(child_process_handle, shared_memory_handle);
198 }
199
188 int ChildProcessHostImpl::GenerateChildProcessUniqueId() { 200 int ChildProcessHostImpl::GenerateChildProcessUniqueId() {
189 // This function must be threadsafe. 201 // This function must be threadsafe.
190 // 202 //
191 // Historically, this function returned ids started with 1, so in several 203 // Historically, this function returned ids started with 1, so in several
192 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as 204 // places in the code a value of 0 (rather than kInvalidUniqueID) was used as
193 // an invalid value. So we retain those semantics. 205 // an invalid value. So we retain those semantics.
194 int id = g_unique_id.GetNext() + 1; 206 int id = g_unique_id.GetNext() + 1;
195 207
196 CHECK_NE(0, id); 208 CHECK_NE(0, id);
197 CHECK_NE(kInvalidUniqueID, id); 209 CHECK_NE(kInvalidUniqueID, id);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 handled = true; 248 handled = true;
237 break; 249 break;
238 } 250 }
239 } 251 }
240 252
241 if (!handled) { 253 if (!handled) {
242 handled = true; 254 handled = true;
243 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg) 255 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg)
244 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, 256 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
245 OnShutdownRequest) 257 OnShutdownRequest)
246 // NB: The SyncAllocateGpuMemoryBuffer and DeletedGpuMemoryBuffer IPCs are 258 // NB: The SyncAllocateSharedMemory, SyncAllocateGpuMemoryBuffer, and
247 // handled here for non-renderer child processes. For renderer processes, 259 // DeletedGpuMemoryBuffer IPCs are handled here for non-renderer child
248 // they are handled in RenderMessageFilter. 260 // processes. For renderer processes, they are handled in
261 // RenderMessageFilter.
262 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
263 OnAllocateSharedMemory)
249 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, 264 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
250 OnAllocateGpuMemoryBuffer) 265 OnAllocateGpuMemoryBuffer)
251 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer, 266 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer,
252 OnDeletedGpuMemoryBuffer) 267 OnDeletedGpuMemoryBuffer)
253 IPC_MESSAGE_UNHANDLED(handled = false) 268 IPC_MESSAGE_UNHANDLED(handled = false)
254 IPC_END_MESSAGE_MAP() 269 IPC_END_MESSAGE_MAP()
255 270
256 if (!handled) 271 if (!handled)
257 handled = delegate_->OnMessageReceived(msg); 272 handled = delegate_->OnMessageReceived(msg);
258 } 273 }
(...skipping 26 matching lines...) Expand all
285 filters_[i]->OnChannelError(); 300 filters_[i]->OnChannelError();
286 301
287 // This will delete host_, which will also destroy this! 302 // This will delete host_, which will also destroy this!
288 delegate_->OnChildDisconnected(); 303 delegate_->OnChildDisconnected();
289 } 304 }
290 305
291 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { 306 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) {
292 delegate_->OnBadMessageReceived(message); 307 delegate_->OnBadMessageReceived(message);
293 } 308 }
294 309
310 void ChildProcessHostImpl::OnAllocateSharedMemory(
311 uint32_t buffer_size,
312 base::SharedMemoryHandle* handle) {
313 AllocateSharedMemory(buffer_size, peer_process_.Handle(), handle);
314 }
315
295 void ChildProcessHostImpl::OnShutdownRequest() { 316 void ChildProcessHostImpl::OnShutdownRequest() {
296 if (delegate_->CanShutdown()) 317 if (delegate_->CanShutdown())
297 Send(new ChildProcessMsg_Shutdown()); 318 Send(new ChildProcessMsg_Shutdown());
298 } 319 }
299 320
300 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( 321 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer(
301 gfx::GpuMemoryBufferId id, 322 gfx::GpuMemoryBufferId id,
302 uint32_t width, 323 uint32_t width,
303 uint32_t height, 324 uint32_t height,
304 gfx::BufferFormat format, 325 gfx::BufferFormat format,
(...skipping 11 matching lines...) Expand all
316 } 337 }
317 338
318 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( 339 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
319 gfx::GpuMemoryBufferId id, 340 gfx::GpuMemoryBufferId id,
320 const gpu::SyncToken& sync_token) { 341 const gpu::SyncToken& sync_token) {
321 // Note: Nothing to do here as ownership of shared memory backed 342 // Note: Nothing to do here as ownership of shared memory backed
322 // GpuMemoryBuffers is passed with IPC. 343 // GpuMemoryBuffers is passed with IPC.
323 } 344 }
324 345
325 } // namespace content 346 } // namespace content
OLDNEW
« 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