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 "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h" | 5 #include "chrome/browser/chromeos/arc/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 "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 void GpuArcVideoServiceHost::OnRequestArcVideoAcceleratorChannel( | 55 void GpuArcVideoServiceHost::OnRequestArcVideoAcceleratorChannel( |
56 const OnRequestArcVideoAcceleratorChannelCallback& callback) { | 56 const OnRequestArcVideoAcceleratorChannelCallback& callback) { |
57 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
58 | 58 |
59 // Hardcode pid 0 since it is unused in mojo. | 59 // Hardcode pid 0 since it is unused in mojo. |
60 const base::ProcessHandle kUnusedChildProcessHandle = | 60 const base::ProcessHandle kUnusedChildProcessHandle = |
61 base::kNullProcessHandle; | 61 base::kNullProcessHandle; |
62 mojo::edk::PlatformChannelPair channel_pair; | 62 mojo::edk::PlatformChannelPair channel_pair; |
| 63 std::string child_token = mojo::edk::GenerateRandomToken(); |
63 mojo::edk::ChildProcessLaunched(kUnusedChildProcessHandle, | 64 mojo::edk::ChildProcessLaunched(kUnusedChildProcessHandle, |
64 channel_pair.PassServerHandle()); | 65 channel_pair.PassServerHandle(), child_token); |
65 | 66 |
66 MojoHandle wrapped_handle; | 67 MojoHandle wrapped_handle; |
67 MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper( | 68 MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper( |
68 channel_pair.PassClientHandle(), &wrapped_handle); | 69 channel_pair.PassClientHandle(), &wrapped_handle); |
69 if (wrap_result != MOJO_RESULT_OK) { | 70 if (wrap_result != MOJO_RESULT_OK) { |
70 LOG(ERROR) << "Pipe failed to wrap handles. Closing: " << wrap_result; | 71 LOG(ERROR) << "Pipe failed to wrap handles. Closing: " << wrap_result; |
71 callback.Run(mojo::ScopedHandle(), std::string()); | 72 callback.Run(mojo::ScopedHandle(), std::string()); |
72 return; | 73 return; |
73 } | 74 } |
74 mojo::ScopedHandle child_handle{mojo::Handle(wrapped_handle)}; | 75 mojo::ScopedHandle child_handle{mojo::Handle(wrapped_handle)}; |
75 | 76 |
76 std::string token = mojo::edk::GenerateRandomToken(); | 77 std::string token = mojo::edk::GenerateRandomToken(); |
77 mojo::ScopedMessagePipeHandle server_pipe = | 78 mojo::ScopedMessagePipeHandle server_pipe = |
78 mojo::edk::CreateParentMessagePipe(token); | 79 mojo::edk::CreateParentMessagePipe(token, child_token); |
79 if (!server_pipe.is_valid()) { | 80 if (!server_pipe.is_valid()) { |
80 LOG(ERROR) << "Invalid pipe"; | 81 LOG(ERROR) << "Invalid pipe"; |
81 callback.Run(mojo::ScopedHandle(), std::string()); | 82 callback.Run(mojo::ScopedHandle(), std::string()); |
82 return; | 83 return; |
83 } | 84 } |
84 callback.Run(std::move(child_handle), token); | 85 callback.Run(std::move(child_handle), token); |
85 | 86 |
86 content::BrowserThread::PostTask( | 87 content::BrowserThread::PostTask( |
87 content::BrowserThread::IO, FROM_HERE, | 88 content::BrowserThread::IO, FROM_HERE, |
88 base::Bind( | 89 base::Bind( |
89 &ConnectToVideoAcceleratorServiceOnIOThread, | 90 &ConnectToVideoAcceleratorServiceOnIOThread, |
90 base::Passed( | 91 base::Passed( |
91 mojo::MakeRequest<::arc::mojom::VideoAcceleratorServiceClient>( | 92 mojo::MakeRequest<::arc::mojom::VideoAcceleratorServiceClient>( |
92 std::move(server_pipe))))); | 93 std::move(server_pipe))))); |
93 } | 94 } |
94 | 95 |
95 } // namespace arc | 96 } // namespace arc |
OLD | NEW |