| OLD | NEW |
| 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/hash.h" | 12 #include "base/hash.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/numerics/safe_math.h" | 16 #include "base/numerics/safe_math.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/process/process_metrics.h" | 18 #include "base/process/process_metrics.h" |
| 19 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
| 22 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 22 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "content/common/child_process_messages.h" | 25 #include "content/common/child_process_messages.h" |
| 26 #include "content/public/common/child_process_host_delegate.h" | 26 #include "content/public/common/child_process_host_delegate.h" |
| 27 #include "content/public/common/content_paths.h" | 27 #include "content/public/common/content_paths.h" |
| 28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 29 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | |
| 30 #include "ipc/ipc.mojom.h" | 29 #include "ipc/ipc.mojom.h" |
| 31 #include "ipc/ipc_channel.h" | 30 #include "ipc/ipc_channel.h" |
| 32 #include "ipc/ipc_channel_mojo.h" | 31 #include "ipc/ipc_channel_mojo.h" |
| 33 #include "ipc/ipc_logging.h" | 32 #include "ipc/ipc_logging.h" |
| 34 #include "ipc/message_filter.h" | 33 #include "ipc/message_filter.h" |
| 35 #include "mojo/edk/embedder/embedder.h" | 34 #include "mojo/edk/embedder/embedder.h" |
| 36 #include "services/service_manager/public/cpp/interface_provider.h" | 35 #include "services/service_manager/public/cpp/interface_provider.h" |
| 37 | 36 |
| 38 #if defined(OS_LINUX) | 37 #if defined(OS_LINUX) |
| 39 #include "base/linux_util.h" | 38 #include "base/linux_util.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 handled = true; | 235 handled = true; |
| 237 break; | 236 break; |
| 238 } | 237 } |
| 239 } | 238 } |
| 240 | 239 |
| 241 if (!handled) { | 240 if (!handled) { |
| 242 handled = true; | 241 handled = true; |
| 243 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg) | 242 IPC_BEGIN_MESSAGE_MAP(ChildProcessHostImpl, msg) |
| 244 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, | 243 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, |
| 245 OnShutdownRequest) | 244 OnShutdownRequest) |
| 246 // NB: The SyncAllocateGpuMemoryBuffer and DeletedGpuMemoryBuffer IPCs are | |
| 247 // handled here for non-renderer child processes. For renderer processes, | |
| 248 // they are handled in RenderMessageFilter. | |
| 249 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, | |
| 250 OnAllocateGpuMemoryBuffer) | |
| 251 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer, | |
| 252 OnDeletedGpuMemoryBuffer) | |
| 253 IPC_MESSAGE_UNHANDLED(handled = false) | 245 IPC_MESSAGE_UNHANDLED(handled = false) |
| 254 IPC_END_MESSAGE_MAP() | 246 IPC_END_MESSAGE_MAP() |
| 255 | 247 |
| 256 if (!handled) | 248 if (!handled) |
| 257 handled = delegate_->OnMessageReceived(msg); | 249 handled = delegate_->OnMessageReceived(msg); |
| 258 } | 250 } |
| 259 | 251 |
| 260 #ifdef IPC_MESSAGE_LOG_ENABLED | 252 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 261 if (logger->Enabled()) | 253 if (logger->Enabled()) |
| 262 logger->OnPostDispatchMessage(msg); | 254 logger->OnPostDispatchMessage(msg); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 290 | 282 |
| 291 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { | 283 void ChildProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { |
| 292 delegate_->OnBadMessageReceived(message); | 284 delegate_->OnBadMessageReceived(message); |
| 293 } | 285 } |
| 294 | 286 |
| 295 void ChildProcessHostImpl::OnShutdownRequest() { | 287 void ChildProcessHostImpl::OnShutdownRequest() { |
| 296 if (delegate_->CanShutdown()) | 288 if (delegate_->CanShutdown()) |
| 297 Send(new ChildProcessMsg_Shutdown()); | 289 Send(new ChildProcessMsg_Shutdown()); |
| 298 } | 290 } |
| 299 | 291 |
| 300 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( | |
| 301 gfx::GpuMemoryBufferId id, | |
| 302 uint32_t width, | |
| 303 uint32_t height, | |
| 304 gfx::BufferFormat format, | |
| 305 gfx::BufferUsage usage, | |
| 306 gfx::GpuMemoryBufferHandle* handle) { | |
| 307 // TODO(reveman): Add support for other types of GpuMemoryBuffers. | |
| 308 | |
| 309 // AllocateGpuMemoryBuffer() will check if |width| and |height| are valid | |
| 310 // and handle failure in a controlled way when not. We just need to make | |
| 311 // sure |usage| is supported here. | |
| 312 if (gpu::GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) { | |
| 313 *handle = gpu::GpuMemoryBufferImplSharedMemory::AllocateGpuMemoryBuffer( | |
| 314 id, gfx::Size(width, height), format); | |
| 315 } | |
| 316 } | |
| 317 | |
| 318 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( | |
| 319 gfx::GpuMemoryBufferId id, | |
| 320 const gpu::SyncToken& sync_token) { | |
| 321 // Note: Nothing to do here as ownership of shared memory backed | |
| 322 // GpuMemoryBuffers is passed with IPC. | |
| 323 } | |
| 324 | |
| 325 } // namespace content | 292 } // namespace content |
| OLD | NEW |