| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/gpu/gpu_arc_video_service_host.h" | 5 #include "content/browser/gpu/gpu_arc_video_service_host.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/browser/gpu/gpu_process_host.h" | 10 #include "content/browser/gpu/gpu_process_host.h" |
| 11 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
| 12 #include "content/public/browser/arc_video_host_delegate.h" | 12 #include "content/public/browser/arc_video_host_delegate.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "ipc/ipc_channel_handle.h" | 14 #include "ipc/ipc_channel_handle.h" |
| 15 #include "ipc/ipc_message_macros.h" | 15 #include "ipc/ipc_message_macros.h" |
| 16 #include "ipc/ipc_message_utils.h" | 16 #include "ipc/ipc_message_utils.h" |
| 17 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 17 #include "mojo/edk/embedder/embedder.h" |
| 18 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 void CreateChannelOnIOThread( | 24 void CreateChannelOnIOThread( |
| 24 const GpuProcessHost::CreateArcVideoAcceleratorChannelCallback& callback) { | 25 const GpuProcessHost::CreateArcVideoAcceleratorChannelCallback& callback) { |
| 25 GpuProcessHost* gpu_process_host = | 26 GpuProcessHost* gpu_process_host = |
| 26 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 27 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 27 CAUSE_FOR_GPU_LAUNCH_ARCVIDEOACCELERATOR); | 28 CAUSE_FOR_GPU_LAUNCH_ARCVIDEOACCELERATOR); |
| 28 gpu_process_host->CreateArcVideoAcceleratorChannel(callback); | 29 gpu_process_host->CreateArcVideoAcceleratorChannel(callback); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void HandleChannelCreatedReply( | 32 void HandleChannelCreatedReply( |
| 32 const arc::VideoHost::OnRequestArcVideoAcceleratorChannelCallback& callback, | 33 const arc::VideoHost::OnRequestArcVideoAcceleratorChannelCallback& callback, |
| 33 const IPC::ChannelHandle& handle) { | 34 const IPC::ChannelHandle& handle) { |
| 34 MojoHandle wrapped_handle; | 35 MojoHandle wrapped_handle; |
| 35 MojoResult wrap_result = mojo::embedder::CreatePlatformHandleWrapper( | 36 MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper( |
| 36 mojo::embedder::ScopedPlatformHandle( | 37 mojo::edk::ScopedPlatformHandle( |
| 37 mojo::embedder::PlatformHandle(handle.socket.fd)), | 38 mojo::edk::PlatformHandle(handle.socket.fd)), |
| 38 &wrapped_handle); | 39 &wrapped_handle); |
| 39 if (wrap_result != MOJO_RESULT_OK) { | 40 if (wrap_result != MOJO_RESULT_OK) { |
| 40 LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result; | 41 LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result; |
| 41 callback.Run(mojo::ScopedHandle()); | 42 callback.Run(mojo::ScopedHandle()); |
| 42 return; | 43 return; |
| 43 } | 44 } |
| 44 callback.Run(mojo::ScopedHandle(mojo::Handle(wrapped_handle))); | 45 callback.Run(mojo::ScopedHandle(mojo::Handle(wrapped_handle))); |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace | 48 } // namespace |
| (...skipping 19 matching lines...) Expand all Loading... |
| 67 base::Bind(&HandleChannelCreatedReply, callback))); | 68 base::Bind(&HandleChannelCreatedReply, callback))); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void GpuArcVideoServiceHost::OnStopping() { | 71 void GpuArcVideoServiceHost::OnStopping() { |
| 71 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 72 GpuProcessHost::SendOnIO(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 72 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 73 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
| 73 new GpuMsg_ShutdownArcVideoService()); | 74 new GpuMsg_ShutdownArcVideoService()); |
| 74 } | 75 } |
| 75 | 76 |
| 76 } // namespace content | 77 } // namespace content |
| OLD | NEW |