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

Side by Side Diff: content/common/child_process_host_impl.cc

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: address review feedback Created 6 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 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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/numerics/safe_math.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/process/process_metrics.h" 16 #include "base/process/process_metrics.h"
16 #include "base/rand_util.h" 17 #include "base/rand_util.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 19 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
19 #include "content/common/child_process_messages.h" 20 #include "content/common/child_process_messages.h"
20 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 21 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
21 #include "content/public/common/child_process_host_delegate.h" 22 #include "content/public/common/child_process_host_delegate.h"
22 #include "content/public/common/content_paths.h" 23 #include "content/public/common/content_paths.h"
23 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
24 #include "ipc/ipc_channel.h" 25 #include "ipc/ipc_channel.h"
25 #include "ipc/ipc_logging.h" 26 #include "ipc/ipc_logging.h"
26 #include "ipc/message_filter.h" 27 #include "ipc/message_filter.h"
27 28
28 #if defined(OS_LINUX) 29 #if defined(OS_LINUX)
29 #include "base/linux_util.h" 30 #include "base/linux_util.h"
30 #elif defined(OS_WIN) 31 #elif defined(OS_WIN)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 247 }
247 } 248 }
248 249
249 if (!handled) { 250 if (!handled) {
250 handled = true; 251 handled = true;
251 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg) 252 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg)
252 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, 253 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
253 OnShutdownRequest) 254 OnShutdownRequest)
254 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory, 255 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
255 OnAllocateSharedMemory) 256 OnAllocateSharedMemory)
256 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, 257 IPC_MESSAGE_HANDLER_DELAY_REPLY(
257 OnAllocateGpuMemoryBuffer) 258 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
259 OnAllocateGpuMemoryBuffer)
260 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer,
261 OnDeletedGpuMemoryBuffer)
258 IPC_MESSAGE_UNHANDLED(handled = false) 262 IPC_MESSAGE_UNHANDLED(handled = false)
259 IPC_END_MESSAGE_MAP() 263 IPC_END_MESSAGE_MAP()
260 264
261 if (!handled) 265 if (!handled)
262 handled = delegate_->OnMessageReceived(msg); 266 handled = delegate_->OnMessageReceived(msg);
263 } 267 }
264 268
265 #ifdef IPC_MESSAGE_LOG_ENABLED 269 #ifdef IPC_MESSAGE_LOG_ENABLED
266 if (logger->Enabled()) 270 if (logger->Enabled())
267 logger->OnPostDispatchMessage(msg, channel_id_); 271 logger->OnPostDispatchMessage(msg, channel_id_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 307 }
304 308
305 void ChildProcessHostImpl::OnShutdownRequest() { 309 void ChildProcessHostImpl::OnShutdownRequest() {
306 if (delegate_->CanShutdown()) 310 if (delegate_->CanShutdown())
307 Send(new ChildProcessMsg_Shutdown()); 311 Send(new ChildProcessMsg_Shutdown());
308 } 312 }
309 313
310 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( 314 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer(
311 uint32 width, 315 uint32 width,
312 uint32 height, 316 uint32 height,
313 uint32 internalformat, 317 gfx::GpuMemoryBuffer::Format format,
314 uint32 usage, 318 gfx::GpuMemoryBuffer::Usage usage,
315 gfx::GpuMemoryBufferHandle* handle) { 319 IPC::Message* reply) {
316 handle->type = gfx::SHARED_MEMORY_BUFFER; 320 base::CheckedNumeric<int> size = width;
317 AllocateSharedMemory( 321 size *= height;
318 width * height * GpuMemoryBufferImpl::BytesPerPixel(internalformat), 322 if (!size.IsValid()) {
323 GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle());
324 return;
325 }
326
327 // TODO(reveman): Add support for other types of GpuMemoryBuffers.
328 if (!GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
329 gfx::Size(width, height), format, usage)) {
330 GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle());
331 return;
332 }
333
334 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
335 gfx::Size(width, height),
336 format,
319 peer_handle_, 337 peer_handle_,
320 &handle->handle); 338 base::Bind(&ChildProcessHostImpl::GpuMemoryBufferAllocated,
339 base::Unretained(this),
piman 2014/10/10 02:58:42 nit: can you add a comment that unretained is safe
reveman 2014/10/10 12:47:44 Done.
340 reply));
341 }
342
343 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
344 gfx::GpuMemoryBufferType type,
345 const gfx::GpuMemoryBufferId& id) {
346 // Note: Nothing to do here as ownership of shared memory backed
347 // GpuMemoryBuffers is passed with IPC.
348 }
349
350 void ChildProcessHostImpl::GpuMemoryBufferAllocated(
351 IPC::Message* reply,
352 const gfx::GpuMemoryBufferHandle& handle) {
353 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply,
354 handle);
355 Send(reply);
321 } 356 }
322 357
323 } // namespace content 358 } // 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